@megatherium/log
v1.6.2
Published
See the whole [documentation](https://megatherium.gitlab.io/log) or the [coverage report](https://megatherium.gitlab.io/log/coverage).
Downloads
14
Readme
log
See the whole documentation or the coverage report.
Getting started
Install the module:
$ npm install @megatherium/log
Use the module:
import logger from '@megatherium/log';
const log = logger.init({
app: 'test',
});
// create a logger for a subfolder
const subLog = log.init(null, 'subfolder');
subLog.debug(`A debugging message.`);
subLog.verbose(`A verbose message.`);
subLog.http(`An HTTP message - usually a request or response...`);
subLog.info(`An information.`);
subLog.warn(`A warning.`);
subLog.error(`An error message.`);API
Exports
Exports an instance of Logger:
- clear
(): PromiseClears all logs from the current log directory. - debug
(message: ...any): Promise<Message>Logs a message on the debugging channel. - error
(message: ...any): Promise<Message>Logs a message on the error channel. - http
(message: ...any): Promise<Message>Logs a message on the http channel. - info
(message: ...any): Promise<Message>Logs a message on the info channel. - init
(filenameOrMeta: string | object | null, directoryName: string): Promise<Logger>Initializes the logger. - log
(level: string, message: ...any): Promise<Message>Logs a message on any channel. - verbose
(message: ...any): Promise<Message>Logs a message on the verbose channel. - warn
(message: ...any): Promise<Message>Logs a message on the warn channel.
Environment variables
MEGATHERIUM_QUIET: booleanIftrue, messages will not be printed on the console.NODE_ENV: stringIf'production', messages on thedebug-channel will be ignored.
Scripts
The following scripts can be executed using npm run:
buildBuilds the module.build-docsBuilds the documentation.build-sourceBuilds the source code.build-testsBuilds test-cases from jsdoc examples.clearClears the module from a previous build.clear-coverageClears the coverage reports and caches.clear-docsClears the previous documentation build.clear-sourceClears the previous source build.clear-testsClears the generated jsdoc example test files.fixRuns all automated fixes.fix-lintAutomatically fixes linting problems.releaseRuns semantic release. Meant to be only executed by the CI, not by human users.testExecutes all tests.test-coverageGenerates coverage reports from the test results using nyc.test-depsExecutes a depcheck.test-e2eExecutes End-to-End-Tests using cucumber.test-integrationExecutes integration tests using jest.test-lintExecutes linting tests using eslint.test-unitExecutes unit tests using mocha.updateChecks for dependency updates using renovate.
Contribution
See Contribution Guidelines for more details.
