Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/atlassubbed/atlas-basic-logger
https://github.com/atlassubbed/atlas-basic-logger
Last synced: 21 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/atlassubbed/atlas-basic-logger
- Owner: atlassubbed
- License: other
- Created: 2018-06-26T04:52:52.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-06-28T05:07:41.000Z (over 6 years ago)
- Last Synced: 2024-04-24T22:21:51.154Z (9 months ago)
- Language: JavaScript
- Size: 18.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# atlas-basic-logger
A very simple debug logger.
[![Travis](https://img.shields.io/travis/atlassubbed/atlas-basic-logger.svg)](https://travis-ci.org/atlassubbed/atlas-basic-logger)
---
## install
```
npm install --save atlas-basic-logger
```## why
I just need a simple error-first `Logger` which lets me avoid using `console.log` (for testability), while making my business logic cleaner and more concise.
## examples
Both debug and concise mode can be used to do error-first logging. If an error is passed to the logger, it'll print it (or just the `message` in concise mode), otherwise it'll attempt to print the second argument.
#### debug mode
This will print the error to stderr, if it exists, otherwise it will print the full result to stdout, if it exists.
```javascript
const Logger = require("atlas-basic-logger");
const isDebug = true;
const log = Logger(isDebug)
reddit.deleteAccount("atlassubbed", (err, res) => {
log(err, res)
})
// or, in fewer lines
reddit.deleteAccount("atlassubbed", log)
```#### concise mode
This will print the error's `message` to stderr, if it exists, otherwise it will print the full result to stdout, if it exists.
```javascript
const log = require("atlas-basic-logger")();
reddit.deleteAccount("atlassubbed", (err, res) => {
log(err, res)
})
// or, in fewer lines
reddit.deleteAccount("atlassubbed", log)
```