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

how to custom timestamp? #1

Closed
zieglar opened this issue Sep 8, 2019 · 8 comments · Fixed by #2
Closed

how to custom timestamp? #1

zieglar opened this issue Sep 8, 2019 · 8 comments · Fixed by #2
Assignees
Labels
enhancement New feature or request question Further information is requested

Comments

@zieglar
Copy link
Contributor

zieglar commented Sep 8, 2019

  • I'm submitting a ...
    [ ] bug report
    [x] feature request
    [ ] question about the decisions made in the repository
    [ ] question about how to use this project

  • Summary
    need reformat timestamp in log output

  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)

@lupu60 lupu60 self-assigned this Sep 9, 2019
@lupu60 lupu60 added the question Further information is requested label Sep 9, 2019
@lupu60
Copy link
Owner

lupu60 commented Sep 11, 2019

Hello @zieglar, on which logger are you interested?

@zieglar
Copy link
Contributor Author

zieglar commented Sep 11, 2019

winston

@lupu60
Copy link
Owner

lupu60 commented Sep 11, 2019

Ok, then I will release a new version with the option of customFormatter for the Winston logger.
You can find the examples here: https://github.com/winstonjs/winston#formats
Here is the default formatter:

You can basically copy and paste this function and pass it as an argument to the WinstonLogger constructor().

By doing this you can format not only the timestamp but all the params from the message.

@lupu60
Copy link
Owner

lupu60 commented Sep 11, 2019

Version 0.0.16 is up 👍

@lupu60 lupu60 added the enhancement New feature or request label Sep 11, 2019
@zieglar
Copy link
Contributor Author

zieglar commented Sep 11, 2019

ok, thank you.

@zieglar zieglar closed this as completed Sep 11, 2019
@zieglar
Copy link
Contributor Author

zieglar commented Sep 12, 2019

now new format is ok, but I think why we don't pass this format to winston config for modify timestamp format. winston issue :)

winston.createLogger({
    level: ...
    format: winston.format.combine(
        winston.format.label({ label: '[my-label]' }),
        winston.format.timestamp({
            format: 'YYYY-MM-DD HH:mm:ss'
        }),
        winston.format.simple()
    ),
    transports: ...
});

@zieglar zieglar reopened this Sep 12, 2019
@lupu60
Copy link
Owner

lupu60 commented Sep 12, 2019

Nice. If you want you can open a pr.

@zieglar
Copy link
Contributor Author

zieglar commented Sep 13, 2019

submited, please check and merge.

@lupu60 lupu60 closed this as completed in #2 Sep 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants