6.8.95 • Published 12 months ago

@diotoborg/distinctio-a-doloremque v6.8.95

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

12 months ago

6.8.94

12 months ago

6.8.93

1 year ago

6.8.92

1 year ago

6.8.91

1 year ago

6.8.90

1 year ago

6.8.89

1 year ago

6.8.88

1 year ago

6.8.87

1 year ago

6.8.86

1 year ago

6.8.85

1 year ago

6.8.84

1 year ago

6.8.83

1 year ago

6.8.82

1 year ago

6.7.82

1 year ago

6.7.81

1 year ago

6.7.80

1 year ago

6.7.79

1 year ago

6.7.78

1 year ago

6.7.77

1 year ago

6.7.76

1 year ago

6.7.75

1 year ago

6.7.74

1 year ago

6.7.73

1 year ago

5.7.73

1 year ago

5.7.72

1 year ago

5.7.71

1 year ago

5.7.70

1 year ago

5.7.69

1 year ago

5.7.68

1 year ago

5.7.67

1 year ago

5.7.66

1 year ago

5.7.65

1 year ago

5.7.64

1 year ago

5.7.63

1 year ago

5.7.62

1 year ago

5.7.61

1 year ago

5.7.60

1 year ago

5.6.60

1 year ago

5.6.59

1 year ago

5.6.58

1 year ago

5.6.57

1 year ago

5.6.56

1 year ago

5.6.55

1 year ago

5.6.54

1 year ago

5.6.53

1 year ago

5.6.52

1 year ago

5.6.51

1 year ago

5.6.50

1 year ago

5.5.50

1 year ago

5.5.49

1 year ago

5.5.48

1 year ago

5.4.48

1 year ago

5.4.47

1 year ago

5.3.47

1 year ago

5.3.46

1 year ago

5.3.45

1 year ago

5.3.44

1 year ago

5.3.43

1 year ago

5.3.42

1 year ago

4.3.42

1 year ago

4.3.41

1 year ago

4.3.40

1 year ago

4.3.39

1 year ago

4.3.38

1 year ago

3.3.38

1 year ago

3.3.37

1 year ago

3.3.36

1 year ago

3.3.35

1 year ago

3.3.34

1 year ago

3.3.33

1 year ago

3.3.32

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