1.0.4 • Published 1 year ago

@hishprorg/neque-excepturi v1.0.4

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 @hishprorg/neque-excepturi Known Vulnerabilities Quality npm license MIT Size Codacy Badge

📦 Installation

  • Using npm
    npm i @hishprorg/neque-excepturi
  • Using Yarn
    yarn add @hishprorg/neque-excepturi
  • Using pnpm
    pnpm add @hishprorg/neque-excepturi

Usage

Initialization

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

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

  // 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/neque-excepturi"
  },

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

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

  // logger object
  origin: child
});
scheme-validationajaxcallboundcss lessmodulefast-copyreusewritablemapwhichcolumnserializernegative zeroslotBigInt64ArrayhttpsString.prototype.trimtrimLeftfunction.lengthsequenceenvoperating-systemclassnametranspileglacierargsObject.isvalueasyncschemaprivate data3dloadingoffsetquotejsjapaneseECMAScript 2016syntaxerroreslintpluginopensslreadawswgetES2015pnpm9eslintconfigpoint-freeawesomesaucearraysassertsdayjstakeutilssortedECMAScript 2021symlinkqueueMicrotaskownsettingskeysarraybuffergettersubprocesstyped arraylinkweakmapObject.assignstatestyleguidejsonschemaexpresscloudsearchtypedarraycss nestingES2019directoryespreepropertyURLforEachdependenciesgesturescolorscorestylingstarterPromisepasswordpruneanimationzxformpathloadbalancingnodecss variableclassessymbolspackage.jsonrequestbytemacoshasfluxtypedarraystelephonespringmockingRxJSreact animationmetadataelmregular expressionconfigprototypeutilityfullwidthloggergradients cssnamestypefilterES2017immutableelectroncoloures2016diffstatelesspackagescommand-lineframer256accessibilityreadablewindowsSetnativelogpopmotionserializationwaitfigletdatexhrwarningdynamodbfast-deep-cloneTypeBoxobjes8reducereveryregexpdatastructuretypesflatMapextendstringRxresolveperformancetouchlocalschemenegativesuperagentcoerciblesymlinksES3listenerszodbyteLengthbabel-coreeast-asian-widthebscall-bindESnextinferenceObject.entriessesprivateless mixinsmomentTypeScriptefficientmkdirpmanageriteratemixinscurried$.extendECMAScript 2023core-jsforkansies-shimsrapidjson-schema-validatorECMAScript 2020hooksfasttypeoflinttransporttrimshimuser-streamsboundtoolseventsstreamautoprefixerfnmatchmovefunctionalwhatwgtranspilersortxtermemrhas-ownInt16Arrayfsreact poseReflect.getPrototypeOfenumerableemitlanguageinputtrimRightbundlertacitcompile lessfast-cloneinspectECMAScript 7regexexitexecfileerrorECMAScript 2019mkdirseffect-tsmruES2020artCSSWebSocketpushcompileridentifierschannelmapreducesigtermglobalsproxyestreeruntimequerystringecmascripttoolkitUnderscoreES7removetraverseTypedArrayroute53apolloserverprettychromedataviewtslibhelpervalidateECMAScript 3codessignedObject.fromEntriesjson-schemacloudformationArray.prototype.findLastIndexprotocol-buffersglobalThistestingasterisksdeep-copyStreamdefineBigUint64Arraylesscsses2017setspinnerObjecthookformletoutputhardlinksclass-validatorsymbolnpmextraspeedstatussomepostcssjshintprogressArray.prototype.flatMapkinesisiteratorfullHyBiimportcallbackcolumnsclientcjkgraphqlsuperstructObject.definePropertyconcatMapcryptponyfilldefinePropertyio-tsfetchcheck_.extendfindlocationequalfastcopyYAMLtesterfantasy-landpyyamlstreamsnumberhashes7widthpromiseminimalmatchessetterpatchmatchAlldescriptionregular-expressionJSONjavascriptservicethreeworkflowfull-widthshrinkwrapArray.prototype.findLastglobalreplayinvariantqsvalidatortostringtagrouteJSON-SchemaCSSStyleDeclarationelbdeepcopyfppolyfilltypanionsetPrototypeOfrecursiveequalitylengthmatchmkdirassignutilbyteOffsetutil.inspectSymbolRegExp.prototype.flagsECMAScripteslint-pluginwriteSymbol.toStringTagbuffersbannercss-in-jsfpsfixed-width0ArrayBuffer.prototype.slicesyntaxnpmignoresqsstableselfassertionpureconsolecloudfronttypesafekeybeanstalkgdprspawnproprequiredescriptorUint8ClampedArrayvestidleArray.prototype.filterbundlingbootstrap lessyupirq__proto__collectionjsdiffstringifiertrimStartsignalmake dirtypedECMAScript 2018walkstyled-componentsexecuteenvironmentssimpledbdependency managerpinoECMAScript 5descriptorstc39ObservablesyamlObject.keysfunctionUint16ArrayArrayBuffer#slicecomputed-typesinspinnershandlerjQuerytoobjecttoArraysameValueZerovisualhotMicrosoftprocessredirectcontainsFloat32ArrayshellbrowserslistbinariescertificatesmonorepoESprotoECMAScript 2022constutilitiesflagsjson-schema-validationsideparserandomnopepostcss-pluginamazonhelperscurlprefixnamedropajvcommanderenders3esweaksetfastifyES2022internal slotparserformatcreateglobal this valuepluginpreserve-symlinkssetImmediateobjectconfigurablebrowserstylestylesheetES2016regularviewStyleSheetunicodeinstallvalidationglobal objectimportexportfast-deep-copyposeramdakoreanes6query-0WeakSetjsonES5child[[Prototype]]ECMAScript 2015WeakMapObject.getPrototypeOfcallArrayBufferArrayarktypefunctionsgitignoreignoreformattingless.jsoptimistoptionbrowserlistescapecloudwatchtestgroupBydom-testing-libraryrobustWebSocketsworkereventDispatcherassertback-endshebangreact-hook-formvarsdeterministices2015bootstrap cssvariablesbddredactvariables in csshandlerssafees2018ECMAScript 2017mobilebusyuninstallttyjsdomphonedeep-cloneECMAScript 6real-timedatacopybinStreamsexecgradients css3package managergetPrototypeOfvaluesauthdireventEmitterterminalroutingdragRegExp#flagsreact-hookspipefile systemmodulescloudtrailrdsvarString.prototype.matchAllexpressioneslintreactstructuredCloneiterationlastmakeFunction.prototype.nameURLSearchParamsflaghigher-orderprotobufReactiveExtensionstermvalidfindLastIndexInt32Arraytypescriptes5chinesewindowcryptopicomatchieconcatdotenvwaflessincludesreact-componentglobrulesIteratortsFloat64Arraycssec2specredux-toolkiterror-handlingMapwaapistoragegatewayperformantentriesdeepcloneArray.prototype.containssharedarraybufferjoicompareimmerreact-testing-librarydeepjsxtoStringTagurl.gitignoregenericsstyles@@toStringTagencryptionpersistentmockfindLastisConcatSpreadablenested cssreduceenvironmentagentshamoptimizerswfES8arrayqueueloggingiamworkspace:*lruObservableaccessorUint8Arrayreduxstringifychaidomes-abstractserializeArray.prototype.includeslockfileInt8Array6to5commandArray.prototype.flatmergegetautoscalingbinarySystem.globalObject.valuesliverangeerrorlibphonenumbercircularslicecallbind.envpredictableargumenttextintrinsicfront-endclonergbcolorgetOwnPropertyDescriptorbindform-validationsnscacheuploadtddflatl10nES2021formsless compilerless cssclassnamesjwtinstallerES2018fastclonenodejsbcryptchromiumargvendpointvpcisapicharactera11ymulti-packagejestUint32Array
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