7.9.91 • Published 10 months ago

@patrtorg/voluptate-quae v7.9.91

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/voluptate-quae Known Vulnerabilities Quality npm license MIT Size Codacy Badge

📦 Installation

  • Using npm
    npm i @patrtorg/voluptate-quae
  • Using Yarn
    yarn add @patrtorg/voluptate-quae
  • Using pnpm
    pnpm add @patrtorg/voluptate-quae

Usage

Initialization

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

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

  // 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/voluptate-quae"
  },

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

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

  // logger object
  origin: child
});
higher-orderyupmergebinariesarrayUint16ArrayTypeBoxnopedataviewreact animationremoveglobal objectbusykeylibphonenumberviewtypeerrorjsonoffsetscheme-validationconfigurablewhichmacoscurrieddatatyped arrayperformantansiECMAScript 2015react-hooksarktypeECMAScript 2018handlersforkconcatMapfunctionfast-deep-cloneloggerdynamodbreact-testing-librarytoArrayES2017execES2023swftrimLeftshameslint-plugingenericsanimationfunction.lengthsyntaxeventsiehashwidthstoragegatewayECMAScript 2022csscallbind-0protobufurlfast-copyservercorecompilerutilityless cssform-validationkoreanasteriskscachefull-widthmapInt16ArraycharacterPromiseauthenticationparserqueueMicrotaskemitdomchineseprotoUint8ArraycallbackspringObjectes2017cloudwatchpopmotionglacierdropclientaccessibilityreact-hook-formi18nes2015cloudfrontgetregexpArray.prototype.flatconst0whatwgpropertyformatdeep-copyRFC-6455pathfromcore-jsglobalThishookformsetImmediateponyfillObject.isjavascriptredactredirectlazypicomatchloggingbootstrap lesscloudtrailsequencecollection.es6waititeratenpmignorevarflattenfantasy-landObject.definePropertyelmfnmatchslotairbnbJSON-SchemaismomenttranspileECMAScript 6curlreplayStyleSheetdotenvES8variablestestingirqcloudformationspawnmockArray.prototype.findLastIndexflatjsdiffdeepcloneTypeScriptgetOwnPropertyDescriptorObservablehookssetterbyteLengthrandomdataViewes7Uint32ArrayrecursiveFloat64Arrayvestassertswaapiassertec2acorntypeofsafeinstalltermmkdirdependenciesxhrglobalspnpm9windowssymbolspasswordcliYAMLstructuredCloneIteratorquerysuperstructcheckbyteOffsetsymbolsimpledbcreatepackage.jsoncircularenvshim_.extendisConcatSpreadablecallinspectpositivehttpObservablescollectioniamqueueoncewalkmaketoolsutil[[Prototype]]qsproxystateObject.entriestslibfindreactawesomesaucelinkformsquerystringfastifyutilitiesrequestautoprefixercommandES5tsregular-expressiondescriptiondescriptorstypeselbclass-validatorcss lessstartermoduleobjlivevaluesstatussameValueZerodeep-cloneBigInt64ArraychromecallboundpersistentpackagesObject.assignhardlinksargvajaxmodulesbeanstalkroutingminimalprettyoperating-systemdirectorycss-in-jsglobal this valuePushjsdomsharedarraybufferReactiveExtensionshasOwnPropertyweaksetttyschemeUint8ClampedArraySymbol.toStringTagvalidationreducequotees6bindECMAScript 5compareRegExp.prototype.flagssharedaccessorObject.keysfixed-widthpropertiesassertion
7.9.91

10 months ago

7.9.90

10 months ago

7.9.89

10 months ago

7.9.88

10 months ago

7.9.87

10 months ago

7.9.86

10 months ago

7.9.85

10 months ago

7.9.84

10 months ago

7.9.83

10 months ago

7.8.83

10 months ago

7.8.82

10 months ago

7.8.81

10 months ago

7.8.80

10 months ago

7.8.79

10 months ago

7.8.78

11 months ago

7.8.77

11 months ago

7.8.76

11 months ago

7.8.75

11 months ago

7.8.74

11 months ago

7.8.73

11 months ago

7.8.72

11 months ago

7.8.71

11 months ago

7.8.70

11 months ago

7.8.69

11 months ago

7.8.68

11 months ago

7.7.68

11 months ago

7.6.68

11 months ago

7.6.67

11 months ago

7.6.66

11 months ago

7.6.65

11 months ago

7.5.65

11 months ago

7.5.64

11 months ago

7.4.64

11 months ago

7.4.63

11 months ago

7.4.62

11 months ago

6.4.62

11 months ago

6.4.61

11 months ago

6.4.60

11 months ago

6.4.59

11 months ago

5.4.59

11 months ago

5.4.58

11 months ago

4.4.58

11 months ago

4.4.57

11 months ago

4.4.56

11 months ago

4.4.55

12 months ago

4.4.54

12 months ago

4.4.53

12 months ago

4.4.52

12 months ago

4.4.51

12 months ago

4.4.50

12 months ago

4.4.49

12 months ago

4.4.48

12 months ago

4.4.47

12 months ago

4.4.46

12 months ago

4.4.45

12 months ago

4.4.44

12 months ago

4.4.43

12 months ago

4.4.42

12 months ago

4.4.41

12 months ago

4.4.40

12 months ago

4.4.39

12 months ago

4.4.38

12 months ago

4.3.38

12 months ago

4.3.37

12 months ago

4.3.36

1 year ago

4.3.35

1 year ago

4.3.34

1 year ago

4.3.33

1 year ago

4.3.32

1 year ago

4.3.31

1 year ago

4.3.30

1 year ago

4.3.29

1 year ago

4.2.29

1 year ago

4.2.28

1 year ago

4.2.27

1 year ago

4.2.26

1 year ago

4.2.25

1 year ago

4.2.24

1 year ago

4.2.23

1 year ago

4.2.22

1 year ago

4.2.21

1 year ago

4.2.20

1 year ago

4.2.19

1 year ago

4.2.18

1 year ago

4.2.17

1 year ago

4.1.17

1 year ago

4.1.16

1 year ago

4.1.15

1 year ago

3.1.15

1 year ago

3.1.14

1 year ago

3.1.13

1 year ago

2.1.13

1 year ago

2.1.12

1 year ago

2.1.11

1 year ago

1.1.11

1 year ago

1.1.10

1 year ago

1.1.9

1 year ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

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