6.5.86 • Published 10 months ago

@taktikorg/odit-modi v6.5.86

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/odit-modi Known Vulnerabilities Quality npm license MIT Size Codacy Badge

📦 Installation

  • Using npm
    npm i @taktikorg/odit-modi
  • Using Yarn
    yarn add @taktikorg/odit-modi
  • Using pnpm
    pnpm add @taktikorg/odit-modi

Usage

Initialization

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

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/odit-modi"}',
    parts: [
      "Application initialized. Port:",
      { port: 3000 },
      ". Environment: ",
      {
        SHELL: "/bin/bash",
        COLORTERM: "truecolor",
        PWD: "/home/alexxgrib/Projects/@taktikorg/odit-modi"
      }
    ]
  },

  // 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/odit-modi"
  },

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

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

  // logger object
  origin: child
});
browsersameValueZero256argvyamltypeofjQuerystructuredCloneArrayBuffer.prototype.slicetypedom-testing-librarycharacterECMAScript 7URLSearchParamsvalidationqsserializedependency managerArray.prototype.flattenlocalutilsrapidframersortcloudformationsharedglobalshotbrowserlistemittestingschemeObject.isperformancecss variabletakegetPrototypeOfcomputed-typesformatpyyamlgenericsstringifierMicrosoftreactobjwhatwgString.prototype.trimspecsymlinkservicetoobjectstablejoideepStreampostcssfast-deep-clonedescriptorjshintes-shim APIenvregularbabeldependenciesjavascriptextra3doncetc39xtermMappoint-freeespreenpmjwtECMAScript 2022toArraystarterES2016artreducereadsyntaxhardlinksArray.prototype.flatMapcall-boundlockfilesignalsshebangreduxvarcoreredux-toolkitcodesflattenvariables in csspropbytebinariesredirectendpointArray.prototype.findLastArray.prototype.includesjsES2022boundfront-endObservableoffsetassertsexpressRegExp.prototype.flagslanguagebundlerdomreact animationenvironmentinternal slotInt32Arrayajaxaccessorvaluesawsmkdirsassertionflagsphoneless cssless compilerString.prototype.matchAllless mixins-0findLastIndexgradients csscryptoirqmovelrupipeWeakMapregexpositivesigtermvalidatorlesscssdatastructurehas-owncallboundFloat64Arrayapollopathfull-widthjsoncss nestingoptimizerchromemoduleforEachurlfixed-widthpureprefixbufferBigInt64Arrayes2018zerolastchildstatussidenopesigintentriesexecuteeventEmitterincludespatchpackagesserializerprocessregular expressionES7warningprototype6to5class-validatorcompilercreateECMAScript 2019textspringjson-schema-validationemrslicemulti-packageiteratecachecompareWebSocketargumentanimationfindLastTypeScriptjapaneseconcatMaproute53getomitimmutableutilitybundlingredactReactiveXenumerablestringifytoSortedcliqueryawesomesauceprogresssubprocesskinesisnumberwaittypedarrayhelperflatpushRxs3fast-copy0simpledbkeysarraystestperformantObservablesbyteOffsetfluxwhichglobalzxcurriedweakmapconcatstatelesshttpshigher-orderspawnpostcss-pluginiterationshamgetterestreesetPrototypeOfsesmatchAllmanagerglobalThisforkextendisConcatSpreadableinObject.entriesfssetImmediateES2017hookseffect-tssignedcjkES2021Int8ArrayescapelessauthenticationhelpersECMAScript 2023fnmatches6deepcloneeslint-pluginequalexeccheckES2015io-tstrimStart_.extendrandomTypedArrayregular-expressionprotomapreduceESnextassignflagbcryptStyleSheethttpjsonschemaUint32ArraySystem.globalArray.prototype.filterstringglaciercopyelectronkoreanloadbalancinglinuxgraphqlquoteReflect.getPrototypeOfmatchelasticachefunctionalquerystringRFC-6455curlpreserve-symlinksgetintrinsicutil.inspectgesturesinstallfunction.lengthworkflowqueuei18nInt16ArraystyletoStringTagslotWebSocketsfindviewclassnameschemadescriptioncloudsearchthreeglobal objectArray.prototype.flatbinarylive@@toStringTagbinObject.valuesinferencees2016Promisemixinstoolkitformsrgbfast-clonecall-bindconfigECMAScript 2016browserslistObject.getPrototypeOfsymbolshrinkwrapglobal this valuefetchtypeerrornativevalueunicodecryptSymbolpluginECMAScript 2017npmignorefast-deep-copyregexpObject.keysidlecallbindintrinsicvariablesjestexit-codeclassnamespopmotiondeep-copyiamerrorroutees2017ES3RegExp#flagsreact-testing-libraryreact-hooksoptionPushsuperstructequalityinvariantendera11ybddspeedharmonyefficientconsumeArray[[Prototype]]tslibdescriptorssharedarraybufferchaiiteratorless.jsreusetrimEndES2018busyvalidauthcommanderdirstyleguideexecfileramda
6.5.86

10 months ago

6.5.85

10 months ago

6.5.84

10 months ago

6.5.83

10 months ago

6.5.82

10 months ago

5.5.82

10 months ago

5.5.81

10 months ago

5.5.80

10 months ago

5.5.79

11 months ago

5.5.78

11 months ago

5.5.77

11 months ago

5.5.76

11 months ago

5.5.75

11 months ago

5.5.74

11 months ago

5.4.74

11 months ago

5.4.73

11 months ago

5.4.72

11 months ago

5.3.72

11 months ago

5.3.71

11 months ago

5.3.70

11 months ago

5.3.69

11 months ago

5.3.68

11 months ago

5.3.67

11 months ago

5.3.66

11 months ago

5.3.65

11 months ago

5.3.64

11 months ago

5.3.63

11 months ago

5.3.62

11 months ago

5.3.61

11 months ago

4.3.61

11 months ago

3.3.61

11 months ago

3.3.60

11 months ago

3.3.59

11 months ago

3.3.58

11 months ago

3.3.57

11 months ago

3.3.56

11 months ago

3.3.55

11 months ago

3.3.54

11 months ago

3.3.53

12 months ago

3.3.52

12 months ago

3.3.51

12 months ago

3.3.50

12 months ago

3.3.49

12 months ago

3.3.48

12 months ago

2.3.48

12 months ago

2.3.47

12 months ago

2.3.46

12 months ago

2.3.45

12 months ago

2.3.44

12 months ago

2.3.43

12 months ago

2.3.42

12 months ago

2.3.41

12 months ago

2.3.40

12 months ago

2.3.39

12 months ago

2.3.38

12 months ago

2.3.37

12 months ago

2.3.36

12 months ago

2.3.35

12 months ago

2.3.34

1 year ago

2.3.33

1 year ago

2.3.32

1 year ago

2.3.31

1 year ago

2.3.30

1 year ago

2.3.29

1 year ago

2.3.28

1 year ago

2.3.27

1 year ago

2.3.26

1 year ago

2.3.25

1 year ago

2.3.24

1 year ago

2.3.23

1 year ago

2.3.22

1 year ago

2.3.21

1 year ago

2.3.20

1 year ago

2.3.19

1 year ago

2.3.18

1 year ago

2.3.17

1 year ago

2.3.16

1 year ago

2.3.15

1 year ago

2.3.14

1 year ago

2.3.13

1 year ago

2.2.13

1 year ago

2.1.13

1 year ago

2.1.12

1 year ago

2.1.11

1 year ago

2.1.10

1 year ago

2.1.9

1 year ago

2.1.8

1 year ago

2.1.7

1 year ago

2.1.6

1 year ago

2.1.5

1 year ago

2.1.4

1 year ago

2.1.3

1 year ago

2.1.2

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago