Comparing version 0.2.4 to 0.3.0
# Change log | ||
## Version 0.3.0 | ||
## Added | ||
#### Added useTimestamp to configuration object | ||
By given `useTimestamp`(Boolean) in the configuration object, the logger users Unix timestamp instead of the server local time. | ||
**NOTE**: File rotation still uses server local time for file names. | ||
## Changed | ||
None | ||
## Deprecated | ||
None | ||
## Removed | ||
None | ||
*** | ||
## Version 0.2.3 | ||
@@ -4,0 +28,0 @@ |
@@ -6,2 +6,3 @@ var util = require('util'); | ||
var depth = 4; | ||
var useTimestamp = false; | ||
@@ -16,9 +17,17 @@ module.exports.setup = function (config) { | ||
} | ||
if (config.useTimestamp) { | ||
useTimestamp = config.useTimestamp; | ||
} | ||
}; | ||
module.exports.create = function (prefix, logName, levelName, args) { | ||
var timestamp; | ||
var date = new Date(); | ||
var ymd = date.getFullYear() + '/' + pad(date.getMonth() + 1, 2) + '/' + pad(date.getDate(), 2); | ||
var his = pad(date.getHours(), 2) + ':' + pad(date.getMinutes(), 2) + ':' + pad(date.getSeconds(), 2) + ':' + pad(date.getMilliseconds(), 3); | ||
var timestamp = ymd + ' ' + his; | ||
if (useTimestamp) { | ||
timestamp = date.getTime(); | ||
} else { | ||
var ymd = date.getFullYear() + '/' + pad(date.getMonth() + 1, 2) + '/' + pad(date.getDate(), 2); | ||
var his = pad(date.getHours(), 2) + ':' + pad(date.getMinutes(), 2) + ':' + pad(date.getSeconds(), 2) + ':' + pad(date.getMilliseconds(), 3); | ||
timestamp = ymd + ' ' + his; | ||
} | ||
var msg = ['[' + timestamp + ']' + (prefix ? '[' + prefix + ']' : '') + '<' + levelName + '>[' + logName + ']']; | ||
@@ -25,0 +34,0 @@ for (var key in args) { |
{ | ||
"name": "gracelog", | ||
"description": "Log management module", | ||
"version": "0.2.4", | ||
"version": "0.3.0", | ||
"author": "Nobuyori Takahashi <voltrue2@yahoo.com>", | ||
@@ -6,0 +6,0 @@ "repository": { |
@@ -1,4 +0,4 @@ | ||
#gracelog | ||
# gracelog | ||
###Access | ||
### Access | ||
```javascript | ||
@@ -9,8 +9,9 @@ var gracelog = require('gracelog'); | ||
###Configurations | ||
### Configurations | ||
###.config(configData [object]) | ||
### .config(configData [object]) | ||
``` | ||
var configData = { | ||
"useTimestamp": <bool> // if given true, the logging time will be in Unix timestamp instead of the server time | ||
"bufferSize": <int> // log data buffer size in memory (bytes), | ||
@@ -17,0 +18,0 @@ "bufferFlushInterval": <int> // log data buffer auto flush interval in milliseconds, |
@@ -12,3 +12,4 @@ var assert = require('assert'); | ||
color: true, | ||
file: false | ||
file: false, | ||
useTimestamp: true | ||
}); | ||
@@ -15,0 +16,0 @@ |
4184907
906
327