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

browser write hook #218

Merged
merged 1 commit into from
Mar 22, 2017
Merged

browser write hook #218

merged 1 commit into from
Mar 22, 2017

Conversation

davidmarkclements
Copy link
Member

  • introduces object based logging that corresponds to pino logs
  • object based logging can be turned on independently with asObject option
  • supply an individual write function to capture all logs
  • supply an object to capture logs on level by level basis
  • if an object, any methods that aren't supplied fallback to logging to console
  • asObject is mandatorily enabled if write is supplied

cc @CyberThom @temsa

browser.js Outdated
return logger
}

pino._Pino = Pino
// pino._Pino = Pino
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why retain this line at all?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

accident

Copy link
Member

@jsumners jsumners left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

browser.js Outdated

function asObject (logger, levels) {
var k
for (var i in levels) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

levels is an array in here.
It looks a bit strange that you're using a normal for loop everywhere else except here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good spot!

var proto = opts.browser.write || _console
if (opts.browser.write) opts.browser.asObject = true

var levels = ['error', 'fatal', 'warn', 'info', 'debug', 'trace']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you can move that array into the asObject function. You don't need it anywhere else.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not want to allocate this every time we call asObject.

@davidmarkclements davidmarkclements merged commit 403edfe into master Mar 22, 2017
@jsumners jsumners deleted the browser-write-hook branch May 3, 2019 11:45
@github-actions
Copy link

github-actions bot commented Feb 5, 2022

This pull request 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 5, 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

Successfully merging this pull request may close these issues.

None yet

4 participants