2.6.74 • Published 11 months ago

@hishprorg/ad-minima v2.6.74

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

Tie Logger

👔 Fully typed minimal platform-agnostic logger

Test Status Downloads last commit codecov GitHub @hishprorg/ad-minima Known Vulnerabilities Quality npm license MIT Size Codacy Badge

📦 Installation

  • Using npm
    npm i @hishprorg/ad-minima
  • Using Yarn
    yarn add @hishprorg/ad-minima
  • Using pnpm
    pnpm add @hishprorg/ad-minima

Usage

Initialization

/** @file: logger.js */
import { Logger, logLevels, filter } from "@hishprorg/ad-minima";

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

  // 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/@hishprorg/ad-minima"
  },

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

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

  // logger object
  origin: child
});
ObservablemetadatathreeECMAScript 2019valuecallbackreactECMAScript 2023fastifyinlasttostringtagreadglobalThis256ECMAScript 6compilersortpicomatchoutputnamesES2019groupdataviewcopypositiveES2020assertbundlingfantasy-landinstallCSSStyleDeclarationspinnerses-abstractdifftestervalidatecommand-lineeffect-tsvalidES6visualutilsstatelessfnmatchpromiseinvariantvalidatorsharedarraybufferassertionnodejsreal-timeshrinkwrapgetopta11yIteratortslibdependenciesFloat32Arraycolourtestes2017ES2016channelsymbolsafewhatwgbabeljson-schema-validationarrayhashfunctionalirqdatees2016core-jspackage managerReflect.getPrototypeOfreact-hook-formmatchtsstylingSystem.globalfastcopyqueuettyWebSocketbrowserdescriptorglobalsObject.valuesreduxtestinginternalclonemake dirzodoperating-systemlazydropstylesfpsECMAScript 7route53byteOffsetownInt16ArraytrimLeftmomentaccessibilityArray.prototype.flattenbinariesrobustdeterministicexecfileautoscalingjavascriptharmonyasciideletecompareregexsesregulardayjsswfidleobjectebsUint16Arrayfunction.lengthstreamequalreact-testing-libraryemrargvinstallerpoint-freepreserve-symlinksbusyfunctiongraphqlchildYAMLeveryjsmockingmoveprefixArrayBuffer#slicefsfullwidthi18ntacitindicatoreventshigher-orderreact-components3objfluxjsdiffprogressforEachemitloadbalancingcolumnsHyBiclientsymbolscommanderincludesrdsbytedom-testing-libraryerrorresolveregexppathcloudsearchhooksspecgdpransicsskoreanenumerableflattenauthenticationcryptoairbnbtypedeventDispatcherxtermenvironmentsecmascriptramdaschemacollection.es6Pushstateisidentifierscall-boundnpmignoreURLSearchParamsroutingoptimizersetPrototypeOfES2017WeakSetlogjwtlinuxdirFunction.prototype.nameuninstallconstrecursiveTypedArrayhotArrayES2018columncollectionECMAScript 2021deepcopyelmcss lessES3ES2021mkdirtouchexecutevpcgetOwnPropertyDescriptorbeanstalkmakecacheESnextArrayBuffer.prototype.sliceES7Int32Arrayhelperreact posewaapimatchesredacteslintpluginpreprocessorRegExp#flagssortedacorncoerciblegetPrototypeOfchromiumgetvestweakmapcjkconsoleextrabyteLengthmulti-packagepluginfast-cloneconcatless cssmixinselbtrimlesscontainsenderpackageslistenerses2015sqsiterateECMAScript 2015reducelocationsuperstructponyfillArray.prototype.filterinspectencryptionqueueMicrotaskpopmotionworkflowsyntaxerrorcallchaicensorzxcurriedimportexportes5schemearktypevalidationvarsfindwalkObservablessharedcss nestingxhrnodeObject.assignarraybufferwindowtimeutil.inspectestreeconfignegative zerodependency managerhardlinksfigletmkdirsdefinetoSortedgestureslibphonenumberphoneapolloelectronchromeclass-validatorparsercreateclassnamesES2015es-shim APIconcatMapprotocol-buffersCSScertificateseslint-pluginescapeendpointwaitfile systemquoteserviceequalitypruneselfanimationuploadTypeScriptlogginggitignorelink[[Prototype]]compile lessspringjshinteventEmitterhandlerECMAScript 2017dynamodbECMAScript 2016full-widthposespawnargsArray.prototype.findLastbcryptcheckimmerObject.getPrototypeOfuser-streamsrapidObject.entriesArray.prototype.includesloggerArray.prototype.containsstylecurlfromECMAScript 2018assertsBigUint64Arraylesscssopensslsubprocessreact-hooksECMAScript 3json-schemazeroinputextenddeep-copyflagRxJSloadingcloudfrontfast-copyeslintconfigMicrosoftbinarystyled-componentsexitsettingshelpersmapreduceECMAScript 2020wgetprocessparseTypeBoxlengthhookformwafsliceio-tsexecutilitypushmkdirpwritableglobexpresskinesisgradients css3tddwhichsignalsspeedmruenvexit-codeformatsimpledbtypesafeclassestc39espreeES2022internal slotremovemodulescomputed-typesbrowserlistiebindframerfindLastes8toolsiterationdeep-clonecommandmergeless.jsprototypeiamproxytexttranspilepersistenteast-asian-widthstyleguidebddregular expressiondescriptionprototoobjectform-validationformreact animationclassnameunicodeSetbrowserslistconsumesigtermRegExp.prototype.flagsmapbin$.extendBigInt64ArrayletwindowsauthhandlersflatMap
2.6.74

11 months ago

2.6.73

11 months ago

2.6.72

11 months ago

2.6.71

11 months ago

2.6.70

11 months ago

2.6.69

11 months ago

2.6.68

11 months ago

2.6.67

11 months ago

2.6.66

11 months ago

2.6.65

11 months ago

2.6.64

11 months ago

2.6.63

11 months ago

2.6.62

11 months ago

2.6.61

11 months ago

2.6.60

11 months ago

2.6.59

11 months ago

2.6.58

11 months ago

2.6.57

11 months ago

2.6.56

11 months ago

2.6.55

11 months ago

2.6.54

11 months ago

2.6.53

11 months ago

2.6.52

11 months ago

2.6.51

11 months ago

2.6.50

11 months ago

2.5.50

11 months ago

2.5.49

12 months ago

2.5.48

12 months ago

2.5.47

12 months ago

2.5.46

12 months ago

2.5.45

12 months ago

2.5.44

12 months ago

2.5.43

12 months ago

2.5.42

12 months ago

2.4.42

12 months ago

2.4.41

12 months ago

2.4.40

12 months ago

2.3.40

12 months ago

2.2.40

12 months ago

2.2.39

12 months ago

2.2.38

12 months ago

2.2.37

12 months ago

2.2.36

12 months ago

2.1.36

12 months ago

2.1.35

12 months ago

2.1.34

12 months ago

2.1.33

1 year ago

2.1.32

1 year ago

2.1.31

1 year ago

2.1.30

1 year ago

2.1.29

1 year ago

2.1.28

1 year ago

2.1.27

1 year ago

2.1.26

1 year ago

2.1.25

1 year ago

2.1.24

1 year ago

2.1.23

1 year ago

2.1.22

1 year ago

2.1.21

1 year ago

2.1.20

1 year ago

2.1.19

1 year ago

2.1.18

1 year ago

2.1.17

1 year ago

2.1.16

1 year ago

2.1.15

1 year ago

2.1.14

1 year ago

1.1.14

1 year ago

1.1.13

1 year ago

1.1.12

1 year ago

1.1.11

1 year ago

1.1.10

1 year ago

1.1.9

1 year ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

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