2.6.74 • Published 12 months ago

@hishprorg/ad-minima v2.6.74

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 @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

12 months ago

2.6.73

12 months ago

2.6.72

12 months ago

2.6.71

1 year ago

2.6.70

1 year ago

2.6.69

1 year ago

2.6.68

1 year ago

2.6.67

1 year ago

2.6.66

1 year ago

2.6.65

1 year ago

2.6.64

1 year ago

2.6.63

1 year ago

2.6.62

1 year ago

2.6.61

1 year ago

2.6.60

1 year ago

2.6.59

1 year ago

2.6.58

1 year ago

2.6.57

1 year ago

2.6.56

1 year ago

2.6.55

1 year ago

2.6.54

1 year ago

2.6.53

1 year ago

2.6.52

1 year ago

2.6.51

1 year ago

2.6.50

1 year ago

2.5.50

1 year ago

2.5.49

1 year ago

2.5.48

1 year ago

2.5.47

1 year ago

2.5.46

1 year ago

2.5.45

1 year ago

2.5.44

1 year ago

2.5.43

1 year ago

2.5.42

1 year ago

2.4.42

1 year ago

2.4.41

1 year ago

2.4.40

1 year ago

2.3.40

1 year ago

2.2.40

1 year ago

2.2.39

1 year ago

2.2.38

1 year ago

2.2.37

1 year ago

2.2.36

1 year ago

2.1.36

1 year ago

2.1.35

1 year ago

2.1.34

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