Skip to content

Commit

Permalink
feat: not applicable syslog levels
Browse files Browse the repository at this point in the history
BREAKING CHANGE:
'critical', 'alert' and 'emergency' levels were dropped as seem to
not serve a use case in context of JS apps
  • Loading branch information
medikoo committed Mar 18, 2019
1 parent 1f16640 commit 57c879a
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 26 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@ log.error("error message to be logged");

#### Available log levels

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

Expand Down
2 changes: 1 addition & 1 deletion levels.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
["debug", "info", "notice", "warning", "error", "critical", "alert", "emergency"]
["debug", "info", "notice", "warning", "error"]
11 changes: 1 addition & 10 deletions lib/level-symbols.json
Original file line number Diff line number Diff line change
@@ -1,10 +1 @@
{
"debug": "",
"info": "",
"notice": "",
"warning": "",
"error": "",
"critical": "",
"alert": "",
"emergency": ""
}
{ "debug": "", "info": "", "notice": "", "warning": "", "error": "" }
3 changes: 0 additions & 3 deletions test/index/01-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@ test("(main)", function (t) {
t.equal(typeof log.notice, "function");
t.equal(typeof log.warning, "function");
t.equal(typeof log.error, "function");
t.equal(typeof log.critical, "function");
t.equal(typeof log.alert, "function");
t.equal(typeof log.emergency, "function");
t.end();
});

Expand Down
2 changes: 1 addition & 1 deletion test/index/04-events.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ test("(main): Events", function (t) {
t.test("new level logger instance is created", function (t) {
var currentLog, caughtEvent;
emitter.once("init", function (event) { caughtEvent = event; });
currentLog = log.critical;
currentLog = log.warn;
t.equal(caughtEvent.logger, currentLog, "Event should expose initialized logger");
t.end();
});
Expand Down
2 changes: 0 additions & 2 deletions test/lib/setup-visibility/02-existing.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,13 @@ test("lib: setupVisibility: Affects already created loggers", function (t) {
log.debug.get("e1:d");
log.warning.get("e2:e");
log.error.get("foo");
log.alert.get("foo");
log.warning.get("e1");

setupEnv("error", ["e1", "-e1:d", "n1:d", "-n1:d:foo:*"]);

t.equal(log.debug.isEnabled, false, "Disables level logger deep below level threshold");
t.equal(log.warning.isEnabled, false, "Disables level logger just below threshold");
t.equal(log.error.isEnabled, true, "Keeps logger at the threshold enabled");
t.equal(log.alert.isEnabled, true, "Keeps loggers above threshold enabled");

t.test("Applies debug namespace map for level loggers below threshold", function (t) {
t.equal(log.warning.get("e1").isEnabled, true, "Enables directly mentioned namespace");
Expand Down
2 changes: 0 additions & 2 deletions test/lib/setup-visibility/03-future.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,11 @@ test("lib: setupVisibility: Affects loggers created later", function (t) {
log.debug.get("e1:d");
log.warning.get("e2:e");
log.error.get("foo");
log.alert.get("foo");
log.warning.get("e1");

setupEnv("error", ["e1", "-e1:d", "n1:d", "-n1:d:foo:*"]);

t.equal(log.info.isEnabled, false, "Disables level logger deep below level threshold");
t.equal(log.critical.isEnabled, true, "Keeps loggers above threshold enabled");

t.test("Applies debug namespace map for level loggers below threshold", function (t) {
t.equal(log.info.get("e1").isEnabled, true, "Enables directly mentioned namespace");
Expand Down

0 comments on commit 57c879a

Please sign in to comment.