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

"timestamp" option is ignored in Browser environment #903

Closed
acro5piano opened this issue Sep 5, 2020 · 5 comments
Closed

"timestamp" option is ignored in Browser environment #903

acro5piano opened this issue Sep 5, 2020 · 5 comments

Comments

@acro5piano
Copy link
Contributor

acro5piano commented Sep 5, 2020

Hi, thank you for the great library.

I've run the following code.

I expected time should become ISO String, but actually the output is still epochTime.

import pino from 'pino'

const logger = pino({
  timestamp: () => `,"time":"${new Date(Date.now()).toISOString()}"`,
  browser: {
    asObject: true,
  },
})

logger.info('Running app')

image

is this intensional? Thanks in advance.

@mcollina
Copy link
Member

mcollina commented Sep 5, 2020

Yes, this is intentional. In the browser some of the internals are different :( and we cannot have the same features. We might want to add something analog to this. Would you like to send a PR?

@acro5piano
Copy link
Contributor Author

acro5piano commented Sep 5, 2020

@mcollina

Thanks for the reply. The code is located here, right? I'll try to work on it :)

https://github.com/pinojs/pino/blob/master/browser.js#L211

And it looks like passing opts.timestamp to wrap will add customization capability.

https://github.com/pinojs/pino/blob/master/browser.js#L177

@mcollina
Copy link
Member

mcollina commented Sep 5, 2020

Yes

@dariolongo
Copy link

Hi,
First of all, thanks for Pino!

Hope this can help others...

Using the timestamp function and browser.asObject true:

timestamp: () => `,"time":"${new Date(Date.now()).toISOString()}"`,
browser: {
  asObject: true
}

it's ok on stdout:

{"level":30,"time":"2021-11-03T10:59:59.348Z","msg":"Running app"}

but it's not totally correct in the browser:
Schermata 2021-11-03 alle 12 02 08

Using this:

timestamp: pino.stdTimeFunctions.isoTime,

work well for both!

Bey

@github-actions
Copy link

github-actions bot commented Feb 2, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants