5.10.82 • Published 10 months ago

@taktikorg/aperiam-iure v5.10.82

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

Tie Logger

👔 Fully typed minimal platform-agnostic logger

Test Status Downloads last commit codecov GitHub @taktikorg/aperiam-iure Known Vulnerabilities Quality npm license MIT Size Codacy Badge

📦 Installation

  • Using npm
    npm i @taktikorg/aperiam-iure
  • Using Yarn
    yarn add @taktikorg/aperiam-iure
  • Using pnpm
    pnpm add @taktikorg/aperiam-iure

Usage

Initialization

/** @file: logger.js */
import { Logger, logLevels, filter } from "@taktikorg/aperiam-iure";

export const logger = new Logger(
  "app", // Root logger name
  logLevels(), // Define log levels. By default are: verbose, debug, info, warn, error, fatal
  // You can use custom levels by using
  // logLevels("info", "warn", "error")

  {
    // Custom data
    appVersion: "3.1"
    moduleName: "root",
    moduleVersion: "1.0.0"
  }
);

export const child = logger.child(
  // Child logger name
  "auth",

  // Child logger data
  { moduleName: "auth", moduleVersion: "0.3.1" }
);

const criticalLogs = [];

const unsubscribe = logger.subscribe(
  // Subscribe to all logs, they go to console
  (log) => console.log(...log.message.parts),

  // All logs, that level is greater or equal than "warn" will be added to critical logs

  // Severity is determined by index of level in levels array
  // Current array is: verbose, debug, info, warn, error, fatal
  //                             [less] <<<  ^^^^   >> [greater]
  filter(">=", "warn", (log) => criticalLogs.push(log))
)

process.on("SIGINT", () => {
  unsubscribe();
})

Logging

/** @file: index.js */
import { child, logger } from "./logger.js";

const PORT = parseInt(process.env.PORT) || 3000;
logger.subscribe(log => console.log(log));

child.log.debug`Application initialized. Port: ${{ port: PORT }}. Environment: ${{process.env}}`;
// Level:  ^^^^^

// Here goes app

Log format

({
  // One of defined levels
  level: "debug",

  message: {
    template:
      "Application initialized. Port: {port}. Environment: {SHELL,COLORTERM,PWD}",
    plain:
      'Application initialized. Port: 3000. Environment: {"SHELL":"/bin/bash","COLORTERM":"truecolor","PWD":"/home/alexxgrib/Projects/@taktikorg/aperiam-iure"}',
    parts: [
      "Application initialized. Port:",
      { port: 3000 },
      ". Environment: ",
      {
        SHELL: "/bin/bash",
        COLORTERM: "truecolor",
        PWD: "/home/alexxgrib/Projects/@taktikorg/aperiam-iure"
      }
    ]
  },

  // merge of
  // - logger data
  // - logger parents data
  // - data passed in log message
  data: {
    appVersion: "3.1",
    moduleName: "auth",
    moduleVersion: "0.3.1",
    port: 3000,
    SHELL: "/bin/bash",
    COLORTERM: "truecolor",
    PWD: "/home/alexxgrib/Projects/@taktikorg/aperiam-iure"
  },

  context: {
    // name of the logger
    name: "auth",

    // list of logger inheritance
    path: ["app", "auth"]
  },

  // logger object
  origin: child
});
Object.assignhttpssesreact-componentpasswordpackage managercss-in-jsiteratecensorURLvalueArray.prototype.findLastmixinstostringtagcryptodeterministicArray.prototype.flatMapconcatmomentreactkeysstylesheetInt8Arraybyteconsumehandlerselectroncontainsfast-deep-copytoArraywindowdiffES2023exit-codeECMAScript 2023syntaxes2018privatehardlinkspackage.jsonreducevpcprocessArrayBuffer#slicerecursiveautoprefixerreact-hook-formcompile lessjsdomhookformformsexecreact-testing-libraryfastcloneloggerpostcss-pluginassertsObservablesreduxvestlocalbufferhasOwnsafeUnderscorepushvariables in cssObject.definePropertyredirectequalityObjectfunctionloadbalancingopenssleslintconfigwalkrdspathrangeerrorramdasortedlivewgetstylezerofpsmkdirfindLast_.extendclientyamltypanionpredictablefromtermpropertyvarserror-handlingsymlinksRxswfi18nes-abstractdataviewbundlersymbolharmonypostcsscss lessstoragegatewaycloudtrailReflect.getPrototypeOfRegExp.prototype.flagss3objectform-validationinvariantdataamazonECMAScript 2016descriptorcjkagentdropstyleguideenderBigUint64ArrayvalidationObject.keysapollofastcommanderfiltergraphqltslibstylingless csshasOwnPropertyoptimistArray.prototype.flatMapconcatMapimmutableregular expressionsidestringscheme-validationflattenhelperscloudwatchbrowserlistlrudefineeventDispatcherECMAScript 7getintrinsicimportexportcreateruntimeurlgetOwnPropertyDescriptorsetsortRxJScodesposehashES7movemkdirpuploadspinnerhttpTypeScripttrimLeftespreeeslintdescriptorskoreanvalidateschemesettertypescriptYAMLl10nsimpledbHyBistructuredCloneregulartraverseclonepnpm9startercloudformationemrtypesafeawesomesaucefsgroupworkerdeletebeanstalkes-shimsfunction.lengthpolyfillshrinkwrapvalidaccessibilityaccessoriteratortc39lengthtrimEnddeeptacitECMAScript 3call-bindeast-asian-widthbyteLengthsharedarraybufferoffsetfindLastIndexbootstrap csschildjson-schema-validatorbootstrap lessvisualformatacornequaljsonisConcatSpreadableregexpstatelessdom-testing-librarypromisereadablemockingfnmatchcopytexttoStringTageffect-tshot$.extendescapeartwafreact animationinmodulesECMAScript 2017ajvutilityes8classescssshebangsqsquerystringremovejsxnpmargsglobalfastcopytoolsdragreducerquotehasloadingobjtesterfullwidthvaluesAsyncIteratordirrulesrgbassignuser-streamslinknegativereadablestreamtransportdirectorysetImmediatefpArray.prototype.findLastIndexprogressprettyvalidatorECMAScript 2022requestpropertiesreusemobileserializechinesecliflattypees5requireshamPromisetrimasteriskstestcollectionexecuteFloat64ArrayponyfillcompilermakeECMAScript 2021global objectCSSStyleDeclarationmanagerieunicodetypedarrayfast-clonebuffersvariablesArray.prototype.flattenfastifyESnextglobal this valueendpointawsexpressionkeygdprroutinggradients css3ECMAScript 6Uint16ArrayajaxglobalThistestinges7matchessymbolsworkflowassertionbundlingerrorbindotenvstringifyestreedatastructure.gitignoreArrayBuffer.prototype.slicereact posesuperstructintrinsicphonehooksextranumberstreamsexpressroute53eventEmitterArray.prototype.includesecmascripthelperoptionfunctionalBigInt64Arrayauthmake dirtrimRightprototypeES5Pushpurewhichutilframerfront-endtakeless compilertoobjectArray.prototype.filterES2015forkregexbabel-coreUint32Arraysns@@toStringTagspeedformattingdependencieszxmatchdateidlepicomatch[[Prototype]]isflatMapIteratorserverbinarypositivecircularECMAScript 2015browserviewasyncFloat32Arraycolorsweaksetconfigurablethreetssettingsnegative zerotdddomelbcommanddeepclonerapidMicrosoftObject.fromEntriesirqhas-ownWebSocketrobustlazystableoptimizerutilsprivate dataxhrboundWeakMapassertlockfileinternal slot__proto__channelpropescolumnspersistentpopmotionzodclassnamesgesturesencryptioninferencetypesbindtypedarrayspreserve-symlinksbannercomparecoreignorefigletinstallwarningReactiveExtensionscharacter
5.10.82

10 months ago

5.10.81

10 months ago

5.10.80

10 months ago

5.10.79

10 months ago

5.10.78

10 months ago

5.9.78

10 months ago

5.9.77

10 months ago

5.9.76

10 months ago

4.9.76

11 months ago

4.9.75

11 months ago

4.9.74

11 months ago

4.9.73

11 months ago

4.9.72

11 months ago

4.8.72

11 months ago

4.8.71

11 months ago

4.8.70

11 months ago

4.8.69

11 months ago

4.8.68

11 months ago

4.7.68

11 months ago

4.7.67

11 months ago

4.7.66

11 months ago

4.6.66

11 months ago

4.6.65

11 months ago

4.6.64

11 months ago

4.6.63

11 months ago

4.6.62

11 months ago

4.6.61

11 months ago

4.6.60

11 months ago

4.6.59

11 months ago

4.6.58

11 months ago

4.6.57

11 months ago

4.6.56

11 months ago

4.6.55

11 months ago

4.6.54

11 months ago

4.6.53

11 months ago

4.6.52

11 months ago

4.6.51

11 months ago

4.6.50

11 months ago

4.6.49

12 months ago

4.5.49

12 months ago

4.5.48

12 months ago

4.5.47

12 months ago

4.5.46

12 months ago

4.5.45

12 months ago

4.5.44

12 months ago

4.5.43

12 months ago

4.5.42

12 months ago

4.5.41

12 months ago

4.5.40

12 months ago

4.5.39

12 months ago

4.5.38

12 months ago

4.4.38

12 months ago

4.4.37

12 months ago

4.4.36

12 months ago

4.4.35

12 months ago

4.4.34

12 months ago

4.4.33

12 months ago

4.4.32

12 months ago

3.4.32

1 year ago

3.4.31

1 year ago

3.4.30

1 year ago

3.4.29

1 year ago

2.4.29

1 year ago

2.4.28

1 year ago

2.4.27

1 year ago

2.4.26

1 year ago

2.4.25

1 year ago

2.4.24

1 year ago

2.4.23

1 year ago

1.4.23

1 year ago

1.4.22

1 year ago

1.4.21

1 year ago

1.4.20

1 year ago

1.4.19

1 year ago

1.4.18

1 year ago

1.4.17

1 year ago

1.3.17

1 year ago

1.3.16

1 year ago

1.3.15

1 year ago

1.3.14

1 year ago

1.3.13

1 year ago

1.2.13

1 year ago

1.2.12

1 year ago

1.2.11

1 year ago

1.2.10

1 year ago

1.2.9

1 year ago

1.2.8

1 year ago

1.2.7

1 year ago

1.2.6

1 year ago

1.2.5

1 year ago

1.2.4

1 year ago

1.2.3

1 year ago

1.1.3

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago