5.4.55 • Published 1 year ago

@dramaorg/expedita-quo v5.4.55

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

fran-logging

Fran logger is a simple logging with an easy configuration. Supports level based filtering and tagging that keeps your logs readable and uncluttered!

Simple Features

  • Small footprint, around 500 bytes
  • Filter by level, ERROR > WARN > INFO > TRACE > DEBUG
  • Filter by tag, 'security' | 'anything'

Install

npm install fran-logging

Initialize

Tags typically refer to a subsystem or component like 'security' or FooBar.name. When fran-logging is initialized, tags can be assigned a level. A message is logged when its level is greater than or equal to its tag's assigned level.

import { log, LogLevel } from 'fran-logging';
import chalk from 'chalk';

// handler which does the logging to the console or anything
const logger = {
  [LogLevel.ERROR]: (tag, msg, params) => console.error(`[${chalk.red(tag)}]`, msg, ...params),
  [LogLevel.WARN]: (tag, msg, params) => console.warn(`[${chalk.yellow(tag)}]`, msg, ...params),
  [LogLevel.INFO]: (tag, msg, params) => console.log(`[${chalk.brightGreen(tag)}]`, msg, ...params),
  [LogLevel.TRACE]: (tag, msg, params) => console.log(`[${chalk.cyan(tag)}]`, msg, ...params),
  [LogLevel.DEBUG]: (tag, msg, params) => console.log(`[${chalk.magenta(tag)}]`, msg, ...params),
} as Record<LogLevel, (tag: string, msg: unknown, params: unknown[]) => void>;

/**
 * initialize fran-logging
 * @param config JSON which assigns tags levels. An uninitialized,
 *    tag's level defaults to DEBUG.
 * @param callback? handle logging whichever way works best for you
 */
log.init({ transporter: 'INFO', security: 'ERROR', system: 'OFF' }, (level, tag, msg, params) => {
  logger[level as keyof typeof logger](tag, msg, params);
});

Usage

import { log, tag } from 'fran-logging';

// the imported value "tag" is populated with YOUR tags!
log.error(tag.security, 'not authorized', statusCode);

// but if you prefer simply use strings
log.warn('transporter', 'Evil twin detected!');

// filtered since security's log level ERROR is greater than INFO
log.info(tag.security, 'login successful');

// trace
log.trace(tag.system, 'entering engine room');

// debug
log.debug(tag.system, { warpFactor, starDate });

// also filtered since system's level is OFF
log.error(tag.system, 'eject the warp core', error);

// updates tag levels on the fly
log.init({ loader: 'ERROR', system: 'INFO' });

// disable logging by clearing the callback
log.init();

Advanced Usage

Create an instance with its own tags and callback.

import { Log, tag } from 'fran-logging';

const myLog = new Log().init(
  { loader: 'INFO', security: 'ERROR' },
  (level, tag, msg, params) => {
    console.log(`${level}: [${tag}] `, msg, ...params);
});

myLog.info(tag.security, 'login successful');
logtslibidletrimtypedWeakMappinonamesxmlapitransformRFC-6455requiretouchcolorglobalThislinkcolumnsReactiveExtensions-0parentsregular expressionchannelsuperstructFunction.prototype.namegetterredux-toolkitwaapiprotocol-bufferswaitstoragegatewayPushES3specieemrtoolkitfunctionsWebSocketsrgbES2023modulestrimRightPromiseObject.isReflect.getPrototypeOftimesomeObservableansiastObject.definePropertypnpm9reducerlibphonenumberes6es2017regular expressionsfindLastbuffer.gitignoreloggerUint8ArrayvariablesharmonyexecvalidationfastcopyAsyncIteratorFloat32ArrayerrorECMAScript 2017varoutputreadablestreamhttpsjasminemodulemanagerframerwalkconsoleECMAScript 2022commandergesturesquerystringES6WebSockettypeerrornpmignoreString.prototype.matchAlljson-schema-validationgetPrototypeOfJSONshrinkwrapiamspeedbundlingsymbolstyled-componentsshamgenericsECMAScript 5regularhardlinkspostcssjestrfc4122xtermconcatstylesdeepclonejavascriptinstrumentationflattenflatcloudfrontpoint-freeposespringfunction.lengthestreerouteUint8ClampedArraybabelasteriskscolumnWeakSetECMAScriptphoneexpressiondirlockfiledebugprotobufautoscalingreact animationmovereuseinstallerObject.valuesqueueMicrotaskconsumeeslintwarningdescriptorsetimmerUint16ArraycallbackemitfpsinatraenvironmentcircularprettyObjectclientsyntaxECMAScript 2023SymbolgroupstringifyquerybundlerslottypedarraysthreeglobmaketypescripteventEmitterbyteOffsetperformancejQueryi18nfetchRxcoerciblemapreduceimportcallboundarrayscss-in-jsprefixiteratorpositivedom-testing-librarybindreduxmatchkeysextendfunctionnamereadcollectionfindupespreeatomflagstoobjectStreamswgetnegative zeroobjectroutingl10nrapidclassesArrayponyfillaccessibilityfile systemmochabeanstalkglobal objectloadingmonorepoweaksetES2019artformsawesomesaucerangeerrorrm256hasOwnPropertyform-validationpureinputtoStringTagforEachjsxrouterebsformattingeast-asian-widthcontainshasOwnyamlspawnreversedwalkingsqssettingstermkinesisprivateObject.keysReactiveXsortclisetPrototypeOfassignidentifierschinesetrimLeftUnderscoreguidtestingelbapputil.inspectownfpsasciigetOwnPropertyDescriptornegativeproppolyfillfastifyBigInt64ArraydefinePropertyfullwidthqsrdstransportdragtypaniondotenvObject.assigntc39ECMAScript 2015ESnexta11yletbuffersES2017dynamodbprotoprivate datadomdataviewObject.fromEntrieswafgetistanbuldescriptionpopmotionflagfindLastIndexmatchAllajaxdeep-copyes8starterArray.prototype.flatcharacteranimationoptimistrmdirgitignorejsdifffolderSystem.globalargument0subprocessparsepackagesfspatchsource mapredactpackage managermatcheskoreanenumerablefull-width.envintrinsicramdaruntimefigletjoibyteLengthagentfullenvironmentsES5robustfunctionalcode pointsqueue[[Prototype]]writecloudformationsymbolsautoprefixerhigher-orderunicodedependenciestddSymbol.toStringTagomitTypeScriptclassnamessortedeslint-pluginreact-hook-formcachemergetyped arraytextECMAScript 3ECMAScript 2018multi-packagestyleguidegdpres2016ecmascriptwritableflatMapglobalsECMAScript 2019prototypearraybinarieshasuser-streamsserializationprocesseffect-tsurlconstmomentfilterassertionbabel-corepushpyyamllanguageindicatordirectorymapsnsbusytesterpipeURLexpressnopemetadatajsserializereact-hooksregexzeroObject.entriesrulesbinaryMapslicesuperagentresolvefast-copyworkflowfast-cloneschemaArrayBuffer#sliceignorexhrinspectloadbalancingforkvestcloudwatchsharedwhatwgassertObservablesStyleSheetmkdirsreducecssterminalRegExp.prototype.flagsroute53ES2015Array.prototype.includeslocalstructuredCloneCSSproxyIteratorscheme-validationURLSearchParamsjshintrestdeep-cloneYAMLargsECMAScript 2016fastcloneMicrosoftinternal slotuuidregular-expressionrandomrm -rfECMAScript 2021schemeperformantstringdatamanipulationfixed-widthlocationArrayBufferstreamequalitycodescharactersfast-deep-clonepruneArray.prototype.findLastincludeskeybrowserlistjapanesees-shim APIHyBiparserredirectRxJSselftoSortedchromiumglobal this valuetelephonecall-bindframeworkcore-js__proto__equalquoteECMAScript 2020uninstallimportexportio-tscompiler6to5propertysyntaxerroreventsbannerzoddescriptorssymlinksArray.prototype.containstoolsairbnbconfigargvtypesafeprogressawsES2016fastfromES7Array.prototype.flatMapmruhashtypedarrayclass-validatorupshimworkspace:*ec2Array.prototype.flattenArray.prototype.filterdateapollocolorscolourweakmaphtmlelectronutilitycjkgraphqltestrecursivetrimEndpromiseenderStreamdeepcopynativesimpledbconfigurablejsonschemawebclassnamepackage.jsonavapropertiesexecutetakerssparentnpmcommandBigUint64Arraytaciteses-abstractoptimizersesdeeps3sideelasticachecollection.es6ECMAScript 7sharedarraybufferreact posehas-ownoffsetlistenerseslintconfigstyledependency managerwindowutilsutilitieswhichchecktapeCSSStyleDeclarationRegExp#flagsInt32ArrayspinnerentriesregexpdayjsiterateisConcatSpreadablebrowserslistconcatMapnodevaluecloudsearchttyvalidcreateobjclonedeterministichooksfnmatchnodejsformtypeajvwidthes5extrasetImmediatehelperarktypeeslintplugindefinecurldebuggerlasttoArraylruSetmobilecommand-linecallbindFloat64Arrayplugingetoptreal-timeremoveendpointbddfantasy-landmake dirchromeinfilebines2018swfspinnersrequestglacieroncechildcloudtrailoptioncoveragevpccomputed-typesfind-upassertscall-boundcrypto$.extendworkerlintES2022chaishebangidinternalpackagees-shimspathviewbrowserhookformemojitranspilercensorvaluesObject.getPrototypeOfjson-schemaimmutabletraversepostcss-pluginacorngetintrinsichttpefficientreworksettermkdir_.extendenvjsonlogginglookcurriedlengthfast-deep-copyreverseinstallInt16ArraycorestylingstreamstoReversedfindminimalvarsECMAScript 6ES2018TypedArrayeveryvalidatejsdomES2020arraybufferrm -frArray.prototype.findLastIndexformatvisualeventDispatcherpicomatchArrayBuffer.prototype.slicesearchtostringtagtsdataViewinferencecopy
5.4.55

1 year ago

5.4.54

1 year ago

5.4.53

1 year ago

5.4.52

1 year ago

5.4.51

1 year ago

5.4.50

1 year ago

5.4.49

1 year ago

5.4.48

1 year ago

5.4.47

1 year ago

5.4.46

1 year ago

5.3.46

1 year ago

4.3.46

1 year ago

4.3.45

1 year ago

4.3.44

1 year ago

4.3.43

1 year ago

4.3.42

1 year ago

4.3.41

1 year ago

4.3.40

1 year ago

4.3.39

1 year ago

4.3.38

1 year ago

4.3.37

1 year ago

3.3.37

1 year ago

3.3.36

1 year ago

3.3.35

1 year ago

3.3.34

1 year ago

2.3.34

1 year ago

2.2.34

1 year ago

2.2.33

1 year ago

2.2.32

1 year ago

2.2.31

1 year ago

2.2.30

1 year ago

2.2.29

1 year ago

2.2.28

1 year ago

2.2.27

1 year ago

2.2.26

1 year ago

2.2.25

1 year ago

2.2.24

1 year ago

2.2.23

1 year ago

2.2.22

1 year ago

2.2.21

1 year ago

2.2.20

1 year ago

2.2.19

1 year ago

2.2.18

1 year ago

2.2.17

1 year ago

2.2.16

1 year ago

1.2.16

1 year ago

1.2.15

1 year ago

1.2.14

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

1 year ago

1.2.8

1 year ago

1.2.7

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

1 year ago

1.1.1

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago