Remove all instances of moment

master
Jonatan Nilsson 2018-07-22 08:30:10 +00:00
parent fe31b83e42
commit 4a50ed39c2
5 changed files with 2 additions and 62 deletions

View File

@ -26,12 +26,6 @@ var assert = require('assert');
var exeunt = require('exeunt');
try {
var moment = require('moment');
} catch (e) {
moment = null;
}
//---- globals and constants
@ -97,16 +91,6 @@ Object.keys(levelFromName).forEach(function (name) {
var TIME_UTC = 1; // the default, bunyan's native format
var TIME_LOCAL = 2;
// Timezone formats: output format -> momentjs format string
var TIMEZONE_UTC_FORMATS = {
long: '[[]YYYY-MM-DD[T]HH:mm:ss.SSS[Z][]]',
short: 'HH:mm:ss.SSS[Z]'
};
var TIMEZONE_LOCAL_FORMATS = {
long: '[[]YYYY-MM-DD[T]HH:mm:ss.SSSZ[]]',
short: 'HH:mm:ss.SSS'
};
// Boolean set to true when we are in the process of exiting. We don't always
// hard-exit (e.g. when staying alive while the pager completes).
@ -258,8 +242,6 @@ function printHelp() {
p(' simple: level, followed by "-" and then the message');
p(' -j shortcut for `-o json`');
p(' -0 shortcut for `-o bunyan`');
p(' -L, --time local');
p(' Display time field in local time, rather than UTC.');
p('');
p('Environment Variables:');
p(' BUNYAN_NO_COLOR Set to a non-empty value to force no output ');
@ -523,26 +505,12 @@ function parseArgv(argv) {
case '-0':
parsed.outputMode = OM_BUNYAN;
break;
case '-L':
parsed.timeFormat = TIME_LOCAL;
if (!moment) {
throw new Error(
'could not find moment package required for "-L"');
}
break;
case '--time':
var timeArg = args.shift();
switch (timeArg) {
case 'utc':
parsed.timeFormat = TIME_UTC;
break
case 'local':
parsed.timeFormat = TIME_LOCAL;
if (!moment) {
throw new Error('could not find moment package '
+ 'required for "--time=local"');
}
break
case undefined:
throw new Error('missing argument to "--time"');
default:
@ -795,24 +763,8 @@ function emitRecord(rec, line, opts, stylize) {
// Fast default path: We assume the raw `rec.time` is a UTC time
// in ISO 8601 format (per spec).
time = '[' + rec.time + ']';
} else if (!moment && opts.timeFormat === TIME_UTC) {
// Don't require momentjs install, as long as not using TIME_LOCAL.
} else if (opts.timeFormat === TIME_UTC) {
time = rec.time.substr(11);
} else {
var tzFormat;
var moTime = moment(rec.time);
switch (opts.timeFormat) {
case TIME_UTC:
tzFormat = TIMEZONE_UTC_FORMATS[short ? 'short' : 'long'];
moTime.utc();
break;
case TIME_LOCAL:
tzFormat = TIMEZONE_LOCAL_FORMATS[short ? 'short' : 'long'];
break;
default:
throw new Error('unexpected timeFormat: ' + opts.timeFormat);
};
time = moTime.format(tzFormat);
}
time = stylize(time, 'none');
delete rec.time;

View File

@ -142,10 +142,6 @@ Specify an output format\. One of \fBlong\fR (the default), \fBshort\fR, \fBjson
\fB\-j\fR
Shortcut for \fB\-o json\fR\.
.
.TP
\fB\-L\fR, \fB\-\-time local\fR
Display the time field in \fIlocal\fR time, rather than the default UTC time\.
.
.SH "LOG LEVELS"
In Bunyan log records, then \fBlevel\fR field is a number\. For the \fB\-l|\-\-level\fR argument the level \fBnames\fR are supported as shortcuts\. In \fB\-c|\-\-condition\fR scripts, uppercase symbols like "DEBUG" are defined for convenience\.
.

View File

@ -182,8 +182,6 @@ non-Bunyan lines are passed through.</p></dd>
<dt><code>-o FORMAT</code>, <code>--output FORMAT</code></dt><dd><p>Specify an output format. One of <code>long</code> (the default), <code>short</code>, <code>json</code>,
<code>json-N</code>, <code>bunyan</code> (the native bunyan 0-indent JSON output) or <code>inspect</code>.</p></dd>
<dt class="flush"><code>-j</code></dt><dd><p>Shortcut for <code>-o json</code>.</p></dd>
<dt><code>-L</code>, <code>--time local</code></dt><dd><p>Display the time field in <em>local</em> time, rather than the default UTC
time.</p></dd>
</dl>

View File

@ -109,10 +109,6 @@ Output options:
* `-j`:
Shortcut for `-o json`.
* `-L`, `--time local`:
Display the time field in *local* time, rather than the default UTC
time.
## LOG LEVELS

View File

@ -21,12 +21,10 @@
},
"// dtrace-provider": "required for dtrace features",
"// mv": "required for RotatingFileStream",
"// moment": "required for local time with CLI",
"optionalDependencies": {
"dtrace-provider": "~0.8",
"mv": "~2",
"safe-json-stringify": "~1",
"moment": "^2.10.6"
"safe-json-stringify": "~1"
},
"devDependencies": {
"nodeunit": "0.9",