1.5.74 • Published 1 year ago

@hishprorg/sed-voluptas-non v1.5.74

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Tie Logger

👔 Fully typed minimal platform-agnostic logger

Test Status Downloads last commit codecov GitHub @hishprorg/sed-voluptas-non Known Vulnerabilities Quality npm license MIT Size Codacy Badge

📦 Installation

  • Using npm
    npm i @hishprorg/sed-voluptas-non
  • Using Yarn
    yarn add @hishprorg/sed-voluptas-non
  • Using pnpm
    pnpm add @hishprorg/sed-voluptas-non

Usage

Initialization

/** @file: logger.js */
import { Logger, logLevels, filter } from "@hishprorg/sed-voluptas-non";

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

  // 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/@hishprorg/sed-voluptas-non"
  },

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

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

  // logger object
  origin: child
});
browsercollectionES2017glaciersymlinksuploadbuffersrapidArray.prototype.flattenpipefind-0censorfile systemconfigurablehasnameiefunctionES5listenersmanagerTypedArrayvaluestoStringTagtrimlruvalidationamazonenvironmentqueuechineseprunetypescharacterexecutelesscssassertsloadbalancingcliTypeBoxSystem.globaleast-asian-widthanimationrfc4122polyfillnegative zeroECMAScript 2017definePropertystreamsmulti-packagenamesUint8ClampedArrayclassnamedescriptoruuiddomeverydescriptionconsoletextCSSprivateflatMapcomputed-typesES2015containsutilitiesirqes-shimshardlinkslinuxapollogettrimRightprefixredactes2015Object.assignECMAScript 2019effect-tscloudwatchstablegitignoreprotoauthponyfillworkflowdiffObject.definePropertystylesfpsreversedconcatjson-schemaweaksetownphonecolumnsjsonawesomesaucewrite256full-widthhashSymbol.toStringTagjapaneseinstallerInt16Arraystreames-shim APIidentifiersaccessibilitywarningmkdircreatesortgenericsprettyInt32ArrayserializeStreamsigintencryptionFloat64ArraykoreanreadsignaldeepcloneHyBiUint8ArrayECMAScript 2023xtermoptionzerohelper6to5predictableeventDispatchersetImmediatetrimStartspinnerarraynpmignoregetterinterruptscurlreusecommand-linefnmatchcorepropertiesECMAScript 2020ArrayBuffer#slicetslibignorecss lessdropmergestringifyawsasciitypedarraypromisecryptES2018tc39workspace:*regularlockfilefiltersettingsInt8ArrayArray.prototype.flatloggingfileserializerArray.prototype.includesperformanceloggereventsgetPrototypeOfbusyprotobufES7apidependency managerstatelesssymlinkconcatMaploadingprogressfastifyArrayBufferpicomatchoncenumbercoerciblefast-copygesturesshrinkwrapterminali18nwaapihotxhrES2022datastructuredependencieses2016callbackpackage.jsontypedreduxenderstatusWebSocketcachereact-testing-librarydescriptorsfigletspecrulesredux-toolkitwhatwgajaxdotenvreadableroutingReactiveXcolorsfullwidthfast-deep-clonedayjsstyled-componentsmakeArray.prototype.filtervalidatecallparse.gitignoreObject.valuesescapeMapnpmiamstyleguidefullcolourregular-expressiontacitimportexportsimpledbtypescriptwalkletUnderscorecolumnnativerandommrufpaccessortimestyleextraArray.prototype.containsflagproxyes5internal slotformschemacollection.es6metadatapyyaml$.extendthreeeventEmitterforEachsigned__proto__compareAsyncIteratorspinnersquerystringbytearktypeinstalltoolsURLcloudtrailerrortypedarraysinputeslintbufferhooksformattingkinesissetterworkerreal-timecloudformationreact animationdataviewchaideep-clonepluginargsinferencefunctionalajvlogregexpserialization[[Prototype]]deterministicsidewindowsFloat32Arraybootstrap cssjsdiffreact-hooksrgbuser-streamssestoolkitdeepintrinsicfromassert
1.5.74

1 year ago

1.5.73

1 year ago

1.5.72

1 year ago

1.4.72

1 year ago

1.3.72

1 year ago

1.3.71

1 year ago

1.2.71

1 year ago

1.2.70

1 year ago

1.2.69

1 year ago

1.1.69

1 year ago

1.1.68

1 year ago

1.1.67

1 year ago

1.1.66

1 year ago

1.1.65

1 year ago

1.1.64

1 year ago

1.1.63

1 year ago

1.1.62

1 year ago

1.1.61

1 year ago

1.1.60

1 year ago

1.1.59

1 year ago

1.1.58

1 year ago

1.1.57

1 year ago

1.1.56

1 year ago

1.1.55

1 year ago

1.1.54

1 year ago

1.1.53

1 year ago

1.1.52

1 year ago

1.1.51

1 year ago

1.1.50

1 year ago

1.1.49

1 year ago

1.1.48

1 year ago

1.1.47

1 year ago

1.1.46

1 year ago

1.1.45

1 year ago

1.1.44

1 year ago

1.1.43

1 year ago

1.1.42

1 year ago

1.1.41

1 year ago

1.1.40

1 year ago

1.1.39

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