1.0.6 • Published 4 years ago

drop-in-winston v1.0.6

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

Drop-in-Winston

This package exists purely so I don't have to constantly add the exact same patterns for my projects,

Syntax to initialize Winston essentially comes out to requiring the package and then calling it with an options object that includes a defaultMeta object that includes a key named "src". The options object can optionally include paths for logging files. I use src as the file path the function is in but it can be anything at all and you can add as many keys as you like to that object. By default errors go to log/error.log and everything (including errors but excepting verbose) goes to log/combined.log by default.

npm i drop-in-winston

const getLogger = require("drop-in-winston");
const { log, trace } = getLogger({
  defaultMeta: { src: "index.js" },
  error: "log/error.log",
  combined: "log/combined",
  verbose: "",
});

log.info("oh look, a log message", {
  variables: [blah, blah2, blah3],
});

Trace is a useful function for functional programming patterns involving composition. It takes a string (and optionally a logging level, defaults to 'verbose') as a parameter and returns a function that logs whatever value is passed to it before returning that value.

const getLogger = require("drop-in-winston");
const { log, trace } = getLogger({
  defaultMeta: { src: "index.js" },
  error: "log/error.log",
  combined: "log/combined",
  verbose: "",
});

pipe(someFn, trace("Look at this trace", "verbose"), someOtherFn);
1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago