Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why does formatArgs prepend with date if useColors = false? #216

Closed
ptrhdn opened this issue Aug 25, 2015 · 3 comments
Closed

Why does formatArgs prepend with date if useColors = false? #216

ptrhdn opened this issue Aug 25, 2015 · 3 comments

Comments

@ptrhdn
Copy link

ptrhdn commented Aug 25, 2015

Unsure why formatArgs prepends log message with a date stamp when useColors is false. Am I missing something?

/**
 * Adds ANSI color escape codes if enabled.
 *
 * @api public
 */

function formatArgs() {
  var args = arguments;
  var useColors = this.useColors;
  var name = this.namespace;

  if (useColors) {
    var c = this.color;

    args[0] = '  \u001b[3' + c + ';1m' + name + ' '
      + '\u001b[0m'
      + args[0] + '\u001b[3' + c + 'm'
      + ' +' + exports.humanize(this.diff) + '\u001b[0m';
  } else {
    args[0] = new Date().toUTCString()
      + ' ' + name + ' ' + args[0];
  }
  return args;
}
@gramakri
Copy link

We face this issue when running a node program via systemd. We end up with double dates in journactl logs (one from systemd itself and another from the above code).

@gramakri
Copy link

See also #161 and #157

@thebigredgeek
Copy link
Contributor

Date configuration and output parsing via middleware should be supported in V3 and solve this.

Check it out here: #370

Closing for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants