6.8.68 • Published 5 months ago

@hishprorg/id-ab v6.8.68

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

5 months ago

6.8.67

5 months ago

5.8.67

5 months ago

5.8.66

5 months ago

5.8.65

5 months ago

5.8.64

5 months ago

5.8.63

5 months ago

5.8.62

5 months ago

5.7.62

5 months ago

5.7.61

5 months ago

5.7.60

5 months ago

5.7.59

5 months ago

5.7.58

5 months ago

5.7.57

5 months ago

5.7.56

5 months ago

5.7.55

5 months ago

5.7.54

5 months ago

5.7.53

5 months ago

5.7.52

6 months ago

5.7.51

6 months ago

5.6.51

6 months ago

5.6.50

6 months ago

5.6.49

6 months ago

5.6.48

6 months ago

5.6.47

6 months ago

4.6.47

6 months ago

4.6.46

6 months ago

4.6.45

6 months ago

4.6.44

6 months ago

4.5.44

6 months ago

4.5.43

6 months ago

4.5.42

6 months ago

4.5.41

6 months ago

3.5.41

6 months ago

3.5.40

6 months ago

3.5.39

6 months ago

3.4.39

6 months ago

3.4.38

6 months ago

3.4.37

6 months ago

3.4.36

6 months ago

3.4.35

6 months ago

3.4.34

6 months ago

3.4.33

6 months ago

3.4.32

6 months ago

3.4.31

6 months ago

3.4.30

6 months ago

3.4.29

6 months ago

3.4.28

6 months ago

3.4.27

7 months ago

2.4.27

7 months ago

2.4.26

7 months ago

2.4.25

7 months ago

2.4.24

7 months ago

2.4.23

7 months ago

2.4.22

7 months ago

2.4.21

7 months ago

2.3.21

7 months ago

2.3.20

7 months ago

2.3.19

7 months ago

2.3.18

7 months ago

2.3.17

7 months ago

2.3.16

7 months ago

2.3.15

7 months ago

2.3.14

7 months ago

2.3.13

7 months ago

2.3.12

7 months ago

2.3.11

7 months ago

2.3.10

7 months ago

2.2.10

7 months ago

2.2.9

7 months ago

2.1.9

7 months ago

2.1.8

7 months ago

2.1.7

7 months ago

2.1.6

7 months ago

2.1.5

7 months ago

2.1.4

7 months ago

2.1.3

7 months ago

2.1.2

7 months ago

2.0.2

8 months ago

2.0.1

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago