2.4.106 • Published 10 months ago

@diotoborg/inventore-beatae v2.4.106

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 @diotoborg/inventore-beatae Known Vulnerabilities Quality npm license MIT Size Codacy Badge

📦 Installation

  • Using npm
    npm i @diotoborg/inventore-beatae
  • Using Yarn
    yarn add @diotoborg/inventore-beatae
  • Using pnpm
    pnpm add @diotoborg/inventore-beatae

Usage

Initialization

/** @file: logger.js */
import { Logger, logLevels, filter } from "@diotoborg/inventore-beatae";

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

  // 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/@diotoborg/inventore-beatae"
  },

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

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

  // logger object
  origin: child
});
utilitiesArray.prototype.filterslicegetpackage.jsonzodjshintes2017lazyfullwidthmobileworkflowback-endfilechannelspecjson-schema-validationviewpreprocessordefineerrorbcryptastfilterflagsbeanstalkhotECMAScript 2019io-tstslibphoneArray.prototype.findLastprivatereact-hookscallbackcodesrobustserializerloggeriteratordayjsbinariespopmotionstatees2015waapioperating-systemimmutablesomearraybufferautherror-handlingapicompareObject.assignconcathookformespreeelasticacheomitproxyignoresymlinkmkdircertificatesinternalasteriskschromiumamazonES2020opensslassertshelpersframergetoptmake dirprotobufsafedataviewtrimEndintrinsicpathpromiseESfast-deep-copydatastructureroute53globaldateassignStreamsconsumeexpressionwarningmatcheshandlerslistenersiteratemapreducetoArrayeast-asian-widthHyBifastifynodejsutilsArrayBuffer#sliceArraysymbolsnpmignorelintquerystringpostcssjsonvariables in csspackage managerJSON-Schematypeerror.gitignoretoolkitwritableajaxbrowserlistjestselfECMAScript 2020typedarrayuninstallsymlinksdataViewstyleguidelastmanagerownObject.fromEntriesinvariantasyncoutputremovejapaneseArray.prototype.flattencss nestingansifpmkdirpwgettoolsmixinsregular-expressionprotocol-buffersbusypnpm9computed-typesdiffprunebootstrap lessonceoffsetgesturesbyteOffsetbyteefficientsharedmatchforEaches2018postcss-pluginECMAScript 5ReactiveXYAMLes7eslintfast-clonetyped arrayformattingtransportreduxArray.prototype.findLastIndexrulesES2022whatwgcolormkdirsgetOwnPropertyDescriptortakerecursivetestingemrpasswordshellenvwritesuperstructloadbalancinginternal slotzxes-shim APIxhryamlstyled-componentshas-ownisfast-deep-clonees6signalsbootstrap cssquoteemitecmascripttimedependenciestypedarraysfantasy-landTypedArrayperformancestatuscacheschemerangeerrorsqscallbindfindStyleSheetReactiveExtensionswaitIteratorkoreanrandomvaluebundlerflatFloat32Array@@toStringTagelbvarshebangexecutelru0loadingroutecss variableroutingStreamformsmetadatacloudsearchprocessassertionawsbddSetfluxRxJSbuffersbabelparsechineseairbnbexitnopetrimRightUint8ClampedArrayECMAScript 7valuesless.jsimporttc39momentcloudwatchsetImmediateprogressObject.isiterationdirectorynodefromArray.prototype.includesirqvalidpropertiesstructuredClonepoint-freejson-schemaECMAScript 2018matchAllcommandebsvalidatepinoes-abstractregexelectronlogpyyaml
2.4.106

10 months ago

2.4.105

10 months ago

2.4.104

10 months ago

2.4.103

10 months ago

2.4.102

10 months ago

2.4.101

10 months ago

2.4.100

10 months ago

2.4.99

10 months ago

2.4.98

10 months ago

2.4.97

10 months ago

2.4.96

10 months ago

2.3.96

10 months ago

2.3.95

11 months ago

2.3.94

11 months ago

2.3.93

11 months ago

2.3.92

11 months ago

2.3.91

11 months ago

2.3.90

11 months ago

2.3.89

11 months ago

2.3.88

11 months ago

2.3.87

11 months ago

2.3.86

11 months ago

2.3.85

11 months ago

2.3.84

11 months ago

2.3.83

11 months ago

2.3.82

11 months ago

2.3.81

11 months ago

2.3.80

11 months ago

2.3.79

11 months ago

2.3.78

11 months ago

2.3.77

11 months ago

2.3.76

11 months ago

2.3.75

11 months ago

2.3.74

11 months ago

2.3.73

11 months ago

2.2.73

11 months ago

2.2.72

11 months ago

2.2.71

11 months ago

2.2.70

11 months ago

2.2.69

11 months ago

2.2.68

11 months ago

2.2.67

11 months ago

2.2.66

12 months ago

2.2.65

12 months ago

2.2.64

12 months ago

2.2.63

12 months ago

2.2.62

12 months ago

2.2.61

12 months ago

2.2.60

12 months ago

2.2.59

12 months ago

2.2.58

12 months ago

2.2.57

12 months ago

2.1.57

12 months ago

2.1.56

12 months ago

2.0.56

12 months ago

2.0.55

12 months ago

2.0.54

12 months ago

2.0.53

12 months ago

2.0.52

12 months ago

2.0.51

12 months ago

2.0.50

12 months ago

2.0.49

12 months ago

1.0.49

1 year ago

1.0.48

1 year ago

1.0.47

1 year ago

1.0.46

1 year ago

1.0.45

1 year ago

1.0.44

1 year ago

1.0.43

1 year ago

1.0.42

1 year ago

1.0.41

1 year ago

1.0.40

1 year ago

1.0.39

1 year ago

1.0.38

1 year ago

1.0.37

1 year ago

1.0.36

1 year ago

1.0.35

1 year ago

1.0.34

1 year ago

1.0.33

1 year ago

1.0.32

1 year ago

1.0.31

1 year ago

1.0.30

1 year ago

1.0.29

1 year ago

1.0.28

1 year ago

1.0.27

1 year ago

1.0.26

1 year ago

1.0.25

1 year ago

1.0.24

1 year ago

1.0.23

1 year ago

1.0.22

1 year ago

1.0.21

1 year ago

1.0.20

1 year ago

1.0.19

1 year ago

1.0.18

1 year ago

1.0.17

1 year ago

1.0.16

1 year ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

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