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

Stream content in one record #285

Open
gaubert opened this issue Jan 11, 2019 · 3 comments
Open

Stream content in one record #285

gaubert opened this issue Jan 11, 2019 · 3 comments

Comments

@gaubert
Copy link

gaubert commented Jan 11, 2019

Is there a way to stream some content in a unique record.
I am using logbook in a project for great benefit, thanks.
In this project, we are spawning bash script processes and getting the stdout/sderr logs of those processes.
At the moment we are keeping all stdout/stderr lines in a string buffer (StringIO) and then dumping everyting in a log book record at the end of the process execution. This is fine but some processes are taking several minutes and during that time, I am blind as I have based all the logging on logbook.
Is there a simple way to get the corresponding logbook string buffer in that case and continue writing in the file ?
Indeed to avoid poluting the reporting, we would like to have all the script outputs contained in one record ?

So to sum up I would in particular case to write within the same record with multiple write message call and not a unique one as it is currently available. Is it possible with a bit of development. Is there an example ?

Many thanks in advance.

@vmalloc
Copy link
Collaborator

vmalloc commented Jan 11, 2019

Assuming your output is line-based, the right thing to do is emit the lines one-by-one, but that would make the log slightly harder to read. Another option is to separate that output to a separate log file

@gaubert
Copy link
Author

gaubert commented Jan 13, 2019

Yes it is line base by I do not want to have a date and message type for each line. I would like to also avoid using another file if possble. is there a way to have access to the string buffer of logbook and write into it ? Then when ready call a method to release and write the message in the log file with just one date ?
If not I will continue doing as I do now, buffering everything and write all the lines in one logbook message at the end once the process has exited.

Thanks

@vmalloc
Copy link
Collaborator

vmalloc commented Jan 14, 2019

I don't fully understand what you're suggesting.... If you had access to the handler's internal stream you would be doing essentially the same thing - interleaving your output lines along with the "regular" log lines... Can you scribble a suggested API you have in mind?

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