4.9.97 • Published 12 months ago

@patrtorg/ratione-error-quo v4.9.97

Weekly downloads
-
License
MIT
Repository
github
Last release
12 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');
pureYAMLaccessibilityimportexporterroragenttoobjectstylecheckemitimmutableworkspace:*babelglobStyleSheetreusetypescircularrobustargvObservablesarktypeprettybeanstalktrimStarthttpmixinsinstallerdefinePropertyeslintpluginomitgetterECMAScript 5callbindshellfile systemwhichstyleguidedireventDispatcherzodtransportacornlengthserializees5flattenlinttoArrayfast-deep-clonetoSortedcssrecursivevarinferencepnpm9Array.prototype.flattenreact animationprotobufcss lessamazonincludesroute53routeprotocol-buffersvpcunicodecoercibleprivate dataWebSocketexecfileECMAScript 2017ES6dragstatelesssomedeterministicpasswordmake dirtoReversedcolorentriesyupnpmignoretoolkitworkflowES8ES2023performantrulesoperating-systemclassnamepersistentbootstrap lessiteratefilterES2021jQueryTypedArraytrimEndrapidECMAScript 2019removewindowsstylesheethasOwnzx[[Prototype]]urlsortlastloadingSystem.globalstringrfc9562cryptoes2015eslint-pluginnumberargumentlibphonenumberjson-schema-validationprogressresolveStreamsinvarianttranspileindicatorECMAScript 2020schemesetPrototypeOfelmCSSTypeBoxutilitiessyntaxrequestcompareextendArray.prototype.findLastcjkinputsqsbcryptinspectposegraphql$.extendbrowserslistpositiveuninstallreducerlazypicomatchlocalconsumeES2016awesomesaucepropECMAScript 7json-schema-validatorfindLastIndexES2020mapreducejavascriptsharedUint8ArrayasciiiteratorflagbinariesecmascriptnpmfpajvphonepolyfillpyyamlchromereduxliveminimalstartersafeArray.prototype.filterless compilerrandomexit-codereact-componentidlehasReactiveXES2019zeropostcss-pluginidentifiersURLSearchParamsgroupprefixopenssleffect-tssymlinkObject.keysshamkeyshttpsutil.inspectvalidationuser-streamsisConcatSpreadablepruneglobalWebSocketsinternal slotprocessignorewriteclassesArray.prototype.flatMapshimtypescriptmatchAlldynamodbstringifyconstes6es7assignec2datastructureairbnbglobalThispopmotions3react-hook-formbind.envlinuxownURLwhatwgtypesafebanner.gitignoremapmovebyteLengthtty6to5collection.es6Array.prototype.containsimportfullpropertiesRxJSmodulecss-in-jsexecfunctionchaia11yhasOwnPropertyqueuegenericshotbuffersstringifiersignalstabletimeES7namemomentcolumnrdscompilerfunctionsmergeloggerdiffwaitcertificateshardlinkseslintES2018gdpronceflatMapESshrinkwrappathcharactertypedarraysReactiveExtensionststestingregular-expressiongitignoreerror-handlingtoolsInt8ArrayFloat32Arrayhashwaapifantasy-landterminalgesturestranspilershebangObject.isECMAScript 2022collectionlogchromiumdataViewpreprocessordeep-copyhookformpostcsschannelbufferbusyECMAScript 3jshintthreefull-widthhooksjsonschemai18nanimationInt32ArraystatusexecutesuperstructObject.entriesglaciernegativeiamfindLastredactpipejwtreact-testing-librarystructuredClonemodulesaccessorsyntaxerroremrsharedarraybufferlesscssreplayregexUint32Arrayformfast-cloneArray.prototype.flatescapefromtouchdomeverysignedawsfastifygetestreeauthfullwidthnodejsES2022typeerrorstyled-componentstraversenested cssrequireserializationECMAScriptcore-js
4.9.95

12 months ago

4.9.97

12 months ago

4.9.96

12 months ago

4.9.94

12 months ago

4.8.94

12 months ago

4.8.93

12 months ago

4.8.92

1 year ago

4.8.91

1 year ago

4.8.90

1 year ago

4.8.89

1 year ago

4.8.88

1 year ago

4.8.87

1 year ago

4.8.86

1 year ago

4.8.85

1 year ago

4.8.84

1 year ago

4.7.84

1 year ago

4.7.83

1 year ago

4.7.82

1 year ago

4.7.81

1 year ago

4.7.80

1 year ago

4.7.79

1 year ago

4.7.78

1 year ago

4.7.77

1 year ago

4.6.77

1 year ago

4.6.76

1 year ago

4.6.75

1 year ago

4.6.74

1 year ago

4.6.73

1 year ago

4.6.72

1 year ago

4.6.71

1 year ago

4.6.70

1 year ago

4.5.70

1 year ago

4.5.69

1 year ago

4.5.68

1 year ago

4.5.67

1 year ago

4.5.66

1 year ago

4.5.65

1 year ago

4.5.64

1 year ago

4.5.63

1 year ago

4.5.62

1 year ago

4.5.61

1 year ago

4.5.60

1 year ago

4.5.59

1 year ago

3.5.59

1 year ago

3.5.58

1 year ago

3.4.58

1 year ago

3.4.57

1 year ago

3.4.56

1 year ago

3.4.55

1 year ago

3.3.55

1 year ago

3.3.54

1 year ago

3.3.53

1 year ago

3.3.52

1 year ago

3.3.51

1 year ago

3.3.50

1 year ago

3.3.49

1 year ago

2.3.49

1 year ago

2.3.48

1 year ago

2.3.47

1 year ago

2.3.46

1 year ago

1.3.46

1 year ago

1.3.45

1 year ago

1.3.44

1 year ago

1.3.43

1 year ago

1.2.43

1 year ago

1.2.42

1 year ago

1.2.41

1 year ago

1.2.40

1 year ago

1.2.39

1 year ago

1.2.38

1 year ago

1.2.37

1 year ago

1.1.37

1 year ago

1.1.36

1 year ago

1.1.35

1 year ago

1.1.34

1 year ago

1.1.33

1 year ago

1.1.32

1 year ago

1.1.31

1 year ago

1.1.30

1 year ago

1.1.29

1 year ago

1.1.28

1 year ago

1.1.27

1 year ago

1.1.26

1 year ago

1.1.25

1 year ago

1.1.24

1 year ago

1.1.23

1 year ago

1.1.22

1 year ago

1.1.21

1 year ago

1.1.20

1 year ago

1.1.19

1 year ago

1.0.19

1 year ago

1.0.18

1 year ago

1.0.17

1 year ago

1.0.16

1 year ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago