6.8.68 • Published 8 months ago

@hishprorg/id-ab v6.8.68

Weekly downloads
-
License
MIT
Repository
github
Last release
8 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

8 months ago

6.8.67

8 months ago

5.8.67

8 months ago

5.8.66

8 months ago

5.8.65

8 months ago

5.8.64

8 months ago

5.8.63

8 months ago

5.8.62

8 months ago

5.7.62

8 months ago

5.7.61

8 months ago

5.7.60

8 months ago

5.7.59

8 months ago

5.7.58

9 months ago

5.7.57

9 months ago

5.7.56

9 months ago

5.7.55

9 months ago

5.7.54

9 months ago

5.7.53

9 months ago

5.7.52

9 months ago

5.7.51

9 months ago

5.6.51

9 months ago

5.6.50

9 months ago

5.6.49

9 months ago

5.6.48

9 months ago

5.6.47

9 months ago

4.6.47

9 months ago

4.6.46

9 months ago

4.6.45

9 months ago

4.6.44

9 months ago

4.5.44

9 months ago

4.5.43

9 months ago

4.5.42

9 months ago

4.5.41

9 months ago

3.5.41

9 months ago

3.5.40

9 months ago

3.5.39

9 months ago

3.4.39

9 months ago

3.4.38

9 months ago

3.4.37

9 months ago

3.4.36

9 months ago

3.4.35

9 months ago

3.4.34

9 months ago

3.4.33

10 months ago

3.4.32

10 months ago

3.4.31

10 months ago

3.4.30

10 months ago

3.4.29

10 months ago

3.4.28

10 months ago

3.4.27

10 months ago

2.4.27

10 months ago

2.4.26

10 months ago

2.4.25

10 months ago

2.4.24

10 months ago

2.4.23

10 months ago

2.4.22

10 months ago

2.4.21

10 months ago

2.3.21

10 months ago

2.3.20

10 months ago

2.3.19

10 months ago

2.3.18

10 months ago

2.3.17

10 months ago

2.3.16

10 months ago

2.3.15

10 months ago

2.3.14

10 months ago

2.3.13

10 months ago

2.3.12

10 months ago

2.3.11

10 months ago

2.3.10

10 months ago

2.2.10

10 months ago

2.2.9

10 months ago

2.1.9

10 months ago

2.1.8

10 months ago

2.1.7

11 months ago

2.1.6

11 months ago

2.1.5

11 months ago

2.1.4

11 months ago

2.1.3

11 months ago

2.1.2

11 months ago

2.0.2

11 months ago

2.0.1

11 months ago

1.0.1

11 months ago

1.0.0

11 months ago