Comparing version 3.2.0 to 4.0.0
128
CHANGELOG.md
@@ -5,33 +5,47 @@ # Change Log | ||
<a name="3.2.0"></a> | ||
# [3.2.0](https://github.com/medikoo/log/compare/v3.1.0...v3.2.0) (2018-11-29) | ||
# [4.0.0](https://github.com/medikoo/log/compare/v3.2.0...v4.0.0) (2019-03-18) | ||
### Code Refactoring | ||
- move writer-utils to lib ([429aec5](https://github.com/medikoo/log/commit/429aec5)) | ||
### Features | ||
* rename log4 to log ([84cd31a](https://github.com/medikoo/log/commit/84cd31a)) | ||
- LOG_TIME recommendation and utils ([6af9400](https://github.com/medikoo/log/commit/6af9400)), closes [#9](https://github.com/medikoo/log/issues/9) | ||
- make 'info' level default ([4a1fa53](https://github.com/medikoo/log/commit/4a1fa53)) | ||
- not applicable syslog levels ([57c879a](https://github.com/medikoo/log/commit/57c879a)) | ||
- upgrade linter ([eba6bb4](https://github.com/medikoo/log/commit/eba6bb4)) | ||
### BREAKING CHANGES | ||
- 'critical', 'alert' and 'emergency' levels were dropped as seem to | ||
not serve a use case in context of JS apps | ||
- Default level was changed from 'debug' to 'info' | ||
- Or writer-utils were moved to lib | ||
<a name="3.1.0"></a> | ||
# [3.1.0](https://github.com/medikoo/log4/compare/v3.0.1...v3.1.0) (2018-09-21) | ||
<a name="3.2.0"></a> | ||
# [3.2.0](https://github.com/medikoo/log/compare/v3.1.0...v3.2.0) (2018-11-29) | ||
### Features | ||
* support default namespace concept ([3c99624](https://github.com/medikoo/log4/commit/3c99624)) | ||
* validate namespace token when setting as default ([62862c1](https://github.com/medikoo/log4/commit/62862c1)) | ||
- rename log4 to log ([84cd31a](https://github.com/medikoo/log/commit/84cd31a)) | ||
<a name="3.1.0"></a> | ||
# [3.1.0](https://github.com/medikoo/log4/compare/v3.0.1...v3.1.0) (2018-09-21) | ||
### Features | ||
- support default namespace concept ([3c99624](https://github.com/medikoo/log4/commit/3c99624)) | ||
- validate namespace token when setting as default ([62862c1](https://github.com/medikoo/log4/commit/62862c1)) | ||
<a name="3.0.1"></a> | ||
## [3.0.1](https://github.com/medikoo/log4/compare/v3.0.0...v3.0.1) (2018-06-01) | ||
### Bug Fixes | ||
* put default level threshold to notice ([e994285](https://github.com/medikoo/log4/commit/e994285)) | ||
- put default level threshold to notice ([e994285](https://github.com/medikoo/log4/commit/e994285)) | ||
<a name="3.0.0"></a> | ||
@@ -43,34 +57,34 @@ | ||
* Predefined levels are no longer accessible at `logger.predefinedLevels` property. | ||
- Predefined levels are no longer accessible at `logger.predefinedLevels` property. | ||
Instead they should be required from `log4/levels` | ||
* For simplicity and to avoid compliance issues, | ||
- For simplicity and to avoid compliance issues, | ||
only predefined levels are allowed (it's no | ||
longer possible to create custom named levels) | ||
* `enable()` and `disable()` methods no logger return own logger. | ||
- `enable()` and `disable()` methods no logger return own logger. | ||
Instead they return plain object with `restore` function, that allows to restore to previous state | ||
* `getNs` method has been renamed to | ||
- `getNs` method has been renamed to | ||
`get` | ||
* `ns` property has been renamed to | ||
- `ns` property has been renamed to | ||
`namespace` | ||
* `nsTokens` property has been renamed to | ||
- `nsTokens` property has been renamed to | ||
`namespaceTokens` | ||
* Emitter is not longer accessible at logger.emiter | ||
- Emitter is not longer accessible at logger.emiter | ||
Instead it should be required from `log4/emitter` | ||
* `getAllLevels` method has been renamed to | ||
- `getAllLevels` method has been renamed to | ||
`getAllInitializedLevels` | ||
* `hasLevel` method has been renamed to | ||
- `hasLevel` method has been renamed to | ||
`isLevelInitialized` | ||
* `hasNs` method has been renamed to | ||
- `hasNs` method has been renamed to | ||
`isNamespaceInitialized` | ||
* New setupVisibility accepts: | ||
- New setupVisibility accepts: | ||
* `levelThreshold` - on its basis it's decided logs for which levels are | ||
- `levelThreshold` - on its basis it's decided logs for which levels are | ||
enabled by default | ||
* `debugNamespaceToken` - List of namespaces to be exposed for | ||
- `debugNamespaceToken` - List of namespaces to be exposed for | ||
levels below threshold | ||
* `getLevel` method was removed. Use direct property names: | ||
- `getLevel` method was removed. Use direct property names: | ||
`log.error` instead of `log.getLevel("error")` | ||
* `getAllNs` method has been renamed to | ||
- `getAllNs` method has been renamed to | ||
`getAllInitializedNamespaces` | ||
@@ -80,7 +94,7 @@ | ||
* Default symbols to represent levels ([dc2487b](https://github.com/medikoo/log4/commit/dc2487b)) | ||
* Expose levelIndex on level ([aa480ee](https://github.com/medikoo/log4/commit/aa480ee)) | ||
* Introduce `logger.levelRoot` property ([d1b61c1](https://github.com/medikoo/log4/commit/d1b61c1)) | ||
* `isLogger` and `ensureLogger` utils ([30d7ab6](https://github.com/medikoo/log4/commit/30d7ab6)) | ||
* `registerMaster` log writer util ([7a36ad8](https://github.com/medikoo/log4/commit/7a36ad8)) | ||
- Default symbols to represent levels ([dc2487b](https://github.com/medikoo/log4/commit/dc2487b)) | ||
- Expose levelIndex on level ([aa480ee](https://github.com/medikoo/log4/commit/aa480ee)) | ||
- Introduce `logger.levelRoot` property ([d1b61c1](https://github.com/medikoo/log4/commit/d1b61c1)) | ||
- `isLogger` and `ensureLogger` utils ([30d7ab6](https://github.com/medikoo/log4/commit/30d7ab6)) | ||
- `registerMaster` log writer util ([7a36ad8](https://github.com/medikoo/log4/commit/7a36ad8)) | ||
@@ -93,16 +107,16 @@ <a name="2.0.0"></a> | ||
* remove date from log event ([7f2903a](https://github.com/medikoo/log4/commit/7f2903a)) | ||
* remove node env handler ([20450ad](https://github.com/medikoo/log4/commit/20450ad)) | ||
* remove obsolete event emit ([9499b37](https://github.com/medikoo/log4/commit/9499b37)) | ||
- remove date from log event ([7f2903a](https://github.com/medikoo/log4/commit/7f2903a)) | ||
- remove node env handler ([20450ad](https://github.com/medikoo/log4/commit/20450ad)) | ||
- remove obsolete event emit ([9499b37](https://github.com/medikoo/log4/commit/9499b37)) | ||
- feat: emit events also if logger disabled ([6eb338d](https://github.com/medikoo/log4/commit/6eb338d)) | ||
* feat: emit events also if logger disabled ([6eb338d](https://github.com/medikoo/log4/commit/6eb338d)) | ||
### BREAKING CHANGES | ||
* logs for disabled loggers will also be emitted. | ||
- logs for disabled loggers will also be emitted. | ||
Handler should check `logger.enabled` to confirm on whether | ||
intetion is to have log visible | ||
* remove 'event.date` property | ||
* log:before event was removed | ||
* Node env handler was moved to outer package, | ||
- remove 'event.date` property | ||
- log:before event was removed | ||
- Node env handler was moved to outer package, | ||
it'll have to be initialized as: | ||
@@ -118,4 +132,4 @@ | ||
* allow direct setting of isEnabled ([1245e21](https://github.com/medikoo/log4/commit/1245e21)) | ||
* **filter:** support nested catch all ([93f390c](https://github.com/medikoo/log4/commit/93f390c)) | ||
- allow direct setting of isEnabled ([1245e21](https://github.com/medikoo/log4/commit/1245e21)) | ||
- **filter:** support nested catch all ([93f390c](https://github.com/medikoo/log4/commit/93f390c)) | ||
@@ -128,3 +142,3 @@ <a name="1.1.0"></a> | ||
* expose 'warn' alias as predefined property ([e8bf927](https://github.com/medikoo/log4/commit/e8bf927)) | ||
- expose 'warn' alias as predefined property ([e8bf927](https://github.com/medikoo/log4/commit/e8bf927)) | ||
@@ -137,19 +151,19 @@ <a name="1.0.0"></a> | ||
* take back exposure of nsChildren ([1784c1a](https://github.com/medikoo/log4/commit/1784c1a)) | ||
- take back exposure of nsChildren ([1784c1a](https://github.com/medikoo/log4/commit/1784c1a)) | ||
### Features | ||
* do not force sort on getAllLevels ([8489362](https://github.com/medikoo/log4/commit/8489362)) | ||
* ensure emitted messageTokens are array ([28bea04](https://github.com/medikoo/log4/commit/28bea04)) | ||
* ensure enable/disable return target logger ([76228c0](https://github.com/medikoo/log4/commit/76228c0)) | ||
* expose array of predefined levels ([354db58](https://github.com/medikoo/log4/commit/354db58)) | ||
* expose levels at named properties ([91ab1c4](https://github.com/medikoo/log4/commit/91ab1c4)) | ||
* getLevels method ([8f36cfe](https://github.com/medikoo/log4/commit/8f36cfe)) | ||
* introduce getAllNs method ([e7eabee](https://github.com/medikoo/log4/commit/e7eabee)) | ||
* introduce hasLevel and hasNs ([2887a80](https://github.com/medikoo/log4/commit/2887a80)) | ||
* make \_children public as nsChildren ([0729be7](https://github.com/medikoo/log4/commit/0729be7)) | ||
* node.js env logger ([2582afe](https://github.com/medikoo/log4/commit/2582afe)) | ||
* predefined log levels ([ad23c30](https://github.com/medikoo/log4/commit/ad23c30)) | ||
* replace getLevels with getAllLevels ([03478fc](https://github.com/medikoo/log4/commit/03478fc)) | ||
* setupEnv functionality ([a873045](https://github.com/medikoo/log4/commit/a873045)) | ||
* tolerate whitespace noise in visibility conf ([14953be](https://github.com/medikoo/log4/commit/14953be)) | ||
- do not force sort on getAllLevels ([8489362](https://github.com/medikoo/log4/commit/8489362)) | ||
- ensure emitted messageTokens are array ([28bea04](https://github.com/medikoo/log4/commit/28bea04)) | ||
- ensure enable/disable return target logger ([76228c0](https://github.com/medikoo/log4/commit/76228c0)) | ||
- expose array of predefined levels ([354db58](https://github.com/medikoo/log4/commit/354db58)) | ||
- expose levels at named properties ([91ab1c4](https://github.com/medikoo/log4/commit/91ab1c4)) | ||
- getLevels method ([8f36cfe](https://github.com/medikoo/log4/commit/8f36cfe)) | ||
- introduce getAllNs method ([e7eabee](https://github.com/medikoo/log4/commit/e7eabee)) | ||
- introduce hasLevel and hasNs ([2887a80](https://github.com/medikoo/log4/commit/2887a80)) | ||
- make \_children public as nsChildren ([0729be7](https://github.com/medikoo/log4/commit/0729be7)) | ||
- node.js env logger ([2582afe](https://github.com/medikoo/log4/commit/2582afe)) | ||
- predefined log levels ([ad23c30](https://github.com/medikoo/log4/commit/ad23c30)) | ||
- replace getLevels with getAllLevels ([03478fc](https://github.com/medikoo/log4/commit/03478fc)) | ||
- setupEnv functionality ([a873045](https://github.com/medikoo/log4/commit/a873045)) | ||
- tolerate whitespace noise in visibility conf ([14953be](https://github.com/medikoo/log4/commit/14953be)) |
204
index.js
"use strict"; | ||
var aFrom = require("es5-ext/array/from") | ||
, identity = require("es5-ext/function/identity") | ||
, noop = require("es5-ext/function/noop") | ||
, assign = require("es5-ext/object/assign") | ||
, objForEach = require("es5-ext/object/for-each") | ||
, objToArray = require("es5-ext/object/to-array") | ||
, setPrototypeOf = require("es5-ext/object/set-prototype-of") | ||
, ensureString = require("es5-ext/object/validate-stringifiable-value") | ||
, toShortString = require("es5-ext/to-short-string-representation") | ||
, d = require("d") | ||
, lazy = require("d/lazy") | ||
, isNamespaceToken = require("./lib/private/is-namespace-token") | ||
, emitter = require("./writer-utils/emitter") | ||
, levelNames = require("./levels"); | ||
var loggerPrototype = require("./lib/private/logger-prototype"); | ||
// Map of initialized top level loggers | ||
var levelLoggers = Object.create(null); | ||
var createLevelLogger, createNamespaceLogger; | ||
var loggerPrototype = Object.create( | ||
Function.prototype, | ||
assign( | ||
{ | ||
// Public properties & methods | ||
// --------------------------- | ||
// Should logger logs be exposed? | ||
isEnabled: d("ew", true), | ||
// Initializes and returns namespaced logger | ||
get: d(function (namespace) { | ||
namespace = ensureString(namespace); | ||
var namespaceTokens = namespace.split(":"); | ||
namespaceTokens.forEach(function (namespaceToken) { | ||
if (!isNamespaceToken(namespaceToken)) { | ||
throw new TypeError( | ||
toShortString(namespace) + | ||
" is not a valid namespace string " + | ||
"(only 'a-z0-9-' chars are allowed and ':' as delimiter)" | ||
); | ||
} | ||
}); | ||
return namespaceTokens.reduce(function (currentLogger, token) { | ||
return createNamespaceLogger(currentLogger, token); | ||
}, this); | ||
}), | ||
// Enables logger and all its namespaced children | ||
enable: d(function () { return this._setEnabledState(true); }), | ||
// Disables logger and all its namespaced children | ||
disable: d(function () { return this._setEnabledState(false); }), | ||
// Public meta methods (used by log writers) | ||
// ----------------------------------------- | ||
isNamespaceInitialized: d("e", function (namespace) { | ||
var namespaceTokens = ensureString(namespace).split(":"); | ||
var currentLogger = this; | ||
return namespaceTokens.every(function (nsToken) { | ||
return (currentLogger = currentLogger._childNamespaceLoggers[nsToken]); | ||
}); | ||
}), | ||
isLevelInitialized: d("e", function (level) { | ||
level = ensureString(level); | ||
if (this.level === level) return true; | ||
var logger = levelLoggers[level]; | ||
if (!logger) return false; | ||
if (!this.namespace) return true; | ||
return logger.isNamespaceInitialized(this.namespace); | ||
}), | ||
getAllInitializedLevels: d("e", function () { | ||
return Object.keys(levelLoggers) | ||
.filter(function (level) { return this.isLevelInitialized(level); }, this) | ||
.map(function (level) { return this._getLevelLogger(level); }, this); | ||
}), | ||
getAllInitializedNamespaces: d("e", function () { | ||
return objToArray(this._childNamespaceLoggers, identity); | ||
}), | ||
// Internal properties and methods | ||
// ----------------------------------------- | ||
_namespaceToken: d("", null), | ||
_getLevelLogger: d(function (newLevel) { | ||
newLevel = ensureString(newLevel); | ||
if (this.level === newLevel) return this; | ||
var levelLogger = createLevelLogger(newLevel); | ||
return this.namespaceTokens.reduce(function (currentLogger, token) { | ||
return createNamespaceLogger(currentLogger, token); | ||
}, levelLogger); | ||
}), | ||
_setEnabledState: d(function (state) { | ||
var cache = []; | ||
this._setEnabledStateRecursively(state, cache); | ||
var result = { | ||
restore: function () { | ||
cache.forEach(function (data) { | ||
if (data.hasDirectSetting) data.logger.isEnabled = !state; | ||
else delete data.logger.isEnabled; | ||
}); | ||
result.restore = noop; | ||
} | ||
}; | ||
return result; | ||
}), | ||
_setEnabledStateRecursively: d(function (newState, cache) { | ||
if (this.isEnabled !== newState) { | ||
cache.push({ | ||
logger: this, | ||
hasDirectSetting: hasOwnProperty.call(this, "isEnabled") | ||
}); | ||
this.isEnabled = newState; | ||
} | ||
objForEach(this._childNamespaceLoggers, function (namespacedLogger) { | ||
namespacedLogger._setEnabledStateRecursively(newState, cache); | ||
}); | ||
}) | ||
}, | ||
// Lazily resolved properties | ||
// ----------------------------------------- | ||
lazy( | ||
assign( | ||
// Loggers for all levels | ||
levelNames.reduce(function (descriptors, level) { | ||
descriptors[level] = d( | ||
"e", | ||
function () { return this._getLevelLogger(level); }, | ||
{ cacheName: "_" + level } | ||
); | ||
return descriptors; | ||
}, {}), | ||
{ | ||
// Alias `warn` to `warning` | ||
warn: d(function () { return this._getLevelLogger("warning"); }, { | ||
cacheName: "_warning" | ||
}), | ||
// Full namespace string e.g. foo:bar:elo | ||
namespace: d( | ||
"e", | ||
function () { return this.namespaceTokens.join(":") || null; }, | ||
{ cacheName: "_namespace" } | ||
), | ||
// All namespace tokens e.g. ["foo", "bar", "elo"] | ||
namespaceTokens: d( | ||
"e", | ||
function () { | ||
return this._namespaceToken | ||
? Object.getPrototypeOf(this).namespaceTokens.concat( | ||
this._namespaceToken | ||
) | ||
: []; | ||
}, | ||
{ cacheName: "_namespaceTokens" } | ||
), | ||
// Internal: Map of children namespace loggers | ||
_childNamespaceLoggers: d("", function () { return Object.create(null); }, { | ||
cacheName: "__childNamespaceLoggers" | ||
}) | ||
} | ||
) | ||
) | ||
) | ||
); | ||
var createLogger = function (prototype) { | ||
// eslint-disable-next-line no-unused-vars | ||
return setPrototypeOf(function self(msgItem1/*, ...msgItemn*/) { | ||
emitter.emit("log", { logger: self, messageTokens: aFrom(arguments) }); | ||
}, prototype || loggerPrototype); | ||
}; | ||
createLevelLogger = function (levelName) { | ||
if (levelLoggers[levelName]) return levelLoggers[levelName]; | ||
var logger = createLogger(); | ||
Object.defineProperties(logger, { | ||
level: d("e", levelName), | ||
levelIndex: d("e", levelNames.indexOf(levelName)), | ||
levelRoot: d("e", logger) | ||
}); | ||
levelLoggers[levelName] = logger; | ||
emitter.emit("init", { logger: logger }); | ||
return logger; | ||
}; | ||
createNamespaceLogger = function (parent, namespaceToken) { | ||
if (parent._childNamespaceLoggers[namespaceToken]) { | ||
return parent._childNamespaceLoggers[namespaceToken]; | ||
} | ||
var logger = Object.defineProperties(createLogger(parent), { | ||
_namespaceToken: d("", namespaceToken) | ||
}); | ||
parent._childNamespaceLoggers[namespaceToken] = logger; | ||
emitter.emit("init", { logger: logger }); | ||
return logger; | ||
}; | ||
// Exports "debug" level logger as a starting point | ||
module.exports = createLevelLogger("debug"); | ||
module.exports = loggerPrototype._createLevel("info"); |
@@ -1,1 +0,1 @@ | ||
["debug", "info", "notice", "warning", "error", "critical", "alert", "emergency"] | ||
["debug", "info", "notice", "warning", "error"] |
126
package.json
{ | ||
"name": "log", | ||
"version": "3.2.0", | ||
"description": "Universal pluggable logging utility", | ||
"author": "Mariusz Nowak <medyk@medikoo.com> (http://www.medikoo.com/)", | ||
"keywords": [ | ||
"log", | ||
"logger", | ||
"debug", | ||
"bunyan", | ||
"winston" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/medikoo/log.git" | ||
}, | ||
"dependencies": { | ||
"d": "1", | ||
"es5-ext": "^0.10.46", | ||
"event-emitter": "^0.3.5" | ||
}, | ||
"devDependencies": { | ||
"browserstack-tape-runner": "2", | ||
"cjs-module": "1.4", | ||
"eslint": "^5.6", | ||
"eslint-config-medikoo-es5": "^1.7.1", | ||
"istanbul": "^0.4.5", | ||
"tape": "^4.9.1", | ||
"tape-index": "2" | ||
}, | ||
"eslintConfig": { | ||
"extends": "medikoo-es5", | ||
"root": true | ||
}, | ||
"scripts": { | ||
"coverage": "tape-index && istanbul cover test.index.js", | ||
"check-coverage": "npm run coverage && istanbul check-coverage --statements 100 --function 100 --branches 100 --lines 100", | ||
"lint": "eslint --ignore-path=.gitignore .", | ||
"test": "tape-index && node test.index.js", | ||
"test-browsers": "tape-index && browserstack-tape-runner test.index.js" | ||
}, | ||
"browserstack": { | ||
"browsers": [ | ||
"chrome_current", | ||
"firefox_current", | ||
"safari_current", | ||
"opera_current", | ||
"ie_11", | ||
"edge_current" | ||
] | ||
}, | ||
"license": "ISC" | ||
"name": "log", | ||
"version": "4.0.0", | ||
"description": "Universal pluggable logging utility", | ||
"author": "Mariusz Nowak <medyk@medikoo.com> (http://www.medikoo.com/)", | ||
"keywords": [ | ||
"log", | ||
"logger", | ||
"debug", | ||
"bunyan", | ||
"winston" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/medikoo/log.git" | ||
}, | ||
"dependencies": { | ||
"d": "^1.0.0", | ||
"duration": "^0.2.2", | ||
"es5-ext": "^0.10.49", | ||
"event-emitter": "^0.3.5" | ||
}, | ||
"devDependencies": { | ||
"browserstack-tape-runner": "^3.0.0", | ||
"eslint": "^5.15.1", | ||
"eslint-config-medikoo-es5": "^2.0.0", | ||
"essentials": "^1.0.0", | ||
"git-list-updated": "^1.1.2", | ||
"husky": "^1.3.1", | ||
"lint-staged": "^8.1.5", | ||
"ncjsm": "^2.0.0", | ||
"nyc": "^13.3.0", | ||
"prettier-elastic": "^1.16.4", | ||
"tape": "^4.10.1", | ||
"tape-index": "^3.0.1" | ||
}, | ||
"husky": { | ||
"hooks": { | ||
"pre-commit": "lint-staged" | ||
} | ||
}, | ||
"lint-staged": { | ||
"*.js": [ | ||
"eslint" | ||
], | ||
"*.{css,html,js,json,md,yaml,yml}": [ | ||
"prettier -c" | ||
] | ||
}, | ||
"eslintConfig": { | ||
"extends": "medikoo-es5", | ||
"root": true | ||
}, | ||
"scripts": { | ||
"coverage": "nyc --reporter=lcov --reporter=html --reporter=text-summary npm test", | ||
"check-coverage": "npm run coverage && nyc check-coverage --statements 100 --function 100 --branches 100 --lines 100", | ||
"lint": "eslint --ignore-path=.gitignore .", | ||
"lint-updated": "pipe-git-updated --ext=js -- eslint --ignore-pattern '!*'", | ||
"prettier-check-updated": "pipe-git-updated --ext=css --ext=html --ext=js --ext=json --ext=md --ext=yaml --ext=yml -- prettier -c", | ||
"prettify": "prettier --write --ignore-path .gitignore '**/*.{css,html,js,json,md,yaml,yml}'", | ||
"test": "npm run test-prepare && npm run test-run", | ||
"test-browsers": "tape-index && browserstack-tape-runner test.index.js", | ||
"test-prepare": "tape-index", | ||
"test-run": "node test.index.js" | ||
}, | ||
"browserstack": { | ||
"browsers": [ | ||
"chrome_current", | ||
"firefox_current", | ||
"safari_current", | ||
"opera_current", | ||
"ie_11", | ||
"edge_current" | ||
] | ||
}, | ||
"license": "ISC" | ||
} |
@@ -18,7 +18,7 @@ [![*nix build status][nix-build-image]][nix-build-url] | ||
```javascript | ||
// Default logger writes at 'debug' level | ||
// Default logger writes at 'info' level | ||
const log = require("log"); | ||
// Log 'debug' level message: | ||
log("some debug message %s", "injected string"); | ||
// Log 'info' level message: | ||
log("some info message %s", "injected string"); | ||
@@ -28,4 +28,4 @@ // Get namespaced logger (debug lib style) | ||
// Log 'debug' level message in context of 'my-lib' namespace: | ||
log("some debug message in 'my-lib' namespace context"); | ||
// Log 'info' level message in context of 'my-lib' namespace: | ||
log("some info message in 'my-lib' namespace context"); | ||
@@ -35,4 +35,4 @@ // Namespaces can be nested | ||
// Log 'debug' level message in context of 'my-lib:func' namespace: | ||
log("some debug message in 'my-lib:func' namespace context"); | ||
// Log 'info' level message in context of 'my-lib:func' namespace: | ||
log("some info message in 'my-lib:func' namespace context"); | ||
@@ -52,13 +52,13 @@ // Log 'error' level message in context of 'my-lib:func' namespace: | ||
Mirror of syslog (in severity order): | ||
Mirror of applicable syslog levels (in severity order): | ||
- `debug` - debugging information | ||
- `info` - a purely informational message | ||
- `debug` - debugging information (hidden by default) | ||
- `info` - a purely informational message (hidden by default) | ||
- `notice` - condition normal, but significant | ||
- `warning` (also aliased as `warn`) - condition warning | ||
- `error` - condition error | ||
- `critical` - condition critical | ||
- `alert` - immediate action required | ||
- `emergency` - system unusable | ||
- `error` - condition error - to notify of errors accompanied with recovery mechanism (hence reported as log and not as uncaught exception) | ||
_Note: `critical`, `alert`, `emergency` are not exposed as seem to not serve a use case in context of JS applications, | ||
such errors should be exposed as typical exceptions_ | ||
#### Output message formatting | ||
@@ -82,9 +82,9 @@ | ||
_Note to log writer configuration developers: For cross-env compatibiity it is advised to base implementation on [sprintf-kit](https://github.com/medikoo/sprintf-kit)_ | ||
_Note to log writer configuration developers: For cross-env compatibility it is advised to base implementation on [sprintf-kit](https://github.com/medikoo/sprintf-kit)_ | ||
#### Enabling log writing | ||
`log` on its own doesn't write anything to the console on any other mean (it just emits events to be consumed by preloaded log writers) | ||
`log` on its own doesn't write anything to the console or any other means (it just emits events to be consumed by preloaded log writers). | ||
To have logs written, the pre-chosen log writer needs to be initialized in main (starting) module of a process. | ||
To have logs written, the pre-chosen log writer needs to be initialized in the main (starting) module of a process. | ||
@@ -100,3 +100,3 @@ ##### List of available log writers | ||
Default visibility depends on the enviroment (see chosen log writer for more information), and in most cases is setup through following environment variables: | ||
Default visibility depends on the enviroment (see chosen log writer for more information), and in most cases is setup through the following environment variables: | ||
@@ -115,2 +115,11 @@ ###### `LOG_LEVEL` | ||
#### Timestamps logging | ||
Writers are recommended to to expose timestamps aside each log when following env var is set | ||
##### `LOG_TIME` | ||
- `rel` (default) - Logs time elapsed since logger initialization | ||
- `abs` - Logs absolute time in ISO 8601 format | ||
### Tests | ||
@@ -126,3 +135,3 @@ | ||
[nix-build-url]: https://semaphoreci.com/medikoo-org/log | ||
[win-build-image]: https://ci.appveyor.com/api/projects/status/i77xe4unnscrkews?svg=true | ||
[win-build-image]: https://ci.appveyor.com/api/projects/status/jmw8p7g98x83itr0?svg=true | ||
[win-build-url]: https://ci.appveyor.com/project/medikoo/log | ||
@@ -129,0 +138,0 @@ [cov-image]: https://img.shields.io/codecov/c/github/medikoo/log.svg |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
48159
36
910
135
1
4
12
+ Addedduration@^0.2.2
+ Addedduration@0.2.2(transitive)
Updatedd@^1.0.0
Updatedes5-ext@^0.10.49