From 4a50ed39c26c02c3b5459d781b261b159128cd9f Mon Sep 17 00:00:00 2001 From: Jonatan Nilsson Date: Sun, 22 Jul 2018 08:30:10 +0000 Subject: [PATCH] Remove all instances of moment --- bin/bunyan | 50 +--------------------------------------------- docs/bunyan.1 | 4 ---- docs/bunyan.1.html | 2 -- docs/bunyan.1.ronn | 4 ---- package.json | 4 +--- 5 files changed, 2 insertions(+), 62 deletions(-) diff --git a/bin/bunyan b/bin/bunyan index 178f493..af4ff3d 100755 --- a/bin/bunyan +++ b/bin/bunyan @@ -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; diff --git a/docs/bunyan.1 b/docs/bunyan.1 index 41d3769..d0ed132 100644 --- a/docs/bunyan.1 +++ b/docs/bunyan.1 @@ -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\. . diff --git a/docs/bunyan.1.html b/docs/bunyan.1.html index c11eaf0..617aec9 100644 --- a/docs/bunyan.1.html +++ b/docs/bunyan.1.html @@ -182,8 +182,6 @@ non-Bunyan lines are passed through.

-o FORMAT, --output FORMAT

Specify an output format. One of long (the default), short, json, json-N, bunyan (the native bunyan 0-indent JSON output) or inspect.

-j

Shortcut for -o json.

-
-L, --time local

Display the time field in local time, rather than the default UTC -time.

diff --git a/docs/bunyan.1.ronn b/docs/bunyan.1.ronn index c09b933..1fe0d1e 100644 --- a/docs/bunyan.1.ronn +++ b/docs/bunyan.1.ronn @@ -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 diff --git a/package.json b/package.json index 00a4803..aecb6f1 100644 --- a/package.json +++ b/package.json @@ -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",