2.7.102 • Published 10 months ago

@patrtorg/cumque-atque v2.7.102

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

10 months ago

2.7.101

10 months ago

2.6.101

10 months ago

2.6.100

10 months ago

2.6.99

10 months ago

2.6.98

10 months ago

2.6.97

10 months ago

2.6.96

10 months ago

2.6.95

10 months ago

2.6.94

10 months ago

2.6.93

10 months ago

2.6.92

10 months ago

2.5.92

10 months ago

2.5.91

10 months ago

2.5.90

10 months ago

2.5.89

10 months ago

2.5.88

10 months ago

2.5.87

10 months ago

2.5.86

10 months ago

2.5.85

10 months ago

2.5.84

11 months ago

2.5.83

11 months ago

2.5.82

11 months ago

2.5.81

11 months ago

2.5.80

11 months ago

2.5.79

11 months ago

2.5.78

11 months ago

2.5.77

11 months ago

2.5.76

11 months ago

2.5.75

11 months ago

2.5.74

11 months ago

2.5.73

11 months ago

2.5.72

11 months ago

2.5.71

11 months ago

2.5.70

11 months ago

2.5.69

11 months ago

2.5.68

11 months ago

2.5.67

11 months ago

2.4.67

11 months ago

2.4.66

11 months ago

2.4.65

11 months ago

2.4.64

11 months ago

2.4.63

11 months ago

2.4.62

11 months ago

2.4.61

11 months ago

2.4.60

11 months ago

2.4.59

11 months ago

2.4.58

11 months ago

2.4.57

11 months ago

2.4.56

11 months ago

2.4.55

12 months ago

2.3.55

12 months ago

2.3.54

12 months ago

2.3.53

12 months ago

2.3.52

12 months ago

2.3.51

12 months ago

2.3.50

12 months ago

2.3.49

12 months ago

2.3.48

12 months ago

2.3.47

12 months ago

2.3.46

12 months ago

2.3.45

12 months ago

2.3.44

12 months ago

2.3.43

12 months ago

2.3.42

12 months ago

2.3.41

12 months ago

2.3.40

12 months ago

2.3.39

12 months ago

2.3.38

12 months ago

2.3.37

12 months 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