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

[console] How can I redirect the log output? #5589

Open
themightyoarfish opened this issue Jan 23, 2023 · 3 comments
Open

[console] How can I redirect the log output? #5589

themightyoarfish opened this issue Jan 23, 2023 · 3 comments
Labels
kind: request Type of issue status: triage Labels incomplete

Comments

@themightyoarfish
Copy link
Contributor

I think the answer currently is "you can't", as macros in common/include/pcl/console/print.h always log to stdout. It would be extremely useful to globally redirect logging, or rather configure log handlers so any issues can be written to the application log file to troubleshoot.

Context

I get warnings only on stdout and thus cannot associate them with other stuff happening in my running application.

Expected behavior

A functionality to handle log messages in application code.

Current Behavior

Log always pollutes cout.

Describe the solution you'd like

E.g. a logging library providing this functionality is used.

Describe alternatives you've considered

Can't see any.

@themightyoarfish themightyoarfish added kind: request Type of issue status: triage Labels incomplete labels Jan 23, 2023
@mvieth
Copy link
Member

mvieth commented Feb 7, 2023

@themightyoarfish I would want to avoid depending on a logging library if possible. Adding new dependencies is always a big pain (need to check the license, need to make sure the dependency is available on all systems and in all package managers, have to be sure that the dependency will be maintained in the future, if there are bugs in the dependency we often have to deal with them (as we experienced several times with VTK)).

What do you think about the following function:

void redirect_logging (VERBOSITY_LEVEL level, FILE *stream);

Then you could for example redirect all WARNINGS to log_file.txt:

FILE* f = fopen("log_file.txt", "w");
pcl::console::redirect_logging(pcl::console::L_WARN, f);

@themightyoarfish
Copy link
Contributor Author

Something like that would be helpful, yes. No full logging library needed, just a way to intercept PCL logs to redirect them into our own logging.

@aurelienrb
Copy link

Hello!
Has such a feature been developed? It would be nice indeed to be able to intercept logs emitted by PCL, especially in GUI applications that use the library without any console attached.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: request Type of issue status: triage Labels incomplete
Projects
None yet
Development

No branches or pull requests

3 participants