1.0.0 • Published 5 months ago

@egomobile/mongo-log v1.0.0

Weekly downloads
-
License
LGPL-3.0
Repository
github
Last release
5 months ago

npm last build PRs Welcome

@egomobile/mongo-log

A middleware for js-log, which writes logs to a Mongo database, using node-mongo.

Install

Execute the following command from your project folder, where your package.json file is stored:

npm install --save @egomobile/mongo-log

The following modules are defined in peerDependencies and have to be installed manually:

Usage

import log, {
  consoleLogger as useConsoleLogger,
  useFallback,
  useMongoLogger,
} from "@egomobile/mongo-log";

// reset the logger to configure it from scratch
log.reset();

// use mongo logger as first middleware and console logger as a fallback
log.use(useFallback(useMongoLogger(), useConsoleLogger()));

log("foo"); // default: debug
log.debug("foo"); // debug
log.error("foo"); // error
log.warn("foo"); // warning
log.info("foo"); // information
log.trace("foo"); // trace

Documentation

The API documentation can be found here.