5.6.100 • Published 10 months ago

@kollorg/aspernatur-error v5.6.100

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

Logtopus

Build Status

Logtopus is a powerful logger for Node.js with different transports

Logtopus Logger

Built in logger:

Additional logger:

Usage

const log = require('@kollorg/aspernatur-error').getLogger('mylogger');
log.setLevel('sys');

log.warn('My beer is nearly finish!');

Log levels

debug    development  Logs debugging informations
info     development  Helpful during development
res      staging      Logs requests
req      staging      Logs responses
sys      production   Logs application states
warn     production   Logs warnings
error    production   Logs errors

For example, setting log level to req includes these log levels: req, sys, warn, error Setting log level to debug means all log levels are activated log level error logs errors only.

Example:

log.setLevel('res');        // To be ignored in this log level
log.debug('Log example:');  // To be ignored in this log level
log.info('This would not be logged');
log.res('POST /account');
log.req('200 OK');
log.sys('Request done!');
log.warn('Request was unauthorized!');
log.error('An error has been occurred!');

// prints

res: POST /account
req: 200 OK
sys: Request done!
warn: Request was unauthorized!
error: An error has been occurred!

Express logger

Logtopus comes with a logger for Express/Connect.

@kollorg/aspernatur-error.express() returns a middleware for Express/Connect. It acepts an optional options object

let express = require('express');
let @kollorg/aspernatur-error = require('../@kollorg/aspernatur-error');

let app = express();

app.use(@kollorg/aspernatur-error.express({
  logLevel: 'debug'
}));

Options

logLevel Sets current log level

Koa logger

Logtopus also supports Koa

@kollorg/aspernatur-error.koa() returns a middleware for Koa. It acepts an optional options object

let koa = require('koa');
let @kollorg/aspernatur-error = require('../@kollorg/aspernatur-error');

let app = koa();

app.use(@kollorg/aspernatur-error.koa({
  logLevel: 'debug'
}));

Options

logLevel Sets current log level

Adding custom loggers

Logtopus was designed as an extensible logger. You can add a custom logger by creating a logger class and load it into @kollorg/aspernatur-error. The example below shows a minimal logger class.

class LogtopusLogger {
  constructor(conf) {
    // conf contains the logger conf
  }

  log(logmsg) {
    const date = logmsg.time.toISOString()
    console.log(`[${date}] ${logmsg.msg}`)
  }
}

module.exports = LogtopusLogger

The logger class requires a log method. It takes one argument which contains a log object. The first argument of a log call is the log message, all other arguments are log data.

logmsg: {
  type: 'info', // The logtype eg: debug, info, error, sys
  msg: 'Log message string', // Log message, but without CLI color codes
  cmsg: 'Colorized log message', // Log message with CLI color codes
  time: new Date(), // Current date
  uptime: process.uptime(), // Process uptime in ms
  data: [] // All other arguments as an array
}

Now, the class has to be load into @kollorg/aspernatur-error. You can do it by using the .addLogger() method if your logger is a priveate logger. Otherwis publish it on npm by using our logger name conventions. @kollorg/aspernatur-error-${loggername}-logger Add a new config block into the @kollorg/aspernatur-error config by using loggername as namespace and @kollorg/aspernatur-error tries to load the logger.

const log = @kollorg/aspernatur-error.getLogger('mylogger')
log.addLogger('loggerName', loggerClass)
PushRxredux-toolkitcircularcommanddataviewenvESlinkpicomatchschemadeep-clonemkdirsspawnutil.inspecttapevalidationdeterministiccolourasterisksFunction.prototype.namestringifierconsumeawsES2017keyswritablestreamsargvminimals3callargumentObject.valuesrm -rfarraybufferperformancemergesinatracloudtraildotenvObject.getPrototypeOfkarmasortflatSymbol.toStringTagstyleflagshttprmtypesafecallbounddomes-shimsES2023filtercloudformationextra@@toStringTagshebangreduxstructuredCloneRFC-6455ES6colorformelasticachecss-in-jsreact animationutilmetadatavalueArray.prototype.containsreadablequeueMicrotaskcore-jssettereventsObjectapollotoolsframeworkspeedkey valueshimcallbindsetImmediatees2015sharedarraybufferUint8Arrayprettyfunction.lengthregular-expressionpropertiesfindhelperformattingphonedatacompareintrinsicinstallerFloat64ArrayiamcurriedtouchclassesserializationES2022tdderrorisConcatSpreadablequeryzeronopejasminetaponcepackage managerwgetwalkingfoldercssreversedscheme-validationpipetostringtagnativeWebSocketformsbrowserslisttranspilerflagfind-upslicemockingeventEmittersqswebArray.prototype.flatasyncpropertyclientcolumnes2016Array.prototype.filterservermovestreamECMAScript 2019a11yutilsapptestingReflect.getPrototypeOfrssproxyrandommake diriteratorsortedwafcryptoquerystringfeed256searchfindupdependency managersource mapcorereact-testing-librarylogginges2017upefficientdrag.gitignoreStyleSheeteslintplugindefinePropertyArrayBuffer.prototype.slicelasttakeenvironmenteslintposegenericsworkflowArray.prototype.flattenentriesfetchautoscalingqueuemobileclassnamesES5immerObject.isWeakSetreuseES2018estreeweakmapinvarianttsInt8Arrayanimationoptionimmutabledeepesastparentfast-deep-copyrm -frassertssafeyamlcall-boundfast-clonereacttypesbabelURLomitslotUint8ClampedArraycharactersparsermomentWebSocketswritejsdomcreatesubprocesstypanionTypeBoxReactiveExtensionsapiquotejson cacheflattendatetoSortedmockES7testerdependenciesstyleguideuuidECMAScript 2023regexoptimizerObject.definePropertystringautoprefixerworkerbinariesredirectfindLastArrayBuffer#slicesymbolTypeScriptStreamsArray.prototype.findLastfsrgbwhatwgprivate dataswfemitatomreworkpuredeepcopygdpres2018htmlobjfunctioninternal slotwaitpathoptimistinstrumentationcoerciblepackage.jsonchaispecECMAScript 2017varstypedECMAScript 2022BigUint64Arraytrimprotocol-buffers6to5shamjoiMapconstprogressweaksetinternalglacierdom-testing-librarygettergesturesec2dayjsserializeSymbolagentassertinwaapicall-bindgraphqlspinnerES2016beanstalkkoreanimporttextMicrosoftassertionttydynamodbgroupByhasOwnPropertychildbusyreades7hardlinksconfigurablefunctionalchannelxhrObject.keysWeakMapESnextsomeassignqssuperagentjestsymlinkspostcss-pluginbindbundlerpopmotiontyped arraySetdescriptionreadablestreamregular expressionown[[Prototype]]byte__proto__deep-copyfpsairbnbobjectemrlistenersloadingcheckfullwidthcallbackidlereduceECMAScript 2021javascriptexpressglobalsprotolibphonenumberTypedArraypnpm9Int32Arrayenumerablematchesnametelephonecolorseffect-tsstoragegatewaytrimRightdeletefront-endbuffersstringifyfile cachesnstraverseequaljsdifftypeerror3dfull-widthObject.entrieshandlersesartextendhooksexecmruconfiginspectstylesidescapePromiseES2019nodejspoint-freebinaryRegExp#flagsES8fastcopymapsetfunctionsspinnersendpointeslintconfigUint32ArrayprivatedescriptorssideserializerharmonyforEachhigher-orderObservableaccessorECMAScript 3getoptpushform-validationlockfileES2020resolvehasObservablesloggeturlfantasy-landpatchchromees6byteOffsetyupacornroutelocationrfc4122promisefastifyconsoleECMAScript 5emojitrimLeftelectronmochakey parArray.prototype.includesECMAScript 7valuesjQuerycensorvalidatefast-deep-clonelengthArray.prototype.findLastIndexsimple cacheansijsInt16ArrayconcatperformantmkdirpfastHyBiFloat32Arraynodebrowserdirectoryjapaneseoffsetjshintasciiwhich-0user-streamspinodescriptoreast-asian-widthfnmatchcacheramdahashendercompilerstylingpreprocessorbannerinputarktypesyntaxvpcebsfixed-widthAsyncIteratormatchservicepackagecollectionglobalponyfillignorecolumnsajaxbinfullmulti-packagejsxtransporthookformtoobjectES3collection.es6awesomesaucefindLastIndexdataViewsyntaxerrorString.prototype.trimES2021httpsconcatMaptypedarrayspackageselbtransformcopyJSON-SchemaexecuterequireforkECMAScript 6polyfillformatmanagercommanderaccessibilityCSSStyleDeclarationexpressionl10neslint-pluginYAMLvariablestypescriptcloudwatchrapidfast-copyinstallmakegitignorees-abstractglobespreeprocessdebuggerreal-timecode pointscontainsrestmatchAllzxtypedarrayoutputmkdirnpmignoreequalityincludesroute53cjkECMAScript 2016trimStartistanbulreducerbddcloudfront
5.6.100

10 months ago

5.6.99

10 months ago

5.6.98

10 months ago

5.5.98

10 months ago

5.5.97

10 months ago

5.5.95

11 months ago

5.5.96

11 months ago

5.5.94

11 months ago

5.5.93

11 months ago

5.5.92

11 months ago

4.5.92

11 months ago

4.5.91

11 months ago

4.5.90

11 months ago

4.5.89

11 months ago

4.5.88

11 months ago

4.5.87

11 months ago

4.5.86

11 months ago

4.5.85

11 months ago

4.5.84

11 months ago

4.5.83

11 months ago

4.5.82

11 months ago

4.5.81

11 months ago

4.5.80

11 months ago

4.5.79

11 months ago

4.5.78

11 months ago

4.5.77

11 months ago

4.5.76

11 months ago

4.5.75

11 months ago

4.5.74

11 months ago

4.5.73

11 months ago

4.5.72

11 months ago

4.5.71

11 months ago

4.5.70

11 months ago

3.5.70

11 months ago

3.5.69

11 months ago

3.5.68

12 months ago

3.5.67

12 months ago

3.5.66

12 months ago

3.5.65

12 months ago

3.5.64

12 months ago

3.5.63

12 months ago

3.5.62

12 months ago

3.5.61

12 months ago

3.5.60

12 months ago

3.5.59

12 months ago

3.5.58

12 months ago

3.4.58

12 months ago

3.4.57

12 months ago

3.4.56

12 months ago

3.4.55

12 months ago

3.4.54

12 months ago

3.4.53

12 months ago

2.4.53

12 months ago

2.4.52

12 months ago

2.4.51

12 months ago

2.4.50

1 year ago

2.4.49

1 year ago

2.4.48

1 year ago

2.4.47

1 year ago

2.4.46

1 year ago

2.4.45

1 year ago

2.4.44

1 year ago

2.4.43

1 year ago

2.4.42

1 year ago

2.3.42

1 year ago

2.3.41

1 year ago

2.3.40

1 year ago

2.3.39

1 year ago

2.3.38

1 year ago

2.3.37

1 year ago

2.3.36

1 year ago

2.3.35

1 year ago

2.3.34

1 year ago

2.3.33

1 year ago

2.3.32

1 year ago

2.3.31

1 year ago

2.3.30

1 year ago

2.3.29

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

1 year ago

2.3.17

1 year ago

2.3.16

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

1.2.13

1 year ago

1.2.12

1 year ago

1.2.11

1 year ago

1.2.10

1 year ago

1.1.10

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