forked from itteco/iframely
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogging.js
More file actions
24 lines (20 loc) · 716 Bytes
/
logging.js
File metadata and controls
24 lines (20 loc) · 716 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import moment from 'moment';
import CONFIG from './config.loader.js';
export default function log() {
var args = Array.prototype.slice.apply(arguments);
// Add ip if request provided.
var request = args[0];
if (request && request.headers) {
args.shift();
var remote_addr = request.headers['x-forwarded-for'] || request.connection.remoteAddress;
if (remote_addr) {
args.splice(0, 0, remote_addr, '-');
}
}
if (CONFIG.LOG_DATE_FORMAT) {
args.splice(0, 0, "--", moment().utc().format(CONFIG.LOG_DATE_FORMAT) + process.pid);
} else {
args.splice(0, 0, "--", "pid:" + process.pid);
}
console.log.apply(console, args);
};