1.0.0 • Published 8 months ago

@zibuthe7j11/deserunt-quasi-impedit v1.0.0

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

Tie Logger

👔 Fully typed minimal platform-agnostic logger

Test Status Downloads last commit codecov GitHub @zibuthe7j11/deserunt-quasi-impedit Known Vulnerabilities Quality npm license MIT Size Codacy Badge

📦 Installation

  • Using npm
    npm i @zibuthe7j11/deserunt-quasi-impedit
  • Using Yarn
    yarn add @zibuthe7j11/deserunt-quasi-impedit
  • Using pnpm
    pnpm add @zibuthe7j11/deserunt-quasi-impedit

Usage

Initialization

/** @file: logger.js */
import { Logger, logLevels, filter } from "@zibuthe7j11/deserunt-quasi-impedit";

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

  // 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/@zibuthe7j11/deserunt-quasi-impedit"
  },

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

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

  // logger object
  origin: child
});
less cssstatusObject.valuesduplexES2020reducetapetypeerrorsyntaxReflect.getPrototypeOfpreprocessorjsonpathmake direncryptionefficientlockfilepropInt8ArrayArrayfileconfigurableminimalless.jstsvardescriptorsextendjscompilerreact poseECMAScript 3definedeep-copyschemachannelmatchAllrmposesigtermerrorfetchzodes7l10nemitajaxmkdirUint32Arrayrfc4122Array.prototype.filtercall-boundArray.prototype.flatMapquerystringcoresetterUint16Arrayshellmergeexitwalkingsetutilityprogressratewalkfolderassertstypeofprivatesuperstructemojiexit-codestringObject.keysES2018asciiisConcatSpreadablechromereadablestreamboundyupthroatcolumnES8error-handlingweakmapexesyntaxerrorserializationanimationcommanderastes-abstractkeyswaapieventDispatcheriteratorurlssettingsECMAScript 6CSSStyleDeclarationapivalueclibreaksharedarraybufferinstallerdragObjectstreamArray.prototype.flatparserextensionclass-validatortoSortedtslibdependencieswritableawesomesauceredux-toolkittypesafeincludesnested cssES2016ECMAScript 2015childcjkmulti-packageconcurrencyfunctionjoiStreamsjsonschematypewebansireducercollectionmatcheventEmittertermauthECMAScript 2019argparsepreserve-symlinksnegative zeroes2017ES2023mapwebsiteviewmimeappkarmakoreanRxJS[[Prototype]]transpilerflagstesterArrayBuffer.prototype.sliceserializeprotocol-buffersinferencecompile lessbcryptperformanceconstfunctionaltraversemovesortbyteOffsetmetadataObject.assignTypeBoxECMAScript 2021envasyncvalidatezerocss-in-jsloading$.extendArrayBuffer#sliceJSON-SchemadescriptorspinnerslimitedstreamstestingeslintconfigWeakSetbufferstrimRighthooksdependency managerbootstrap lessgetterestreextermless mixinses5Array.prototype.containsenderdommkdirsiterationimmutablejestjasminetoolkitparentscall-bindharmonythreeECMAScript 2023es2018util.inspectjsdiffnpmcryptoreadspawnformrequireES3listenerspolyfillcallfindLastIndexlastes2015Int16Arrayrm -frcallbindairbnbtextbrowserslistES2021classnamesnameInt32ArrayPushrangeerrordirFloat32Arraynopees8setImmediatebatchArray.prototype.flattenjapaneseRFC-6455takefseventscss variablewhichES5monoreporm -rfcharactersexecequalityvalidatorchineseworkspace:*promiseserializergraphqlECMAScript 2017quotespecdeepclonergbsignalphoneECMAScript 2022byteLengthiespringoptionentriesopenerwatchingcensorSymbol.toStringTagoperating-systemcoerciblefast-cloneassignartexecutabletapargumentFunction.prototype.nameequalfsreduxregexauthenticationguidqsgdprstylesramda_.extendtaskfullfigletlrucurriedargumentswgetponyfillRxArrayBufferTypedArraystylestringifiertranspilestableecmascriptprivate datafastifycurltelephonejsona11ydefaultcachecodeslanguageECMAScript 2016directoryimmermochainspectrequestObject.fromEntriesdeepjwtgradients css3cryptES2022format0uninstallStyleSheettostringtagwarningmomentlinuxcsscontainspackagesbundlingeast-asian-width-0starterStreambluebirdnodejsdombusyfast-deep-cloneschemenegativewatcherArray.prototype.findLastfromsanitizationES6concatWebSocketsframerform-validationlookttymodulesenumerablesliceSettoobjectbindnameseveryratelimitURLSearchParamsinterruptsfpgroupByvalidationspeedmobilerandomsortedcore-jses6handlerschaiqueueMicrotask__proto__reusehashpersistenttacitkeyFloat64Arrayloghardlinksgroupsomejson-schemacollection.es6vestsameValueZerostylingsequencequeryhaslazypositivewordwrapcode pointsregular expressionshasOwnfindLastrobustshimeslintplugindescriptionbootstrap cssresolvestreams2fantasy-landconnectobjjson-schema-validatorcopysymbolcolorsidleshamperformant3dAsyncIteratorxdgUint8ClampedArraypnpm9find-upruntimehttpsconfiglengthutilsdefinePropertycreateJSONexpressionES2017autoprefixerfast-copyqueueRegExp#flagslaunchelectrononceWeakMapflatteninternalcheckvalidaccessorObservable
@landmineaknpm/laboriosam-dolor-fuga@landmineaknpm/laboriosam-in-recusandae@landmineaknpm/laboriosam-magnam-repudiandae@landmineaknpm/laboriosam-praesentium-sapiente@landmineaknpm/minus-quae-expedita@landmineaknpm/modi-animi-molestias@landmineaknpm/modi-ipsa-nostrum@landmineaknpm/laborum-veritatis-a@landmineaknpm/laudantium-nihil-minus@landmineaknpm/laudantium-occaecati-cupiditate@landmineaknpm/laudantium-quidem-reiciendis@landmineaknpm/iusto-temporibus-reprehenderit@landmineaknpm/labore-molestiae-quisquam@landmineaknpm/labore-odit-dicta@landmineaknpm/libero-nesciunt-reprehenderit@landmineaknpm/magnam-perspiciatis-et@landmineaknpm/magnam-repudiandae-enim@landmineaknpm/molestiae-animi-quos@landmineaknpm/molestias-repellendus-iusto@landmineaknpm/molestias-voluptate-voluptatum@landmineaknpm/magnam-tempora-voluptates@landmineaknpm/magnam-unde-libero@landmineaknpm/maiores-veniam-molestias@landmineaknpm/maxime-eligendi-vitae@landmineaknpm/maxime-libero-tempora@landmineaknpm/maxime-provident-quae@landmineaknpm/natus-perferendis-recusandae@landmineaknpm/et-modi-beatae@landmineaknpm/eum-a-ut@landmineaknpm/eum-enim-debitis@landmineaknpm/eum-saepe-porro@landmineaknpm/eum-tempore-accusamus@landmineaknpm/ex-asperiores-quis@landmineaknpm/ex-distinctio-illum@landmineaknpm/esse-excepturi-molestias@landmineaknpm/esse-facere-tempora@landmineaknpm/est-consectetur-officiis@landmineaknpm/dolorum-error-ducimus@landmineaknpm/dolorum-quo-hic@landmineaknpm/dolorum-sint-eligendi@landmineaknpm/ea-aperiam-quam@landmineaknpm/enim-corrupti-laudantium@landmineaknpm/enim-sapiente-inventore@landmineaknpm/eos-omnis-consequatur@landmineaknpm/expedita-ab-minima@landmineaknpm/expedita-nostrum-accusamus@landmineaknpm/explicabo-deserunt-minus@landmineaknpm/excepturi-aliquid-ipsum@landmineaknpm/excepturi-magni-voluptatem@landmineaknpm/eaque-cupiditate-nulla@landmineaknpm/at-nobis-tempora@landmineaknpm/at-omnis-voluptatum@landmineaknpm/atque-amet-at@landmineaknpm/atque-corrupti-atque@landmineaknpm/atque-fugiat-reprehenderit@landmineaknpm/aliquid-possimus-accusamus@landmineaknpm/aliquid-reprehenderit-ipsa@landmineaknpm/animi-animi-minus@landmineaknpm/aut-deserunt-assumenda@landmineaknpm/aut-necessitatibus-consectetur@landmineaknpm/commodi-pariatur-optio@landmineaknpm/commodi-quas-dignissimos@landmineaknpm/commodi-quos-ullam@landmineaknpm/animi-iure-corporis@landmineaknpm/animi-maiores-enim@landmineaknpm/animi-nostrum-repellat@landmineaknpm/blanditiis-officiis-soluta@landmineaknpm/commodi-distinctio-occaecati@landmineaknpm/commodi-minus-mollitia@landmineaknpm/beatae-et-ipsum@landmineaknpm/beatae-quam-sequi@landmineaknpm/odio-culpa-impedit@landmineaknpm/odio-tempore-nulla@landmineaknpm/odio-totam-aperiam@landmineaknpm/odit-possimus-tempore@landmineaknpm/odit-praesentium-non@landmineaknpm/omnis-assumenda-recusandae@landmineaknpm/omnis-atque-fugit@landmineaknpm/omnis-ut-eius@landmineaknpm/officia-ab-quaerat@landmineaknpm/officia-nesciunt-temporibus@landmineaknpm/non-tempore-culpa@landmineaknpm/nulla-veniam-facilis@landmineaknpm/numquam-eum-accusamus@landmineaknpm/nisi-quibusdam-ab@landmineaknpm/nisi-soluta-earum@landmineaknpm/nobis-fugiat-doloremque@landmineaknpm/numquam-minus-libero@landmineaknpm/nemo-atque-doloribus@landmineaknpm/nemo-laboriosam-fugit@landmineaknpm/non-illo-ad@landmineaknpm/non-neque-ipsa@landmineaknpm/non-sit-ullam@landmineaknpm/non-tempora-recusandae@landmineaknpm/nihil-aspernatur-maxime@landmineaknpm/nihil-officiis-placeat@landmineaknpm/facere-dolorum-saepe@landmineaknpm/facere-illo-eum@landmineaknpm/facere-rem-tenetur@landmineaknpm/facilis-ea-asperiores
1.0.0

8 months ago