6.8.68 • Published 4 months ago

@hishprorg/id-ab v6.8.68

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months 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');
inputES2018syntaxstructuredClonelinuxchromiumrequirepicomatchsequencemetadatauninstallclonehooksoutputregular-expressionArray.prototype.findLasteslintECMAScript 2018ecmascriptinterruptsfiltergradients css3callbindchineseless csstelephonemockingiamdropgestureslocationquerystringobjectasyncpushspawndragECMAScript 2017yamlsignedtypeerrorincludesfunctionrouteequalitycoercibleJSONreadperformantcss lessvariablesvestcolorscompareStreamparseES6deep-clonetakegroupBycloudtrailBigUint64ArrayES8polyfilleffect-tsloggerbrowserhigher-orderbanneriterationestreeentriesformsArray.prototype.includesUint32ArrayhasOwnYAMLconfigurablecertificatestypedarrayclassnameSymbol.toStringTagprototypeformWebSocketstrimEndObject.fromEntriesi18nfromassignes7timebyteLengthcreatebinaryprotobufpackage.jsonTypeScriptsymlinksmodulesInt16ArrayaccessorformatinspectArrayBuffer.prototype.slicees-shimsspeedregular expressioncommand-lineRegExp#flagsTypeBoxpredictableredirectgetjson-schema-validationReactiveExtensionssnsacornprivate datatc39sortvalidateenvironmentlogarktypeUint16ArraySymbolstylegitignoreflagstringifiernpmESdeep-copyECMAScript 5es20163dvaluesdom-testing-libraryString.prototype.matchAllxtermlistenersmergefindsuperstructirqlivexhrimmergetPrototypeOfArray.prototype.filterselfponyfilltostringtagString.prototype.trimzxcryptMicrosoftcolorignorecallfull-widthroutingcallbackgetintrinsicglobredactflatMapwidthfpsamazonmatchUint8ArrayassertschromedeleteslotargumentintrinsicObject.valuesObject.entriesenumerablevalidationless.jstslibconcatvarssettouchnested cssasterisksqsdynamodbpreserve-symlinksreactpureES2016statelesscss-in-jsArray.prototype.flatMaptslessnumberkeywaapifunction.lengthcensorsymlinkcodessymbolpyyamlreducerpropdescriptorsstyled-componentsfindLastIndexfast-deep-cloneBigInt64ArraymomentcolumngdprstatetoStringTagweakmappropertiesinstallerrgbtypesafedescriptorcloudwatchexpressionPushpropertytddtypesrequestemrsharednode[[Prototype]]$.extendimmutableapifastcopyfast-copylesscssparserURLwalkflatgetoptSetdependenciesajaxuploadglobal this valueES2019ESnextmanagerinternalnpmignoreeventseslintpluginstatuscharactergetOwnPropertyDescriptorboundECMAScript 2015execlazyflattenmkdirpbyteInt8Arraysetterreact-testing-librarymulti-packageiterateserviceebsflagsjoiec2toArrayqueueresolvejsonschemaownlanguagecolumnsArrayshamdeepclonesigtermeventDispatcherglobaleast-asian-widthspinnerses2018signalexecuteObservableselmfront-endroute53containsbinariesmatchAllcall-bindjslibphonenumberbabel-coreurlvariables in cssshebangenvglobalsECMAScriptcollection.es6curriedstableES2020traverselintespreearraysunicodepackage managerstylingstarterECMAScript 2022styleguidetrimLeftscheme-validationgraphqlpostcss-plugines-shim APIjson-schema-validatorbootstrap cssmapqueryserializerprocessglacierlastclienteslint-pluginsortedconcatMapisConcatSpreadabledayjspromisespecprotospringECMAScript 3fastclonefetchenvironmentsrandominvarianttyped arraycolourexitajvhandlersUint8ClampedArrayindicatorvisualObject.getPrototypeOfmrusuperagentObjectregexpECMAScript 2021offsetelectronargvmixinsstoragegatewayjapaneseoptimistrobustes-abstractsidehashramdaURLSearchParamssafe0ES3eventEmittereveryisbufferinstallreadableasciiwindowmobileES2023css variableerrorcircularreplayieArrayBuffer#sliceshrinkwrapcryptosliceproxyauthreadablestreamclass-validatorescape256getterbcrypteslintconfigRxJSsubprocessobjdomanimationWeakSetObject.definePropertynamesmake dirRFC-6455warningconfigreduxdiffreuse6to5httpclassescommandworkerObservableelasticacheaccessibilityerror-handlingcloudfronthotfigletconsumechairecursivewritableautoprefixerArray.prototype.flattenhelpersfastifyapollooptimizerCSSStyleDeclarationwhichsettingspinotypeposerapidprettynegative zerojson-schemastreamassertansiagentsesuser-streamsrangeerrorwindowsstreamsoptionjestauthenticationtypanionfunctionscorebusyObject.keysnameglobal objecttestera11ypatchartswfstylesbrowserlistECMAScript 7ES2021jsdomstringifycore-jsgenericshelperharmonysharedarraybufferschemecompile lessECMAScript 2023enderkeysbootstrap lessforEachyupprivatesimpledbefficientFloat64ArrayArray.prototype.findLastIndexbabelpathprogressexpressECMAScript 2020ECMAScript 2016fsescopyArrayBufferfpexit-codeAsyncIteratorutilhardlinkses2015siginttrimStartloadbalancingreducepruneprotocol-buffersl10nmonorepoRxWebSocketmodulees5collectionJSON-SchemabuffersbundlingtypeoffastES5jwtclassnamesReactiveXTypedArrayshimcall-boundweaksetregexpositivethreeschemadefinePropertyomitarraybufferbyteOffsetcloudformationjsonzerotacitpersistentback-endutilsdataviewlocalchanneltrimRightquotepasswordRegExp.prototype.flagspipeclitypescriptstringvaluevalidatormacoscssInt32Arrayutilitiespoint-freeruntimeoperating-systemnodejsform-validationbundlerdefinecallboundsameValueZeroterminalworkflowoncemkdirsignalsconstphoneloggingserverdependency managersetImmediatemockio-tswaitinferenceequaltestingES2022toolsserializationtranspilecurlnativeconsoleendpointpnpm9deterministicloading.envperformancewafworkspace:*ttyStyleSheetregular@@toStringTagfile system__proto__functionalawszodES2017nopereal-timeArray.prototype.flatassertiondeepcopybindkinesistypeddataViewbrowserslistObject.assignstylesheetdotenvtestreact-hook-formsyntaxerrortoolkitdeepfullwidthsymbolsutil.inspectless compilertermremovefixed-widthfantasy-landforkmovekoreandatastructureastshellpluginframerarraygrouputilitycomputed-typessqssomejshintIteratorcheckfluxObject.isPromisedirtypedarrays-0globalThisfast-cloneextraencryptionES2015s3datacss nestingimportexport
6.8.68

4 months ago

6.8.67

4 months ago

5.8.67

4 months ago

5.8.66

4 months ago

5.8.65

4 months ago

5.8.64

4 months ago

5.8.63

4 months ago

5.8.62

4 months ago

5.7.62

4 months ago

5.7.61

4 months ago

5.7.60

4 months ago

5.7.59

4 months ago

5.7.58

4 months ago

5.7.57

4 months ago

5.7.56

4 months ago

5.7.55

4 months ago

5.7.54

4 months ago

5.7.53

4 months ago

5.7.52

4 months ago

5.7.51

5 months ago

5.6.51

5 months ago

5.6.50

5 months ago

5.6.49

5 months ago

5.6.48

5 months ago

5.6.47

5 months ago

4.6.47

5 months ago

4.6.46

5 months ago

4.6.45

5 months ago

4.6.44

5 months ago

4.5.44

5 months ago

4.5.43

5 months ago

4.5.42

5 months ago

4.5.41

5 months ago

3.5.41

5 months ago

3.5.40

5 months ago

3.5.39

5 months ago

3.4.39

5 months ago

3.4.38

5 months ago

3.4.37

5 months ago

3.4.36

5 months ago

3.4.35

5 months ago

3.4.34

5 months ago

3.4.33

5 months ago

3.4.32

5 months ago

3.4.31

5 months ago

3.4.30

5 months ago

3.4.29

5 months ago

3.4.28

5 months ago

3.4.27

5 months ago

2.4.27

6 months ago

2.4.26

6 months ago

2.4.25

6 months ago

2.4.24

6 months ago

2.4.23

6 months ago

2.4.22

6 months ago

2.4.21

6 months ago

2.3.21

6 months ago

2.3.20

6 months ago

2.3.19

6 months ago

2.3.18

6 months ago

2.3.17

6 months ago

2.3.16

6 months ago

2.3.15

6 months ago

2.3.14

6 months ago

2.3.13

6 months ago

2.3.12

6 months ago

2.3.11

6 months ago

2.3.10

6 months ago

2.2.10

6 months ago

2.2.9

6 months ago

2.1.9

6 months ago

2.1.8

6 months ago

2.1.7

6 months ago

2.1.6

6 months ago

2.1.5

6 months ago

2.1.4

6 months ago

2.1.3

6 months ago

2.1.2

6 months ago

2.0.2

6 months ago

2.0.1

7 months ago

1.0.1

7 months ago

1.0.0

7 months ago