Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

egomobile/mongo-log

Repository files navigation

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.