Skip to content

Commit

Permalink
winston: updates to v3.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
brandoncarl committed Aug 21, 2021
1 parent e008d99 commit 705a150
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
1 change: 1 addition & 0 deletions History.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### v0.17.0
*Aug 15, 2021*
* Updates winston to 3.3.0
* Adds basic development Dockerfile

### v0.16.4
Expand Down
41 changes: 20 additions & 21 deletions lib/logging.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
**/

var morgan = require("morgan"),
var _ = require("lodash"),
morgan = require("morgan"),
Utils = require("./utils"),
winston = require("winston");

Expand All @@ -17,28 +18,26 @@ module.exports = {

setup: function() {

// winston's default console does not handle exceptions well. We use more sensible defaults
// here. Also note that winston's error handling does not include new lines for non-JSON format
// and as a result is unreadable. To fix this, we add two console loggers by default, one for
// errors (JSON-based) and one for non-errors (text-based).
winston
.remove(winston.transports.Console)
.add(winston.transports.Console, {
level: "debug",
handleExceptions: false,
colorize: !Utils.isProduction(),
json: false
})
.add(winston.transports.Console, {
name: "console-errors",
level: "error",
handleExceptions: true,
colorize: !Utils.isProduction(),
json: true
const debugFormat = Utils.isProduction() ? {} : { format: winston.format.cli() };

// We add two console loggers by default, one for errors (JSON-based) and one for non-errors (text-based).
// winston 3.x introduces the concept of a formatter. The combine method is poorly designed,
// thus we have to use array handling methods in order to achieve our desired results
return winston.createLogger({
transports: [
new winston.transports.Console(_.assign({
level: "debug",
handleExceptions: false
}, debugFormat)),
new winston.transports.Console({
name: "console-errors",
level: "errors",
handleExceptions: true,
format: winston.format.json()
})
]
});

return winston;

},


Expand Down
4 changes: 2 additions & 2 deletions package.json
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "shipp-server",
"version": "0.16.4",
"version": "0.17.0",
"description": "Dev server that quickly gets you up and running",
"main": "index.js",
"scripts": {
Expand Down Expand Up @@ -32,7 +32,7 @@
"universql-json": "^0.1.5",
"uuid": "^2.0.2",
"webpack": "^1.13.0",
"winston": "^2.2.0"
"winston": "^3.3.3"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit 705a150

Please sign in to comment.