Skip to content

Commit e98f931

Browse files
author
Eugene Rodionov
committed
Merge pull request LogRocket#42 from toxickg/master
Added milliseconds to timestamp, updated 'pad' function
2 parents 11b8147 + 67ef7c2 commit e98f931

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

dist/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ return /******/ (function(modules) { // webpackBootstrap
6767
Object.defineProperty(exports, "__esModule", {
6868
value: true
6969
});
70-
var pad = function pad(num) {
71-
return ("0" + num).slice(-2);
70+
var pad = function pad(num, maxLength) {
71+
return "0".repeat(maxLength - num.toString().length) + num;
7272
};
7373

7474
// Use the new performance api to get better precision if available
@@ -137,7 +137,7 @@ return /******/ (function(modules) { // webpackBootstrap
137137
var time = new Date();
138138
var isCollapsed = typeof collapsed === "function" ? collapsed(getState, action) : collapsed;
139139

140-
var formattedTime = timestamp ? " @ " + time.getHours() + ":" + pad(time.getMinutes()) + ":" + pad(time.getSeconds()) : "";
140+
var formattedTime = timestamp ? " @ " + pad(time.getHours(), 2) + ":" + pad(time.getMinutes(), 2) + ":" + pad(time.getSeconds(), 2) + "." + pad(time.getMilliseconds(), 3) : "";
141141
var formattedDuration = duration ? " in " + took.toFixed(2) + " ms" : "";
142142
var formattedAction = actionTransformer(action);
143143
var message = "action " + formattedAction.type + formattedTime + formattedDuration;

dist/index.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,22 @@
1717
"homepage": "https://github.com/fcomb/redux-logger",
1818
"dependencies": {
1919
"react": "^0.13.3",
20-
"redux": "3.0.0",
21-
"react-redux": "^3.0.0",
20+
"redux": "3.0.2",
21+
"react-redux": "^3.1.0",
2222
"redux-actions": "^0.8.0"
2323
},
2424
"devDependencies": {
2525
"babel-core": "^5.8.25",
2626
"babel-loader": "^5.3.2",
27-
"babel-plugin-react-transform": "^1.1.0",
27+
"babel-plugin-react-transform": "^1.1.1",
2828
"css-loader": "^0.19.0",
2929
"express": "^4.13.3",
3030
"node-sass": "^3.3.3",
31-
"react-transform-hmr": "^1.0.0",
32-
"sass-loader": "^2.0.1",
31+
"react-transform-hmr": "^1.0.1",
32+
"sass-loader": "^3.0.0",
3333
"style-loader": "^0.12.4",
3434
"webpack": "^1.12.2",
3535
"webpack-dev-middleware": "^1.2.0",
36-
"webpack-hot-middleware": "^2.2.0"
36+
"webpack-hot-middleware": "^2.4.1"
3737
}
3838
}

lib/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
Object.defineProperty(exports, "__esModule", {
44
value: true
55
});
6-
var pad = function pad(num) {
7-
return ("0" + num).slice(-2);
6+
var pad = function pad(num, maxLength) {
7+
return "0".repeat(maxLength - num.toString().length) + num;
88
};
99

1010
// Use the new performance api to get better precision if available
@@ -73,7 +73,7 @@ function createLogger() {
7373
var time = new Date();
7474
var isCollapsed = typeof collapsed === "function" ? collapsed(getState, action) : collapsed;
7575

76-
var formattedTime = timestamp ? " @ " + time.getHours() + ":" + pad(time.getMinutes()) + ":" + pad(time.getSeconds()) : "";
76+
var formattedTime = timestamp ? " @ " + pad(time.getHours(), 2) + ":" + pad(time.getMinutes(), 2) + ":" + pad(time.getSeconds(), 2) + "." + pad(time.getMilliseconds(), 3) : "";
7777
var formattedDuration = duration ? " in " + took.toFixed(2) + " ms" : "";
7878
var formattedAction = actionTransformer(action);
7979
var message = "action " + formattedAction.type + formattedTime + formattedDuration;

src/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const pad = num => (`0` + num).slice(-2);
1+
const pad = (num, maxLength) => `0`.repeat(maxLength - num.toString().length) + num;
22

33
// Use the new performance api to get better precision if available
44
const timer = typeof performance !== `undefined` && typeof performance.now === `function` ? performance : Date;
@@ -55,7 +55,7 @@ function createLogger(options = {}) {
5555
const time = new Date();
5656
const isCollapsed = (typeof collapsed === `function`) ? collapsed(getState, action) : collapsed;
5757

58-
const formattedTime = timestamp ? ` @ ${time.getHours()}:${pad(time.getMinutes())}:${pad(time.getSeconds())}` : ``;
58+
const formattedTime = timestamp ? ` @ ${pad(time.getHours(), 2)}:${pad(time.getMinutes(), 2)}:${pad(time.getSeconds(), 2)}.${pad(time.getMilliseconds(), 3)}` : ``;
5959
const formattedDuration = duration ? ` in ${took.toFixed(2)} ms` : ``;
6060
const formattedAction = actionTransformer(action);
6161
const message = `action ${formattedAction.type}${formattedTime}${formattedDuration}`;

0 commit comments

Comments
 (0)