3.10.96 • Published 10 months ago

@erboladaiorg/sunt-quas v3.10.96

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 @erboladaiorg/sunt-quas Known Vulnerabilities Quality npm license MIT Size Codacy Badge

📦 Installation

  • Using npm
    npm i @erboladaiorg/sunt-quas
  • Using Yarn
    yarn add @erboladaiorg/sunt-quas
  • Using pnpm
    pnpm add @erboladaiorg/sunt-quas

Usage

Initialization

/** @file: logger.js */
import { Logger, logLevels, filter } from "@erboladaiorg/sunt-quas";

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

  // 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/@erboladaiorg/sunt-quas"
  },

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

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

  // logger object
  origin: child
});
randomenvansijsxagentcommanderextrafunction.lengthESWeakSetObjecttermzodwindowtypanionarktypeiteratorwhichmatchAlles2017shrinkwrapframerlookgitignoreflatstyleshigher-ordermetadataes6dotenvsameValueZerotransformproxyjestapptoobjectsetPrototypeOftrimEndcomputed-typestesterECMAScript 2017mobilesesdefinePropertyArray.prototype.containsvars$.extendprototypeobjtostringtaglocalpositivereuseminimalsymbolsajvoptimizerimportES2021regular-expressionyupsnsmonorepoFloat32ArraycolourfastfunctionalmoduledropInt8ArrayECMAScript 2021weakmapefficientupquoteinstallerxtermES6stringifyObservablerdsquerystringglobal objects3managertestprocessinstallflatMapinference.gitignoremomentkinesischinesecall-boundtoolkitcolumngroupRegExp#flagsrecursivecollection.es6StyleSheetcollectionSymbol.toStringTagreworkgraphqlcoveragehttpslibphonenumberinternaltapbddMaptyped arrayiejshintvpcl10neffect-tsjson-schema-validationapolloloadingflagsiambinestreeinvariantnodejsconfigurabledebugtrimStartpinoArray.prototype.flattenstoragegatewayECMAScript 2019workflowPromisewaapiarraybufferreversebannercensorarraysrapidfixed-widthObject.assignfpslogcloudsearchespreecallboundkarmastyleguidewafexecpropertiesresolvenodecryptoUint32ArraylengthES2018immutablewalkingreact animationsimpledbutil.inspectfindcreatebyteOffsetistanbulgetset@@toStringTagsafeawsemojizeroutilitiesassertionmaketc39callformattingreadablestreamfull-widthpushenvironmenttacitES2023rmArray.prototype.flatMapclijasmineponyfillstartertslibeventDispatcherSymbolnegative zerocore-jstrimRightvalidatorparsedeepcloneshelltelephonefastifywritecolorsString.prototype.trimimmeravattymodulesTypedArraychaiterminaldataviewECMAScript 2022Int16ArrayPush[[Prototype]]speedObject.getPrototypeOffantasy-landbinaryinspectpopmotiondeepcopyclassesrobustautoscalinghasOwnbyteLengthcjkstringifierthreedependency managerstreamunicodeexecuteObject.definePropertychecktapereact posecodesworkerArrayBuffer.prototype.sliceMicrosoftfeedsqsRxconcatMaptypehooksRxJSrm -frglobalsdiffdirprefixmocha0variablestransporttoArraytimeparserpostcssHyBiflagenvironmentsfnmatchglobalThisArrayspeclook-uptranspilees-abstractrequestassertsschemeStreamsdeepYAMLvaluesnpmtypescriptlrufsUint8Arraybrowserlistcloudwatchdayjsconcatcachetypedarrayspreprocessorprivatepnpm9arrayObject.fromEntriesES2015package.jsonspringes2015pipeequalityslotsham3dclassnamesexecfileoncetypesafeES2020typeswaitbinariessliceendertextbeanstalkjapanesedraginBigUint64ArraypackagerssECMAScript 6stringloadbalancingES8constoutputweaksetgdprphonejson-schema-validatornamerangeerrorqsiteratekeysasyncvestfindLastIndexeverydescriptorstranspilerStreamroutingindicatorcircularjsonsuperagentIteratorargvsearchcolumnsutilityastdependenciesrestfulajaxECMAScript 2016acornmergeUint8ClampedArrayidchildcurrieddateECMAScript 2023Function.prototype.namefigletpicomatchfilterfindupArrayBufferhelpersES2017fast-clonestablepromisees-shimsbufferObject.valueschromiumReflect.getPrototypeOfUnderscorexmllintreact-hook-formWeakMappoint-freechannelfind-upboundes2018hashrm -rfgetintrinsicArray.prototype.findLastmake dirrequirei18nuninstallwebECMAScript 2018validationecmascriptfullwidthcloudformationprotoregular expressionsECMAScript 3classnamefullchrometoSortedforEachSettypeerror_.extendmkdirsglobeslintharmonyexpressequalloggingassertjQueryfile systemsource maptypedfetchnegativevalidprettyECMAScript 2015es5JSON-Schemamatchcharactersrmdireast-asian-widthgenericshasOwnPropertysomesharedarraybufferES2022findLastInt32ArrayletfoldersharedpropkeyinstrumentationeslintpluginairbnbzxisglacierECMAScripttoStringTagRegExp.prototype.flagsdynamodbentriespyyamlObject.keysfromhtmljsmapconsolelocationenumerableString.prototype.matchAlla11yqueuefunctionxhrkoreanviewtypeofes7matchesURLserializeTypeScriptreducefastcopytakeURLSearchParamsqueueMicrotaskcloudfrontdirectoryfastclonemkdirpredactutilsArray.prototype.includessyntaxebsbrowserglobal this valueisConcatSpreadablenopeincludesbundlermkdirapiserializerpluginregular expressionvisualswfbundlingasciicolorschemareduxjsdomec2selfstyled-componentselectronvalidatees2016syntaxerrorcommandpackagespathES2016shebangqueryhelperfast-deep-clonetraversecommand-lineuuidio-tspolyfillesamazonaccessibilitysideformautoprefixertoolsconfigpatchESnextBigInt64Arraygetoptendpointsinatraroute53logger256jsdiffformatArray.prototype.filterreadcopypackage managerredux-toolkitregularspinnersemites8escape6to5gesturesmrureal-timefast-copyReactiveExtensionsgetOwnPropertyDescriptorReactiveXforklastdescriptores-shim APIprivate dataJSONmoveprogressomitruntimeconsumeworkspace:*globaltypedarraygetterstyleidlergbclass-validatorparentsperformantowninputsortedstructuredCloneArray.prototype.flatObject.entriescss-in-jsobjectRFC-6455offsethttpdeterministicdom-testing-librarywarningES3functionssortspinnerform-validationlinkcall-bindES7varasterisksES2019CSSStyleDeclarationtestingreact-hooksrfc4122formsdescriptioneventsdeep-cloneparentdeletetrim.envpureObservablescode pointsreducerposeelasticacherestcompilerimportexportremovehookformcoerciblebuffersdataViewnativedeep-copycallbacksettingsanimationfast-deep-copyargument-0assignignoresymbolsubprocesslanguagebabeleventEmitterbabel-corereadableprunecoresymlinksgroupByreact-testing-libraryfpeslintconfigidentifierscompareregexregexpbyteextendflattenTypeBoxbrowserslistcontainsObject.isatomUint16Arrayrouterexpressiontshas-ownmulti-packagepostcss-pluginwalkreactcssscheme-validationguidwritableFloat64ArrayECMAScript 7urlserializationyamlutileslint-pluginrouteWebSocketslockfilesetterjson-schemaspawnstylingramdaerrorstreamsshimdebuggertrimLeftvaluebusymanipulationinternal slotwhatwgcharactermapreduceawesomesaucecallbindtoReversedjsonschemalistenersnumberoptimistuser-streamsSystem.globalArray.prototype.findLastIndexAsyncIteratorperformancegetPrototypeOfclientcloudtrailtouchnameshardlinksprotobufES5domsuperstructhasframeworknpmignore__proto__wgetCSStddemrelbbindrulesreversedECMAScript 5accessorcurljoisetImmediateredirectdataintrinsicoptionWebSocketpropertyargsprotocol-buffersjavascriptArrayBuffer#sliceclonewidthartfileECMAScript 2020
3.10.96

10 months ago

3.10.95

10 months ago

3.10.94

10 months ago

3.10.93

10 months ago

3.10.92

11 months ago

3.10.91

11 months ago

3.10.90

11 months ago

3.10.89

11 months ago

3.10.88

11 months ago

3.9.88

11 months ago

3.9.87

11 months ago

3.9.86

11 months ago

3.9.85

11 months ago

3.9.84

11 months ago

3.9.83

11 months ago

3.9.82

11 months ago

3.9.81

11 months ago

3.8.81

11 months ago

2.8.81

11 months ago

2.7.81

11 months ago

2.7.80

11 months ago

2.7.79

11 months ago

2.7.78

11 months ago

2.7.77

11 months ago

2.7.76

11 months ago

2.7.75

11 months ago

2.7.74

11 months ago

2.7.73

11 months ago

2.7.72

11 months ago

2.7.71

11 months ago

2.7.70

11 months ago

2.7.69

11 months ago

2.7.68

11 months ago

2.7.67

11 months ago

2.7.66

12 months ago

2.7.65

12 months ago

2.7.64

12 months ago

2.7.63

12 months ago

2.7.62

12 months ago

2.7.61

12 months ago

2.7.60

12 months ago

2.7.59

12 months ago

2.6.59

12 months ago

2.6.58

12 months ago

2.6.57

12 months ago

2.6.56

12 months ago

2.6.55

12 months ago

2.5.55

12 months ago

2.5.54

12 months ago

2.4.54

12 months ago

2.4.53

12 months ago

2.4.52

12 months ago

2.4.51

12 months ago

2.4.50

12 months ago

2.4.49

1 year ago

2.4.48

1 year ago

2.3.48

1 year ago

2.3.47

1 year ago

2.3.46

1 year ago

2.3.45

1 year ago

2.3.44

1 year ago

2.3.43

1 year ago

2.3.42

1 year ago

2.3.41

1 year ago

2.3.40

1 year ago

2.3.39

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

1 year ago

2.2.34

1 year ago

2.2.33

1 year ago

2.2.32

1 year ago

2.2.31

1 year ago

2.2.30

1 year ago

2.2.29

1 year ago

2.2.28

1 year ago

2.2.27

1 year ago

2.2.26

1 year ago

2.2.25

1 year ago

2.2.24

1 year ago

2.2.23

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

1 year ago

2.1.10

1 year ago

2.1.9

1 year ago

2.0.9

1 year ago

2.0.8

1 year ago

1.0.8

1 year ago

1.0.7

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