4.10.96 • Published 10 months ago

@patrtorg/porro-similique-blanditiis v4.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 @patrtorg/porro-similique-blanditiis Known Vulnerabilities Quality npm license MIT Size Codacy Badge

📦 Installation

  • Using npm
    npm i @patrtorg/porro-similique-blanditiis
  • Using Yarn
    yarn add @patrtorg/porro-similique-blanditiis
  • Using pnpm
    pnpm add @patrtorg/porro-similique-blanditiis

Usage

Initialization

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

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

  // 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/porro-similique-blanditiis"
  },

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

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

  // logger object
  origin: child
});
awsform-validationramdacommandfunctionsArray.prototype.flatpurestreamsfpsdeepcopyconsumebootstrap lessInt16Arraychainopesettings0metadataloadings3System.globalutilsisprotocol-buffersglobalThisschemafullinstallgdprtrimEndrgbstatustsbannerReflect.getPrototypeOfTypeScriptreact-componentArrayoncespinnercompile lessdirectoryglacierrulesexitfpkeyreal-timeoptimizerutilequalityframerES3clonecolumnsymlinktimebabelfastcopy3dreverseglobcacheasciireact poseconcatMapfixed-widthreduceObject.entriessharedacornroute53envECMAScriptregular expressiontranspilecryptchannelglobal objectperformancetouchStreamsreduxcompilerdescriptionlocalObject.assignserializationUint8Arraycommanderpostcss-pluginimportexportsequencerapidgenericssetterflatMapclientswfmatchvalidationbindSymbol.toStringTagnpmdeep-clonesyntaxerroriteratorvalidreadablestreamuuidelmdragregularassertsfunctionReactiveXhttpjshintyuptypesafecopyPushreusemakeECMAScript 2019stylingargvurlECMAScript 6byteLengthfast-copysymbolvpcdatebrowserlistsaferfc9562awesomesauceloadbalancingresolve256MapimportarrayESnextdependenciestrimStartutil.inspectmacosroutingdefinebytedeletetslibnamesCSSStyleDeclarationregular-expressionintrinsicFunction.prototype.namebyteOffsetstructuredCloneRegExp.prototype.flagswhatwgmergeES2022superstructObjectvariables in csstypeerrorfastifyperformantstreamlazyelasticachecloudtrailsyntaxassigncsstoolsfilterArray.prototype.findLastIndextrimelectronUint32ArraytoolkitRegExp#flagsreadArrayBuffer.prototype.sliceajaxcodesserializebundlingdirBigInt64Arraymatchesspringjsonobjremoveless compileres5mapmanagerlistenerscss-in-jsreversedES2017numberfastcloneeventsmulti-packagees8vestgradients css3classnamedynamodbpruneposeenumerablegroupBychildgetponyfilltransportnpmignoremodulesphonebootstrap csscallboundtranspilerthreegetoptpoint-freeWeakSetindicatorObject.definePropertyqueryeventDispatchercertificateslastString.prototype.trimreact-hook-formbrowserTypedArrayWeakMapfrompreprocessorreplaytypedarraysinttyfileprefixproxyes-shimszerocolorsUint16ArrayhttpsESredactprogressIterator_.extendterminalgetintrinsicjson-schema-validationconfigdomsorteddescriptorsmonorepocss variablelinkexpressionsuperagentparsertypescripthardlinksInt32Arraynegativecloudsearchexecutecomputed-typesbufferArrayBuffer#slicefluxcolourjwtwgetcensorpushstringifierregexparktypesubprocessprettyenvironmentsquoteemit
4.10.95

10 months ago

4.10.96

10 months ago

4.10.94

10 months ago

4.10.93

10 months ago

4.10.92

10 months ago

4.10.91

10 months ago

4.10.90

10 months ago

4.10.89

10 months ago

4.10.88

10 months ago

4.10.87

10 months ago

4.10.86

10 months ago

4.10.85

10 months ago

4.10.84

10 months ago

3.10.84

10 months ago

3.10.83

10 months ago

3.9.83

10 months ago

3.9.82

10 months ago

3.9.81

10 months ago

3.9.80

10 months ago

3.9.79

11 months ago

3.9.78

11 months ago

3.9.77

11 months ago

3.9.76

11 months ago

3.9.75

11 months ago

3.9.74

11 months ago

3.9.73

11 months ago

3.9.72

11 months ago

3.9.71

11 months ago

3.9.70

11 months ago

3.9.69

11 months ago

3.9.68

11 months ago

3.9.67

11 months ago

3.8.67

11 months ago

3.8.66

11 months ago

3.8.65

11 months ago

3.8.64

11 months ago

3.8.63

11 months ago

3.8.62

11 months ago

3.8.61

11 months ago

3.8.60

11 months ago

3.8.59

11 months ago

3.8.58

11 months ago

3.8.57

11 months ago

3.8.56

11 months ago

3.8.55

11 months ago

3.8.54

11 months ago

3.8.53

11 months ago

3.8.52

11 months ago

3.8.51

11 months ago

3.8.50

12 months ago

3.7.50

12 months ago

3.7.49

12 months ago

3.7.48

12 months ago

2.7.48

12 months ago

2.6.48

12 months ago

2.6.47

12 months ago

2.6.46

12 months ago

2.6.45

12 months ago

2.6.44

12 months ago

2.6.43

12 months ago

2.6.42

12 months ago

2.6.41

12 months ago

2.6.40

12 months ago

2.6.39

12 months ago

2.6.38

12 months ago

2.6.37

12 months ago

2.6.36

12 months ago

2.6.35

12 months ago

2.6.34

12 months ago

2.5.34

1 year ago

2.5.33

1 year ago

2.5.32

1 year ago

2.5.31

1 year ago

2.5.30

1 year ago

2.5.29

1 year ago

2.5.28

1 year ago

2.4.28

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

1 year ago

2.3.20

1 year ago

2.3.19

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

1 year ago

2.1.10

1 year ago

2.1.9

1 year ago

2.1.8

1 year ago

2.1.7

1 year ago

2.0.7

1 year ago

2.0.6

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