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

printing the date using Formatters doesn't work #456

Closed
lmj0011 opened this issue May 14, 2017 · 3 comments
Closed

printing the date using Formatters doesn't work #456

lmj0011 opened this issue May 14, 2017 · 3 comments

Comments

@lmj0011
Copy link

lmj0011 commented May 14, 2017

logger.js

const moment = require('moment')
const debug = require('debug')
const log = debug('adonuxt-rp:log [ %s ]', moment().format())
const error = debug('adonuxt-rp:error [ %s ]', moment().format())
debug.log = console.info.bind(console) // https://www.npmjs.com/package/debug#output-streams

const logger = {
  log,
  error
}

module.exports = logger
module.exports.default = logger

I have that module imported throughout my app and is using it like so
logger.log('Successfully created')

The output is not what I expect

  adonuxt-rp:log [ +398ms ] Successfully created

Why is my date output defaulting to the millisecond output?

I'm expecting an output similiar to this:

adonuxt-rp:log [ 2017-05-14T04:08:26-05:00 ] Successfully created
@TooTallNate
Copy link
Contributor

The API doesn't really work like that. The debug() function in your example only takes a single argument: the namespace.

@lmj0011
Copy link
Author

lmj0011 commented May 19, 2017

What should I do in order to get the date to output?

@Qix-
Copy link
Member

Qix- commented Jun 20, 2018

Closing in favor of #582. Please move discussion there.

@Qix- Qix- closed this as completed Jun 20, 2018
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