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

Showing Dates / Timestamps for log entries #43

Closed
bennycode opened this issue Sep 29, 2016 · 5 comments
Closed

Showing Dates / Timestamps for log entries #43

bennycode opened this issue Sep 29, 2016 · 5 comments

Comments

@bennycode
Copy link
Collaborator

I really like the logdown.js project but does it support timestamps in front of log messages?

We are looking for something that can replace our current log library which gives us these features:

unbenannt

@caiogondim
Copy link
Owner

For timestamps in Chrome you can use this checkbox:
sep-29-2016 13-49-43

But that would work only in Chrome, not in other browsers or Node.js
We can implement this
Seems to be easy and straight forward

I'm thinking in an API similar to

// Prints timestamp in the format `2016-08-13` or `YYYY-MM-DD`
const logger1 = new Logdown({
  prefix: 'lorem',
  timestamp: true
})

// If a string is passed, we use it as a template for formatting the timestamp
const logger2 = new Logdown({
  prefix: 'lorem',
  timestamp: 'MM/DD/YYYY'
})

// Throws an error in case we can't parse the string passed as template
const logger3 = new Logdown({
  prefix: 'lorem',
  timestamp: 'ipsum'
})

Thoughts?

@bennycode
Copy link
Collaborator Author

From the first view, I like having a date format like 'MM/DD/YYYY'. One option I thought of is that prefix could accept also functions. Then people could write their own date mechanism, like:

const logger = new Logdown({
  prefix: function() {
    var time = new Date().toLocaleString();
    return time + ' MyModule';
  }
});

@caiogondim
Copy link
Owner

Like both ideas

  1. prefix should accept a function
  2. Output timestamp behind a flag

You mind crating issues for both so we can work on it?

@bennycode
Copy link
Collaborator Author

I created the two issues:

  1. Allow function value for "prefix" property #48
  2. Support "timestamp" property #49

From my side we can close down this issue here. WDYT?

@caiogondim
Copy link
Owner

Closing

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

No branches or pull requests

2 participants