2.4.106 • Published 2 years ago

@diotoborg/inventore-beatae v2.4.106

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years 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

2 years ago

2.4.105

2 years ago

2.4.104

2 years ago

2.4.103

2 years ago

2.4.102

2 years ago

2.4.101

2 years ago

2.4.100

2 years ago

2.4.99

2 years ago

2.4.98

2 years ago

2.4.97

2 years ago

2.4.96

2 years ago

2.3.96

2 years ago

2.3.95

2 years ago

2.3.94

2 years ago

2.3.93

2 years ago

2.3.92

2 years ago

2.3.91

2 years ago

2.3.90

2 years ago

2.3.89

2 years ago

2.3.88

2 years ago

2.3.87

2 years ago

2.3.86

2 years ago

2.3.85

2 years ago

2.3.84

2 years ago

2.3.83

2 years ago

2.3.82

2 years ago

2.3.81

2 years ago

2.3.80

2 years ago

2.3.79

2 years ago

2.3.78

2 years ago

2.3.77

2 years ago

2.3.76

2 years ago

2.3.75

2 years ago

2.3.74

2 years ago

2.3.73

2 years ago

2.2.73

2 years ago

2.2.72

2 years ago

2.2.71

2 years ago

2.2.70

2 years ago

2.2.69

2 years ago

2.2.68

2 years ago

2.2.67

2 years ago

2.2.66

2 years ago

2.2.65

2 years ago

2.2.64

2 years ago

2.2.63

2 years ago

2.2.62

2 years ago

2.2.61

2 years ago

2.2.60

2 years ago

2.2.59

2 years ago

2.2.58

2 years ago

2.2.57

2 years ago

2.1.57

2 years ago

2.1.56

2 years ago

2.0.56

2 years ago

2.0.55

2 years ago

2.0.54

2 years ago

2.0.53

2 years ago

2.0.52

2 years ago

2.0.51

2 years ago

2.0.50

2 years ago

2.0.49

2 years ago

1.0.49

2 years ago

1.0.48

2 years ago

1.0.47

2 years ago

1.0.46

2 years ago

1.0.45

2 years ago

1.0.44

2 years ago

1.0.43

2 years ago

1.0.42

2 years ago

1.0.41

2 years ago

1.0.40

2 years ago

1.0.39

2 years ago

1.0.38

2 years ago

1.0.37

2 years ago

1.0.36

2 years ago

1.0.35

2 years ago

1.0.34

2 years ago

1.0.33

2 years ago

1.0.32

2 years ago

1.0.31

2 years ago

1.0.30

2 years ago

1.0.29

2 years ago

1.0.28

2 years ago

1.0.27

2 years ago

1.0.26

2 years ago

1.0.25

2 years ago

1.0.24

2 years ago

1.0.23

2 years ago

1.0.22

2 years ago

1.0.21

2 years ago

1.0.20

2 years ago

1.0.19

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago