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

Please change the behaviour of debug stdout/stderr output. #926

Closed
emmenlau opened this issue Jun 24, 2019 · 11 comments · Fixed by #939
Closed

Please change the behaviour of debug stdout/stderr output. #926

emmenlau opened this issue Jun 24, 2019 · 11 comments · Fixed by #939
Labels
enhancement feature / functionality enhancements request feature request or any other kind of wish
Milestone

Comments

@emmenlau
Copy link
Contributor

I have a kind request about the exiv2 sources. I see that debug builds use the define DEBUG to print more verbose output messages. These messages are directly written to std::cout or std::cerr.

This behavior is quite common and there is really nothing wrong with it. However I would slightly prefer more control over the messages, because when I use exiv2 debug builds, they tend to be quite verbose on stdout/stderr.

Would it be acceptable to change the logging behavior? I could think to either add a new define like EXIV2_DEBUG_MESSAGES that users can separately control independent of DEBUG. Or to leave the messages to be printed only when DEBUG is defined, but print via exiv2's existing logging mechanism from error.hpp so users can control the verbosity at runtime.

Does any of this sound reasonable? If you find it not worthwhile, please feel free to close this kind request.

@clanmills
Copy link
Collaborator

clanmills commented Jun 24, 2019

Thanks for this suggestion and we could do this.

Let me make a comment. The DEBUG symbol is intended to be set by the user for "occasional" use and not "blanket coverage". This is discussed in README.md 2.11 2) About preprocessor symbols NDEBUG and DEBUG.

I expect other team members will wish to comment. Let's reach a consensus and then agree on action.

@emmenlau
Copy link
Contributor Author

Thanks @clanmills for your quick and helpful reply!

I agree that setting DEBUG for blanket coverage is not super clean from my side. In my defense, I build some 30+ debug builds on Windows and they all happily accept the DEBUG define for additional helpful internal code checks and extended logging. So I am actually quite happy with exiv2's behavior! Only the current verbosity is a (small) issue for me because opening a single file can print 3-5 pages of internal messages which I can not redirect easily to my logger.

So please forgive if this request may be a rather unique use case and not so relevant to the general public. But if debug logging would go through the exiv2 logger, or use a separate define, it would be quite helpful for me.

@D4N
Copy link
Member

D4N commented Jun 24, 2019

I think having a compile time settable verbosity or a compile time switch for the logging is a good idea. I wouldn't mind to have instead of #ifdef DEBUG #endif: #ifdef EXIV2_DEBUG_MESSAGES #endif around the debug output.

I don't think that we should implement a runtime verbosity setting though. Such an option would be very painful on Unix where shared libraries generally exist only once in memory for all applications that link against them. I.e. any application could change the verbosity for every other application linking against libexiv2.

@D4N D4N added enhancement feature / functionality enhancements request feature request or any other kind of wish labels Jun 24, 2019
@clanmills
Copy link
Collaborator

clanmills commented Jun 24, 2019

Having a library run-time logging verbosity setting (default = 0, or EXIV2_DEBUG_VERBOSITY) would be process-wide and not machine-wide.

We wish to avoid API changes in the Exiv2 v0.27 "dots". While adding a new API doesn't hurt, it is something to avoid.

@clanmills clanmills reopened this Jun 24, 2019
@clanmills
Copy link
Collaborator

clanmills commented Jun 24, 2019

Re-opened. No idea how this issue was closed in error (cat jumped on the keyboard).

@D4N
Copy link
Member

D4N commented Jun 24, 2019

Having a library run-time logging verbosity setting (default = 0, or EXIV2_DEBUG_VERBOSITY) would be process-wide and not machine-wide.

That's only true if the variable that sets the logging verbosity is in the address space of the process linked against libexiv2. If the verbosity setting is however inside libexiv2, then the setting is global for all applications linked against libexiv2. (This only applies on Linux and maybe on other Unixes, on Windows shared libraries behave more like static libraries in that regard and each process get's their own copy of the shared library).

@clanmills clanmills added this to the v0.28 milestone Jun 24, 2019
@clanmills
Copy link
Collaborator

I'm setting the target to v0.28. I don't want to modify the behaviour or settings or API for v0.27 "dots". @emmenlau I recommend building without setting DEBUG.

@D4N: Windows DLLs are shared when located on the PATH. Most applications have copies of DLLs in the same directory as the .exe and use that copy because that directory is considered to be on the PATH. Unix systems usually find the shared library in a "standard" location such as /usr/local/lib and are therefore more commonly shared. Windows doesn't have a "standard" location. Microsoft usually put their DLLs in c:\windows\system32 and in ancient times, applications could use that directory to share system-wide DLLs.

@clanmills clanmills changed the title Could I kindly change the behavior of debug stdout/stderr printing? Please change the behaviour of debug stdout/stderr output. Jun 24, 2019
@D4N
Copy link
Member

D4N commented Jun 24, 2019 via email

@piponazo
Copy link
Collaborator

Hi guys!

As @D4N said, I would not mind either to replace DEBUG with EXIV2_DEBUG_MESSAGES to avoid these situations. I have seen the usage of DEBUG in many libraries and it could be that user users come with similar requests (Although it is clear that we are not doing anything wrong in our side).

If we do that ... could not we do it in 0.27-maintenance ? Right now we are not using the DEBUG definition in the public headers. I do not see an impediment to do that, but I might be wrong ...

@D4N
Copy link
Member

D4N commented Jun 28, 2019 via email

piponazo added a commit that referenced this issue Jun 28, 2019
piponazo added a commit that referenced this issue Jul 8, 2019
@D4N D4N closed this as completed in #939 Jul 8, 2019
D4N pushed a commit that referenced this issue Jul 8, 2019
@emmenlau
Copy link
Contributor Author

emmenlau commented Jul 8, 2019

Awesome guys, thanks a lot!

piponazo added a commit that referenced this issue Jul 11, 2019
piponazo added a commit that referenced this issue Jul 11, 2019
piponazo added a commit that referenced this issue Jul 11, 2019
D4N pushed a commit that referenced this issue Jul 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement feature / functionality enhancements request feature request or any other kind of wish
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants