exiftool / exiftool

ExifTool meta information reader/writer

Home Page:https://exiftool.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Possible problem on stderr flushing when verbose level > 0

xsamix opened this issue · comments

When verbose level is > 0 and output is either piped and/or stderr is redirected to stdout, ordering of flushed messages are way off. Messages originally written to stderr are printed quite a lot earlier than rest of the messages regarding currently processed file, and are actually cutting lines written to stdout.

However, on verbose level 0 there seems to be no problem. Could the problem be with flushing, or am I doing something wrong..?

Why I'm doing this in the first place is I'd like to parse the output more eye friendly when processing lots of files, to easily notice anomalies.

Examples:

With verbose level 0, without stderr redirect, lines where xmp file related messages occur and appear (as expected):

$ exiftool -progress -verbose0 -out . '-filename<destination/%f_$imagesize.%e' source | grep -n xmp
93:======== source/701A4598.CR2.xmp [47/61]
Warning: [minor] Tag 'imagesize' not defined - source/701A4598.CR2.xmp
Warning: No writable tags set from source/701A4598.CR2.xmp
94:Nothing changed in source/701A4598.CR2.xmp

With verbose level 0, with stderr redirect, lines where xmp file related messages occur (as expected):

$ exiftool -progress -verbose0 -out . '-filename<destination/%f_$imagesize.%e' source 2>&1 | grep -n xmp
93:======== source/701A4598.CR2.xmp [47/61]
94:Warning: [minor] Tag 'imagesize' not defined - source/701A4598.CR2.xmp
95:Warning: No writable tags set from source/701A4598.CR2.xmp
96:Nothing changed in source/701A4598.CR2.xmp

With verbose level 1, without redirect:

$ exiftool -progress -verbose1 -out . '-filename<destination/%f_$imagesize.%e' source | grep -n xmp
Warning: [minor] Tag 'imagesize' not defined - source/701A4598.CR2.xmp
Warning: No writable tags set from source/701A4598.CR2.xmp
231:======== source/701A4598.CR2.xmp [47/61]
232:Setting new values from source/701A4598.CR2.xmp
233:'source/701A4598.CR2.xmp' --> './701A4598.CR2.xmp'
234:Rewriting source/701A4598.CR2.xmp...
235:Nothing changed in source/701A4598.CR2.xmp

With verbose level 1, with redirect:

$ exiftool -progress -verbose1 -out . '-filename<destination/%f_$imagesize.%e' source 2>&1 | grep -n xmp
190:Nothing changed in source/701A45Warning: [minor] Tag 'imagesize' not defined - source/701A4598.CR2.xmp
191:Warning: No writable tags set from source/701A4598.CR2.xmp
233:======== source/701A4598.CR2.xmp [47/61]
234:Setting new values from source/701A4598.CR2.xmp
235:'source/701A4598.CR2.xmp' --> './701A4598.CR2.xmp'
236:Rewriting source/701A4598.CR2.xmp...
237:Nothing changed in source/701A4598.CR2.xmp

-verbose0 flushes after each line of output. -verbose1 and higher does not. This is by design. From the documentation:

Using -v0 causes the console output buffer to be flushed after each line [...]

Higher verbose levels may produce significantly more output and my thought was that performance could be impacted if the buffering was disabled at these levels.

  • Phil

Ah, yes! I actually noticed that line from the documentation about verbose level 0 flushing after each line, but didn't think further that maybe higher levels do not.

I was after the log line which tells me file rename source --> target, and that is only printed on higher levels. But I can live without it just fine.

I'll close the issue as case is now clear.

Thank you very much for the awesome work Phil!

I think what I'll do is change the -v0 option so it also outputs the "source --> target" line. I'll try this in version 12.41.