2.7.102 • Published 12 months ago

@patrtorg/cumque-atque v2.7.102

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 @patrtorg/cumque-atque Known Vulnerabilities Quality npm license MIT Size Codacy Badge

📦 Installation

  • Using npm
    npm i @patrtorg/cumque-atque
  • Using Yarn
    yarn add @patrtorg/cumque-atque
  • Using pnpm
    pnpm add @patrtorg/cumque-atque

Usage

Initialization

/** @file: logger.js */
import { Logger, logLevels, filter } from "@patrtorg/cumque-atque";

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

  // 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/@patrtorg/cumque-atque"
  },

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

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

  // logger object
  origin: child
});
efficient256Object.is__proto__String.prototype.trimyamldiffoutputdynamodbselfhookscollection.es6symlinksless mixinsroutingec2settingssafemapreducestylesfunctionalArray.prototype.flatMapwhatwgcloneoptimizerString.prototype.matchAllsuperstructES2022ESnextECMAScript 2018configurablesortedmonorepoownhashruntimetypescriptES8deepcopygetreadtc39trimRightspawnprocessmodulesglobal objectes-shim APIsyntaxperformantES2017grouphandlertypedarrayhassortfast-copymaplibphonenumberECMAScript 2015clienttsproxySymboltoArrayglobal this valueboundmulti-packageisConcatSpreadableasciiECMAScript 6private datastatelessspinnersdeterministicchromiumReactiveXstylesheetyupajvregularcommand-lineglobaleslintpluginschemapackage.jsonfluxES7waitagentterminalkeyomit_.extendpostcss-pluginsubprocessexpressjsxpicomatchansipolyfilldeleteautoprefixersharedarraybufferArray.prototype.flattentextchromepropertycoerciblearrayscolumnebsless csstypeerrorconstrandomreact-componentpositivetypedarraysformattinggenericsserializeECMAScript 2021ruleshardlinksreducelocationStreamsless compilerObservablefront-endextrapredictablebufferprototypejestmixinspyyamlwhichsomefullwidthtyped arraycompile lesspackageschineseflattens3shimprivate.envimmutable6to5fastcloneauthenticationinferenceUint8ClampedArraycallmanagertrimEnddeep-copylessRegExp.prototype.flagsunicodeES2016quotecachebundlertakepasswordredux-toolkitcommandtranspilerfindLastquerycompareiterateUint16ArrayCSSStyleDeclarationfantasy-landgetintrinsicgetoptvalidationindicatorreadablestreamserializationArray.prototype.findLastform-validationzerostarterObservablesbindependency managermatchAllsequencevaluebyteLengthjsonidentifiersframerimmersigintscheme-validationendpointartfixed-widthdateURLSearchParamscodesbeanstalkcloudformationmruonceES2018symbolscss lesstranspilecloudsearchponyfillassigndependenciesgraphqlreducerPushelasticacheterminternal slotkoreanUnderscoreformatobjectviewajaxgradients css3PromisecrypthttplazyendercloudwatchlengthmobileiepluginStreamassertemrgdprvalidateES2019classesutilwgetstatusnpmignoresymlinklesscssairbnbcallbindeffect-tsargsWebSocketscloudtrailreusecopyinstallproptoobjectutilsdayjsmatchharmonyutil.inspectdroploggingclassnameses2015queueMicrotasksetterhasOwn$.extendlistenerstacithttpssesoptimistcall-boundcommandercryptoroute53toSortedfigletdragcallbacktraversesetdatahandlers@@toStringTagasyncpnpm9awswaflinuxnegative zeroECMAScript 5javascriptbrowserlistglobwaapitoolsdescriptorstringifyvpcpromisetslibtddbootstrap lessloadingreal-timeredirectparsetimehelpersflagschannelObject.fromEntriesbinariesbusylocalregexpstylees-shimscollectionregular expressionawesomesauceopensslcreate
2.7.102

12 months ago

2.7.101

12 months ago

2.6.101

12 months ago

2.6.100

1 year ago

2.6.99

1 year ago

2.6.98

1 year ago

2.6.97

1 year ago

2.6.96

1 year ago

2.6.95

1 year ago

2.6.94

1 year ago

2.6.93

1 year ago

2.6.92

1 year ago

2.5.92

1 year ago

2.5.91

1 year ago

2.5.90

1 year ago

2.5.89

1 year ago

2.5.88

1 year ago

2.5.87

1 year ago

2.5.86

1 year ago

2.5.85

1 year ago

2.5.84

1 year ago

2.5.83

1 year ago

2.5.82

1 year ago

2.5.81

1 year ago

2.5.80

1 year ago

2.5.79

1 year ago

2.5.78

1 year ago

2.5.77

1 year ago

2.5.76

1 year ago

2.5.75

1 year ago

2.5.74

1 year ago

2.5.73

1 year ago

2.5.72

1 year ago

2.5.71

1 year ago

2.5.70

1 year ago

2.5.69

1 year ago

2.5.68

1 year ago

2.5.67

1 year ago

2.4.67

1 year ago

2.4.66

1 year ago

2.4.65

1 year ago

2.4.64

1 year ago

2.4.63

1 year ago

2.4.62

1 year ago

2.4.61

1 year ago

2.4.60

1 year ago

2.4.59

1 year ago

2.4.58

1 year ago

2.4.57

1 year ago

2.4.56

1 year ago

2.4.55

1 year ago

2.3.55

1 year ago

2.3.54

1 year ago

2.3.53

1 year ago

2.3.52

1 year ago

2.3.51

1 year ago

2.3.50

1 year ago

2.3.49

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

1 year ago

2.3.37

1 year ago

2.3.36

1 year ago

2.3.35

1 year ago

2.3.34

1 year ago

2.3.33

1 year ago

2.3.32

1 year ago

2.3.31

1 year ago

2.3.30

1 year ago

2.3.29

1 year ago

2.3.28

1 year ago

2.3.27

1 year ago

2.3.26

1 year ago

2.3.25

1 year ago

2.3.24

1 year ago

2.3.23

1 year ago

2.3.22

1 year ago

2.2.22

1 year ago

2.2.21

1 year ago

2.2.20

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

1 year ago

2.0.16

1 year ago

2.0.15

1 year ago

2.0.14

1 year ago

2.0.13

1 year ago

2.0.12

1 year ago

2.0.11

1 year ago

2.0.10

1 year ago

2.0.9

1 year ago

2.0.8

1 year ago

2.0.7

1 year ago

2.0.6

1 year ago

2.0.5

1 year ago

2.0.4

1 year ago

2.0.3

1 year ago

2.0.2

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

1.0.0

1 year ago