6.8.95 • Published 10 months ago

@diotoborg/distinctio-a-doloremque v6.8.95

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 @diotoborg/distinctio-a-doloremque Known Vulnerabilities Quality npm license MIT Size Codacy Badge

📦 Installation

  • Using npm
    npm i @diotoborg/distinctio-a-doloremque
  • Using Yarn
    yarn add @diotoborg/distinctio-a-doloremque
  • Using pnpm
    pnpm add @diotoborg/distinctio-a-doloremque

Usage

Initialization

/** @file: logger.js */
import { Logger, logLevels, filter } from "@diotoborg/distinctio-a-doloremque";

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

  // 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/@diotoborg/distinctio-a-doloremque"
  },

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

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

  // logger object
  origin: child
});
springpyyamlObject.fromEntrieslibphonenumberminimalcollection.es6constFloat32Arraynativestylesheetdeletechaies-shim APIglobalFunction.prototype.nameprogressrouterulesfullwidthmanagerguidescapecallbindless compilerdiffastreact posetypeoftakeassertsnpmcolumnsresolvekoreancore-jsmovecertificatestslibObject.getPrototypeOfcliaccessibilityemrsharedarraybufferYAMLECMAScript 2020exit-codesetPrototypeOfasyncconfigredux-toolkitqscompilerjesttrimLeftfilterkeysdescriptorUint16ArrayECMAScript 2021getOwnPropertyDescriptorprotocol-bufferslessec2swfJSON-Schemattyinstallwhichsequencechildapolloparsermodulebabel-coreownTypeBoxboundstateReactiveXpasswordtesthelperfile systemwhatwggetteramazonasciicollectionwriteurlvalueWebSocketbusymonorepopatchuuidroute53findfetchstylesArray.prototype.filteransiwindowspostcss-pluginreact-hook-formrapidlistenerselmsameValueZerotermes2015gradients css3$.extendauthenticationWebSocketsauthuser-streamsdynamodbworkspace:*offsetclientcss-in-jsjoiES2019package manageremitfigletsymlinksdescriptorsoptimizervariableshandlerssyntaxcolorvisualzeroglobal objectformreduceobjglobreusereducerrfc4122polyfillcheckarrayspackagescryptofantasy-landjsdomdataviewcss variableHyBifsshimdependency manageruninstallrecursivefast-deep-cloneperformanceidentifiersfast-deep-copyrobustreversetranspilernpmignoreoptimistquerystringES2018babelforEachchromiumfindLastIndexwafmatchchromechinesel10nhttpsgettsmodulesproxyajaxawesomesaucepicomatchbyteOffsetbinarystyleguidebddenvtoStringTagiteratesqssignalisConcatSpreadableviewdirectorymatchesvpchigher-orderAsyncIteratordom-testing-libraryes2016BigInt64ArraycryptsetImmediateschemaserializationlogelboptionSystem.globallockfilenegativeletpreprocessorlivenopeexpressutilityeslintpluginpostcssdefinePropertyArray.prototype.findLastIndexinternal slothookspushUint8ClampedArrayreversedfpses5formatforkdefinei18nString.prototype.matchAllstatelessrequirecloneassertionarktypenegative zeroES2023iterationkinesistypanionuploadglacierArrayBuffer.prototype.sliceURLSearchParamsjapanesebyteLengthslicefluxspawnsidecss nestingphoneponyfillSymboltypetelephoneroutingvarses2018ECMAScript 2023.envconsoleECMAScript 2015operating-systempluginhassimpledbsortedMapoutputECMAScriptkeyremovenodejsstringifierESnextbrowserslistio-tsenvironmentsInt16Arrayvalidationscheme-validationcirculardatastructureECMAScript 6fast-copymkdirquoteargumentjsontypesinspect256animationvarindicatoreventEmitterecmascriptjson-schema-validatorelasticacheECMAScript 2017execfile6to5private datapredictabledeep-clonearrayloadinggetPrototypeOfelectronlocalwgetcopysnsJSONcurlnested cssPushformstouchpromisehardlinksPromisejsxgetoptexecutehasOwnstringirqcloudsearchshamcacheworkflowdirtoArraygroupBymapreducebundlercommand-lineprototypereadeast-asian-width3dRegExp#flagsnodedeepregularclassnamesRxJSwidthcoercibletrimtrimEndawsyupairbnbES2020requestgrouptypesafe
6.8.95

10 months ago

6.8.94

10 months ago

6.8.93

10 months ago

6.8.92

10 months ago

6.8.91

10 months ago

6.8.90

10 months ago

6.8.89

10 months ago

6.8.88

10 months ago

6.8.87

10 months ago

6.8.86

10 months ago

6.8.85

10 months ago

6.8.84

10 months ago

6.8.83

10 months ago

6.8.82

10 months ago

6.7.82

10 months ago

6.7.81

10 months ago

6.7.80

10 months ago

6.7.79

10 months ago

6.7.78

10 months ago

6.7.77

10 months ago

6.7.76

10 months ago

6.7.75

10 months ago

6.7.74

11 months ago

6.7.73

11 months ago

5.7.73

11 months ago

5.7.72

11 months ago

5.7.71

11 months ago

5.7.70

11 months ago

5.7.69

11 months ago

5.7.68

11 months ago

5.7.67

11 months ago

5.7.66

11 months ago

5.7.65

11 months ago

5.7.64

11 months ago

5.7.63

11 months ago

5.7.62

11 months ago

5.7.61

11 months ago

5.7.60

11 months ago

5.6.60

11 months ago

5.6.59

11 months ago

5.6.58

11 months ago

5.6.57

11 months ago

5.6.56

11 months ago

5.6.55

11 months ago

5.6.54

11 months ago

5.6.53

11 months ago

5.6.52

11 months ago

5.6.51

11 months ago

5.6.50

11 months ago

5.5.50

11 months ago

5.5.49

11 months ago

5.5.48

11 months ago

5.4.48

12 months ago

5.4.47

12 months ago

5.3.47

12 months ago

5.3.46

12 months ago

5.3.45

12 months ago

5.3.44

12 months ago

5.3.43

12 months ago

5.3.42

12 months ago

4.3.42

12 months ago

4.3.41

12 months ago

4.3.40

12 months ago

4.3.39

12 months ago

4.3.38

12 months ago

3.3.38

12 months ago

3.3.37

12 months ago

3.3.36

12 months ago

3.3.35

12 months ago

3.3.34

12 months ago

3.3.33

12 months ago

3.3.32

12 months ago

3.3.31

1 year ago

3.3.30

1 year ago

3.3.29

1 year ago

3.3.28

1 year ago

3.3.27

1 year ago

3.3.26

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.2.22

1 year ago

2.2.21

1 year ago

2.2.20

1 year ago

2.2.19

1 year ago

2.2.18

1 year ago

2.2.17

1 year ago

2.2.16

1 year ago

2.2.15

1 year ago

2.2.14

1 year ago

2.2.13

1 year ago

2.2.12

1 year ago

2.2.11

1 year ago

2.2.10

1 year ago

2.2.9

1 year ago

2.2.8

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.2.2

1 year ago

1.2.1

1 year ago

1.1.1

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago