A middleware for js-log, which writes logs to a Mongo database, using node-mongo.
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:
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
The API documentation can be found here.