Compare View
Commits (4)
Changes
Showing 3 changed files Side-by-side Diff
config.js
... | ... | @@ -6,9 +6,9 @@ let configFile = process.cwd() + "/config.json"; |
6 | 6 | |
7 | 7 | if (!fs.existsSync(configFile)) { |
8 | 8 | console.trace('Config file not found. Terminating'); |
9 | - setImmediate(function() { | |
9 | + //setImmediate(function() { | |
10 | 10 | process.exit(1); |
11 | - }); | |
11 | + //}); | |
12 | 12 | } |
13 | 13 | |
14 | 14 | const config = require(configFile); |
logger.js
... | ... | @@ -0,0 +1,45 @@ |
1 | +"use strict"; | |
2 | + | |
3 | +const fs = require('fs'); | |
4 | +const strftime = require('strftime'); | |
5 | +const winston = require('winston'); | |
6 | +require('winston-daily-rotate-file'); | |
7 | + | |
8 | +var loggerTimestamp = function() { | |
9 | + return strftime('%F %T', new Date()); | |
10 | +} | |
11 | + | |
12 | +let logger; | |
13 | + | |
14 | +const logDirectory = process.cwd() + '/logs'; | |
15 | +const filenamePrefix = logDirectory + "/log"; | |
16 | + | |
17 | +fs.existsSync(logDirectory) || fs.mkdirSync(logDirectory); | |
18 | + | |
19 | +logger = new winston.Logger({ | |
20 | + transports: [ | |
21 | + new (winston.transports.Console)({ | |
22 | + timestamp: function() { | |
23 | + return strftime('%F %T', new Date()); | |
24 | + }, | |
25 | + level: 'verbose', | |
26 | + }), | |
27 | + | |
28 | + new (winston.transports.DailyRotateFile) ({ | |
29 | + name: 'log-file-txt', | |
30 | + filename: filenamePrefix, | |
31 | + timestamp: loggerTimestamp, | |
32 | + formatter: function(options) { | |
33 | + return options.timestamp() | |
34 | + +' ' + options.level.toUpperCase() | |
35 | + +' ' + (undefined !== options.message ? options.message : '') | |
36 | + + (options.meta && Object.keys(options.meta).length ? '\n\t' + JSON.stringify(options.meta) : '' ); | |
37 | + }, | |
38 | + level: 'debug', | |
39 | + }), | |
40 | + ] | |
41 | +}); | |
42 | + | |
43 | +logger.verbose(__filename + ': initialized'); | |
44 | + | |
45 | +module.exports = logger; |
package.json
1 | 1 | { |
2 | 2 | "name": "komodo-sdk", |
3 | - "version": "1.0.2", | |
3 | + "version": "1.1.0", | |
4 | 4 | "description": "SDK for Komodo", |
5 | 5 | "main": "index.js", |
6 | 6 | "scripts": { |
... | ... | @@ -9,7 +9,7 @@ |
9 | 9 | }, |
10 | 10 | "repository": { |
11 | 11 | "type": "git", |
12 | - "url": "git@gitlab.kodesumber.com:adhisimon/komodo-sdk.git" | |
12 | + "url": "git@gitlab.kodesumber.com:komodo/komodo-sdk.git" | |
13 | 13 | }, |
14 | 14 | "keywords": [ |
15 | 15 | "ppob", |
... | ... | @@ -17,5 +17,9 @@ |
17 | 17 | "komodo" |
18 | 18 | ], |
19 | 19 | "author": "Adhidarma Hadiwinoto <gua@adhisimon.org>", |
20 | - "license": "ISC" | |
20 | + "license": "ISC", | |
21 | + "dependencies": { | |
22 | + "winston": "^2.3.1", | |
23 | + "winston-daily-rotate-file": "^1.4.6" | |
24 | + } | |
21 | 25 | } |