forked from steveblue/angular2-rollup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.log.js
55 lines (44 loc) · 1.53 KB
/
build.log.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
"use strict";
const colors = require('colors');
const clim = require('clim');
const cons = clim();
const log = function (action, noun, next) {
let a = action ? colors.dim(colors.white(action)) : '';
let n = noun ? colors.dim(colors.white(noun)) : '';
let x = next ? colors.dim(colors.white(next)) : '';
cons.log(a + ' ' + n + ' ' + x);
};
const alert = function (noun, verb, action, next) {
let n = noun ? colors.white(noun) : '';
let v = verb ? colors.white(verb) : '';
let a = action ? colors.white(action) : '';
let x = next ? colors.dim(colors.white(next)) : '';
cons.log(n + ' ' + v + ' ' + a + ' ' + x);
};
const warn = function (action, noun) {
let a = action ? colors.red(action) : '';
let n = noun ? colors.white(noun) : '';
cons.warn(a + ' ' + n);
};
clim.getTime = function () {
let now = new Date();
return colors.gray(colors.dim('[' +
(now.getHours() < 10 ? '0' : '') + now.getHours() + ':' +
(now.getMinutes() < 10 ? '0' : '') + now.getMinutes() + ':' +
(now.getSeconds() < 10 ? '0' : '') + now.getSeconds() + ']'));
};
clim.logWrite = function (level, prefixes, msg) {
// Default implementation writing to stderr
var line = clim.getTime() + " " + level;
if (prefixes.length > 0) line += " " + prefixes.join(" ");
line = colors.dim(line);
line += " " + msg;
process.stderr.write(line + "\n");
// or post it web service, save to database etc...
};
module.exports = {
log: log,
warn: warn,
alert: alert,
colors: colors
};