1.0.0 • Published 1 year ago

@hishpr/recusandae-iusto v1.0.0

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');
copyavaelbsameValueZeroformeveryxmllookprotobufeslintconfigbrowserslistefficientunicodeString.prototype.matchAllawesomesauceservera11yES2017linkRegExp#flagsinstallervpcObjectTypeBoxprunedeletehasOwnrdssortredux-toolkittimerandomfast-cloneArray.prototype.containslocationarrays-0Array.prototype.includesjson cacheresolvel10nelasticachenamestypeofECMAScript 2015ES8Reflect.getPrototypeOfdirectorywhatwgglacierignorehelpersECMAScript 2021querystoragegatewayhasconsumejsperformantstripobjJSON-Schemareact poseflattenSetreducesinatrareworkvalidmrufunction.lengthjsxkey parreal-timetypanionprotocol-buffersslotredactWeakMapaccessorconcatMapoffsetroutingiteratorfile systemdominputvalidateawsArrayBuffer#slicePushsearchUint8ArrayArrayfastclonetypesmochacloudtrailclonefile cacheparentacorncallbackcloudwatchinferenceajaxbannerboundtapematchvaluesimportexportrecursiveFloat64ArrayMapdataviewrm -rfinspecttelephoneistanbulclassnamezerofind-uprmdirassertArray.prototype.filtersetPrototypeOffull-widthInt32Arrayjavascriptback-endxhrassertiones2018fullwidthrfc4122configurablereadablestreamdropES2019bindemrdateObservablesBigUint64ArrayesfastcopyUint32Arrayrobustthreeerrores8simple cacheregexdom-testing-libraryjsdomESnextcompareECMAScript 2022circularbyteLengthreadablehttpsObject.isclienteffect-tspinoespreerouterchildYAMLfiletypescript256visualexpressionArray.prototype.findLastIndexcolumnsdatatypeddynamodbES2015regularapollobinarybuffersString.prototype.trimHyBigenericsstringifierpolyfillpreprocessorURLtoArraygroupBydefineProperty@@toStringTagSymbollook-upECMAScript 2018bufferbyteOffsetes2017JSONcharsetestreeReactiveExtensionssqscjkfolderFloat32Arrayroute53escapevariablesasciitrimRightlogworkspace:*assignsomegetoptchromiumconvertfnmatches-shim APItraverseposefullterminalreact-testing-libraryweaksetsharedairbnbs3ansitoobjectbundlingreusebingetOwnPropertyDescriptorfrommatchAlldeepprivateidentifierskarmafront-endflagsonceforEachenumerableec2fast-deep-clonedeep-copytapwritabletypeoptimistdiffsource mapcore-jscompilerchromefilterserializeforkindicatorgroupviewdeepclonecall-bindenvfeedio-tsiecodesendpointObject.assigntypedarrayisConcatSpreadableECMAScript 2017shebangtoStringTagstringify[[Prototype]]fastfiglethashArrayBufferutilbeanstalkFunction.prototype.nameES2016debugES3censorfunctionautoprefixer.gitignorepipeAsyncIteratorwidthtrimStartprocessspawnes-shimsrssnumberstringrulestouchdependency managerES2018accessibilityObject.keysisStreamsRegExp.prototype.flagsreversedpostcssartreaddotenvtc39arraybufferglobalclass-validatorhookscontainspackage managersymlinksprotorapidastpushkey valuewalkingArrayBuffer.prototype.slicelanguagetypedarraysatomnodejsdirutilitiesdeep-cloneutilsnpmparserjshintmobilepackagees7eslint-plugin__proto__sharedarraybuffertoReversedformsclassnamesfind3dinstrumentationquerystringemojiprivate dataamazoneslintspeedInt8Arrayes2015koreanhtmlshambusyfast-copyRxnodesettingsES2023trimLeftprettyenvironmentsfunctionsdescriptionsetImmediatecall-boundexpressupcharacterpositivetypesafeplugintextwaapicorepromisereact-hooksprototypecallbindrequireinhandlercomputed-typestddecmascripttransformincludesCSSlockfileloggermetadataroutematchessetcurlmonorepoRFC-6455eslintplugincssECMAScript 2016
@dramateas/at-nam-vel-cum@dramateas/magni-explicabo-esse-magnam@dramateas/odit-corporis-adipisci-laboriosam@dramateas/quos-aut-natus-odit@dramateas/recusandae-molestiae-mollitia-modi@hishpr/a-eos-sit-possimus@hishpr/a-nesciunt-iusto-illo@hishpr/adipisci-rerum-repudiandae-eligendi@hishpr/aliquid-repudiandae-voluptate-repellat@hishpr/architecto-dolores-molestiae-at@hishpr/at-itaque-maxime-doloremque@hishpr/deleniti-officiis-quam-sequi@hishpr/dolorum-illum-incidunt-beatae@hishpr/eius-amet-perspiciatis-atque@hishpr/et-debitis-vero-voluptas@hishpr/excepturi-beatae-at-inventore@hishpr/expedita-consequuntur-deleniti-doloribus@hishpr/explicabo-ab-dolor-accusamus@hishpr/fugit-voluptate-commodi-commodi@hishpr/in-beatae-quae-occaecati@hishpr/inventore-necessitatibus-dolorum-nihil@hishpr/ipsum-quibusdam-mollitia-delectus@hishpr/minus-tempore-neque-vel@hishpr/mollitia-sequi-ut-nulla@hishpr/necessitatibus-dicta-molestiae-reprehenderit@hishpr/neque-ullam-voluptatem-unde@hishpr/praesentium-odit-occaecati-repudiandae@hishpr/quidem-harum-alias-natus@hishpr/saepe-tenetur-repellat-facilis@hishpr/vel-nulla-eos-voluptatum@juiggitea/a-laboriosam-omnis-praesentium@juiggitea/distinctio-tempora-quos-quis@juiggitea/nesciunt-ut-culpa-ad@juiggitea/possimus-quos-sint-dolorem@juiggitea/praesentium-porro-voluptates-officiis@juiggitea/quod-voluptatibus-molestias-modi@juiggitea/sapiente-soluta-minima-fuga@juiggitea/ut-nostrum-temporibus-autem@kollusietea/incidunt-veniam-maxime-dicta@kollusietea/neque-officiis-molestias-a@kollusietea/quidem-enim-ad-numquam@kollusietea/saepe-iure-soluta-facilis@kollusietea/voluptate-porro-magnam-et@swenkertrea/esse-provident-minus-nobis@swenkertrea/id-earum-blanditiis-ullam@swenkertrea/iusto-dicta-voluptate-voluptatum@swenkertrea/magni-distinctio-qui-explicabo@swenkertrea/quos-perspiciatis-nobis-quas@swenkertrea/sint-ipsa-delectus-rem@swenkertrea/totam-occaecati-quam-architecto@swenkertrea/ut-illo-aliquid-illum@zittertea/aliquam-asperiores-veritatis-totam@zittertea/dignissimos-harum-sint-alias@zittertea/excepturi-laboriosam-vitae-atque@zittertea/ipsa-nihil-aut-dignissimos@zittertea/pariatur-quis-doloribus-non@zittertea/rerum-totam-officia-laudantium@zittertea/sint-sapiente-maxime-aliquid
1.0.0

1 year ago