https://github.com/outofsyncstudios/logstub
A basic library to stub logging calls when an external logger is expected to be passed to your libraries and applications
https://github.com/outofsyncstudios/logstub
logger nodejs npm open-source
Last synced: about 2 months ago
JSON representation
A basic library to stub logging calls when an external logger is expected to be passed to your libraries and applications
- Host: GitHub
- URL: https://github.com/outofsyncstudios/logstub
- Owner: OutOfSyncStudios
- License: mit
- Created: 2017-11-20T20:21:53.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-09-24T01:32:27.000Z (9 months ago)
- Last Synced: 2025-04-16T15:36:46.616Z (about 2 months ago)
- Topics: logger, nodejs, npm, open-source
- Language: JavaScript
- Homepage:
- Size: 451 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# logstub
[](https://nodei.co/npm/logstub/)
[](https://www.npmjs.org/package/logstub)
[](https://github.com/OutOfSyncStudios/logstub/actions/workflows/build-master.yml)
[](https://www.npmjs.org/package/logstub)
[](https://www.codacy.com/gh/OutOfSyncStudios/logstub/dashboard?utm_source=github.com&utm_medium=referral&utm_content=OutOfSyncStudios/logstub&utm_campaign=Badge_Grade)
[](https://www.codacy.com/gh/OutOfSyncStudios/logstub/dashboard?utm_source=github.com&utm_medium=referral&utm_content=OutOfSyncStudios/logstub&utm_campaign=Badge_Coverage)
[](https://david-dm.org/OutOfSyncStudios/logstub?view=list)logstub is a basic library to stub logging calls when an external logger is expected to be passed to your libraries and applications.
### Installation
```
$ npm install logstub
```### Usage
```js
const LogStub = require('logstub');class YourClass {
constructor(logger) {
// Stub out the logger when none is passed to the class constructor.
this.logger = logger || new LogStub();
}someMethod() {
try {
this.logger.info('Some Logging Info');
} catch (err) {
this.logger.error(err);
}
}
}
```## API
The logging stub will handle method calls for `log`, `silly`, `debug`, `info`, `verbose`, `warn`, `error`, `critical`, `fatal`, `trace`, and `all` with any number of parameters making it compatible for stubbing general logging from a number of popular logging libraries such as [Winston](https://www.npmjs.com/package/winston), [Log4JS](https://www.npmjs.com/package/log4js), and [Bunyan](https://www.npmjs.com/package/bunyan).
It also supports all standard `console` methods.
Copyright (c) 2017-2019 Jay Reardon
Copyright (c) 2019-2021 Out of Sync Studios
Licensed under the MIT license.