First commit
This commit is contained in:
47
node_modules/abstract-logging/Readme.md
generated
vendored
Normal file
47
node_modules/abstract-logging/Readme.md
generated
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
# abstract-logging
|
||||
|
||||
This module provides an interface for modules to include so that they can
|
||||
support logging via an external logger that conforms to the standard Log4j
|
||||
interface. One such logger is [Pino](https://npm.im/pino). This module
|
||||
is intended for modules that are meant to be used by other modules.
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
'use strict'
|
||||
|
||||
function AwesomeLibrary (options) {
|
||||
this.log = (options.logger) ? options.logger : require('abstract-logging')
|
||||
}
|
||||
|
||||
AwesomeLibrary.prototype.coolMethod = function () {
|
||||
this.log.trace('AwesomeLibrary.coolMethod was invoked')
|
||||
return {}
|
||||
}
|
||||
|
||||
module.exports = AwesomeLibrary
|
||||
```
|
||||
|
||||
## Interface
|
||||
|
||||
Available methods:
|
||||
|
||||
+ `fatal`
|
||||
+ `error`
|
||||
+ `warn`
|
||||
+ `info`
|
||||
+ `debug`
|
||||
+ `trace`
|
||||
|
||||
All methods are no operation functions.
|
||||
|
||||
Some loggers, like [Pino](https://getpino.io/), implement a `child()` method. This method can be easily added to an `abstract-logging` instance when stubbing out such loggers:
|
||||
|
||||
```js
|
||||
const logger = require('abstract-logging')
|
||||
logger.child = () => logger
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT License](http://jsumners.mit-license.org/)
|
||||
18
node_modules/abstract-logging/index.js
generated
vendored
Normal file
18
node_modules/abstract-logging/index.js
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
'use strict'
|
||||
|
||||
function noop () { }
|
||||
|
||||
const proto = {
|
||||
fatal: noop,
|
||||
error: noop,
|
||||
warn: noop,
|
||||
info: noop,
|
||||
debug: noop,
|
||||
trace: noop
|
||||
}
|
||||
|
||||
Object.defineProperty(module, 'exports', {
|
||||
get () {
|
||||
return Object.create(proto)
|
||||
}
|
||||
})
|
||||
25
node_modules/abstract-logging/package.json
generated
vendored
Normal file
25
node_modules/abstract-logging/package.json
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "abstract-logging",
|
||||
"version": "2.0.1",
|
||||
"description": "A noop logger that conforms to the Log4j interface for modules to stub out internal logging",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "node test.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/jsumners/abstract-logging.git"
|
||||
},
|
||||
"keywords": [
|
||||
"log",
|
||||
"logging",
|
||||
"logger",
|
||||
"pino"
|
||||
],
|
||||
"author": "James Sumners <james.sumners@gmail.com>",
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/jsumners/abstract-logging/issues"
|
||||
},
|
||||
"homepage": "https://github.com/jsumners/abstract-logging#readme"
|
||||
}
|
||||
17
node_modules/abstract-logging/test.js
generated
vendored
Normal file
17
node_modules/abstract-logging/test.js
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
'use strict'
|
||||
|
||||
const assert = require('assert')
|
||||
|
||||
const one = require('./')
|
||||
const two = require('./')
|
||||
|
||||
assert.notEqual(one, two)
|
||||
assert.ok(one.info)
|
||||
assert.equal(Function.prototype.isPrototypeOf(one.info), true)
|
||||
two.info = () => 'info'
|
||||
|
||||
const result1 = one.info()
|
||||
assert.equal(result1, undefined)
|
||||
|
||||
const result2 = two.info()
|
||||
assert.equal(result2, 'info')
|
||||
Reference in New Issue
Block a user