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

apply serializers to args once before asObject or transmit #1971

Merged

Conversation

emmyakin
Copy link
Contributor

const argsCloned = args.slice()
let msg = argsCloned[0]
const logObject = {}
if (ts) {
logObject.time = ts
}
logObject.level = levelFormatter(level, logger.levels.values[level])

if (levelFormatter) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

restore previous implementation to fix this bug

@@ -361,9 +366,9 @@ function applySerializers (args, serialize, serializers, stdErrSerialize) {
for (const i in args) {
if (stdErrSerialize && args[i] instanceof Error) {
args[i] = pino.stdSerializers.err(args[i])
} else if (typeof args[i] === 'object' && !Array.isArray(args[i])) {
} else if (typeof args[i] === 'object' && !Array.isArray(args[i]) && serialize) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

no need to start a for loop, if serialize is not true

@@ -144,7 +144,7 @@ Unlike server pino the serializers apply to every object passed to the logger me
if the `asObject` option is `true`, this results in the serializers applying to the
first object (as in server pino).

For more info on serializers see https://github.com/pinojs/pino/blob/master/docs/api.md#parameters.
For more info on serializers see https://github.com/pinojs/pino/blob/master/docs/api.md#mergingobject.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix docs id references

@@ -284,7 +284,6 @@ test('children inherit parent serializers', ({ end, is }) => {

test('children serializers get called', ({ end, is }) => {
const parent = pino({
test: 'this',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is not part of the pino config, or log parameters, seems like a mistake

@@ -166,7 +166,7 @@ test('opts.browser.asObject logs pino-like object to console', ({ end, ok, is })
end()
})

test('opts.browser.formatters logs pino-like object to console', ({ end, ok, is }) => {
test('opts.browser.formatters (level) logs pino-like object to console', ({ end, ok, is }) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

test names were the same, adding context for the different formatters config


end()
})

test('opts.browser.write func string joining when asObject is true', ({ end, ok, is }) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this test was repeated, see line 262 below, I deleted this, git somehow is reconciling my changes adding new test using the these lines

@@ -302,7 +302,7 @@ function createWrap (self, opts, rootLogger, level) {
const proto = (Object.getPrototypeOf && Object.getPrototypeOf(this) === _console) ? _console : this
for (var i = 0; i < args.length; i++) args[i] = arguments[i]

if (opts.serialize && !opts.asObject) {
if (opts.serialize && !opts.transmit) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is the required change to fix the bug

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

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

Successfully merging this pull request may close these issues.

serializers are applied twice in pino/browser
2 participants