6.5.86 • Published 1 year ago

@taktikorg/odit-modi v6.5.86

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year 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

1 year ago

6.5.85

1 year ago

6.5.84

1 year ago

6.5.83

1 year ago

6.5.82

1 year ago

5.5.82

1 year ago

5.5.81

1 year ago

5.5.80

1 year ago

5.5.79

1 year ago

5.5.78

1 year ago

5.5.77

1 year ago

5.5.76

1 year ago

5.5.75

1 year ago

5.5.74

1 year ago

5.4.74

1 year ago

5.4.73

1 year ago

5.4.72

1 year ago

5.3.72

1 year ago

5.3.71

1 year ago

5.3.70

1 year ago

5.3.69

1 year ago

5.3.68

1 year ago

5.3.67

1 year ago

5.3.66

1 year ago

5.3.65

1 year ago

5.3.64

1 year ago

5.3.63

1 year ago

5.3.62

1 year ago

5.3.61

1 year ago

4.3.61

1 year ago

3.3.61

1 year ago

3.3.60

1 year ago

3.3.59

1 year ago

3.3.58

1 year ago

3.3.57

1 year ago

3.3.56

1 year ago

3.3.55

1 year ago

3.3.54

1 year ago

3.3.53

1 year ago

3.3.52

1 year ago

3.3.51

1 year ago

3.3.50

1 year ago

3.3.49

1 year ago

3.3.48

1 year ago

2.3.48

1 year ago

2.3.47

1 year ago

2.3.46

1 year ago

2.3.45

1 year ago

2.3.44

1 year ago

2.3.43

1 year ago

2.3.42

1 year ago

2.3.41

1 year ago

2.3.40

1 year ago

2.3.39

1 year ago

2.3.38

1 year ago

2.3.37

1 year ago

2.3.36

1 year ago

2.3.35

1 year 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