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

proper way to disable stout verbose logs #129

Open
mynickmynick opened this issue Apr 20, 2023 · 6 comments
Open

proper way to disable stout verbose logs #129

mynickmynick opened this issue Apr 20, 2023 · 6 comments

Comments

@mynickmynick
Copy link

When i use Convex Hull in PCL I get a low of undesired outputs like

Convex hull of 81350 points in 2-d:

Number of vertices: 24 Number of facets: 24

Statistics for: | qhull FA

Number of points processed: 24 Number of hyperplanes created: 46 Number of distance tests for qhull: 540934 CPU seconds to compute hull (after input): 0.005 Total facet area: 0.56994136 Total volume: 0.017731251

how to disable them?

I don't see an option

thanks

@mynickmynick
Copy link
Author

mynickmynick commented Apr 22, 2023

I saw there is the option to set the out as nullptr. It works by avoiding the outputs and in one use case by PCL by convexhull it makes the elaboration time 20% faster but it is still not satisafctory becasue all around the qhull lib there are plenty of xxprintf() and related stuff still running and active (even if redirected to nullptr) creating unnecesary CPU overhead. Can we disable those parts of code with conditions similar to

if (fp)
.......do xxprintf(fp,...) etc stuff.....

??

@cbbarber
Copy link
Collaborator

The Qhull library contains multiple options for controlling the output. The "undesired" output is from option 's'. It is the default option if no options are provided to Qhull.
http://www.qhull.org/html/qh-quick.htm#options

In addition, the Qhull library includes qh_fprintf.c/.h These files define the qh_printf function. qh_fprintf handles Qhull's output. You can redefine qh_fprintf according to the msgcode (option 'Ta').

You may need to discuss your issue with the PCL developers.

@mynickmynick
Copy link
Author

mynickmynick commented Apr 24, 2023

Yes thanks, I apologize but I got lost in all those options. Which is the proper way to disable that option? "-s"? Still I am not understanding : the documentation says those "s" outputs are sent to stderr, while in the PCL stderr is by default redirected to nullptr and the "undesired" output i had was on stdout (which I after also redirected to nullptr as an option).

in PCL out and err file descriptors are passed to
int qh_new_qhull(int dim, int numpoints, coordT *points, boolT ismalloc,
char *qhull_cmd, FILE *outfile, FILE *errfile)

as outfile and errfile as far as i understood.

I disabled the "undesired" outputs by setting outfile=nullptr

by the way i see now that PCL redirects errfile to nullptr but that is useless because the code inside qh_new_qhull
sets it again as stderr (lines 145-147) ;))

if(!errfile){
errfile= stderr;
}
is this right? I don't think so, stderr should be always redirectable to null and all necessary error handling should not count on stderr, I think.

Why not adding conditions of the kind

if (file_descriptor)
{.....}

That would make all lines of codes skipped in the case when the file descriptor is redirected to nullptr

I will further study the matter (and the code) and get back

@mynickmynick
Copy link
Author

mynickmynick commented Apr 24, 2023

It's quite complicated to follow all this matter through the code but I suppose the sort of
pseudocode I was wishing of the kind

if (file_descriptor)
{.....}

is already implemented for the outfile
in qh_new_qhull with the lines

if (outfile) {
  qh_produce_output(qh);
}else {
  qh_prepare_output(qh);
}

so I think I might be happy with that (setting outfile=nullptr when I don't need it)

I keep though disliking the code

if(!errfile){
errfile= stderr;
}

inside qh_new_qhull
Could we consider the hypothesis of deleting those 3 lines and if not why are they necessary?

thank you so much

@mynickmynick
Copy link
Author

mynickmynick commented Apr 24, 2023

In addition, the Qhull library includes qh_fprintf.c/.h These files define the qh_printf function. qh_fprintf handles Qhull's output. You can redefine qh_fprintf according to the msgcode (option 'Ta').

do you mean the files userprintf_r.c and userprintf.c ?

@mynickmynick
Copy link
Author

I have avoided the most of unwanted out log by setting outfile=nullptr inside PCL. Still I am getting some less frequent flood of unwanted output on stderr, for that I opened anothe rissue

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

No branches or pull requests

2 participants