Skip to content

Improve debug logging #52

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

Merged
merged 1 commit into from
Aug 30, 2017
Merged

Improve debug logging #52

merged 1 commit into from
Aug 30, 2017

Conversation

kleisauke
Copy link
Member

When thumbnailing to 300x300 at our test environment, I now see:

[2017-08-30T19:59:41+00:00] debug: findLoad {"instance":null,"arguments":["##REDACTED##"]}
[2017-08-30T19:59:41+00:00] debug: findLoad {"result":["VipsForeignLoadJpegFile"]}
[2017-08-30T19:59:41+00:00] debug: newFromFile {"instance":null,"arguments":["##REDACTED##",{"access":"sequential"}]}
[2017-08-30T19:59:41+00:00] debug: newFromFile {"result":"{\"width\":1967,\"height\":2421,\"bands\":3,\"format\":\"uchar\",\"interpretation\":\"srgb\"}"}
[2017-08-30T19:59:41+00:00] debug: thumbnail {"instance":null,"arguments":["##REDACTED##",244,{"auto_rotate":false,"linear":false,"height":300,"size":"down"}]}
[2017-08-30T19:59:41+00:00] debug: thumbnail {"result":"{\"width\":244,\"height\":300,\"bands\":3,\"format\":\"uchar\",\"interpretation\":\"srgb\"}"}
[2017-08-30T19:59:41+00:00] debug: writeToBuffer {"instance":"{\"width\":244,\"height\":300,\"bands\":3,\"format\":\"uchar\",\"interpretation\":\"srgb\"}","arguments":[".jpg",{"strip":true,"Q":85,"interlace":false,"optimize_coding":true}]}
[2017-08-30T19:59:41+00:00] debug: writeToBuffer {"result":"##REDACTED##"}

Instead of:

[2017-08-30T18:39:21+00:00] debug: thumbnail {"instance":null,"arguments":["##REDACTED##",244,{"auto_rotate":false,"linear":false,"height":300,"size":"down"}]}
[2017-08-30T18:39:21+00:00] debug: thumbnail {"result":"{\"width\":244,\"height\":300,\"bands\":3,\"format\":\"uchar\",\"interpretation\":\"srgb\"}"}

When enabling the Vips\DebugLogger.

I didn't include the output of writeToFile (output: -1) and newInterpolator (output: GObject resource) because I think it's not needed for debugging.

If you want to hide the output/input of the *Buffer operations you can use this in the Vips\DebugLogger:

if (($message === 'findLoadBuffer' || $message === 'newFromBuffer') &&
    isset($context['arguments'][0])) {
    $context['arguments'][0] = '##REDACTED##';
}
if ($message === 'writeToBuffer' && isset($context['result'])) {
    $context['result'] = '##REDACTED##';
}

or to encode them with base64:

if (($message === 'findLoadBuffer' || $message === 'newFromBuffer') &&
    isset($context['arguments'][0])) {
    $context['arguments'][0] = base64_encode($context['arguments'][0]);
}
if ($message === 'writeToBuffer' && isset($context['result'])) {
    $context['result'] = base64_encode($context['result']);
}

(I didn't base64_encode them directly in the *Buffer operations because for performance reasons)

@jcupitt jcupitt merged commit f650b97 into libvips:master Aug 30, 2017
@jcupitt
Copy link
Member

jcupitt commented Aug 30, 2017

OK, looks good!

@kleisauke kleisauke deleted the improve-logging branch August 31, 2017 06:47
@jcupitt
Copy link
Member

jcupitt commented Aug 31, 2017

fwiw, I tried removing all the debug logging and it made no difference to the runtime of phpunit, so there's no performance impact, at least for the tests we do there.

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.

2 participants