-
Notifications
You must be signed in to change notification settings - Fork 192
Logger: support of new_line() in the output of the logger #243
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
Conversation
I add @wclodius2 as a reviewer |
All changes can be found here. I am not sure to understand what was your approach. Sorry. My idea was to lead the logger writes something like:
with call global%log_error('Possible reasons'//new_line('a')//'1) first reason'//new_line('a')//'2) second reason') Therefore, the user puts some formatting in the message. Was it your aim too? |
Here is an additional example of what should be nice to achieve:
call global % log_message(&
'Example of an issue: the new_line() is considered as a character:' // &
new_line('a')// &
' -1) first bullet point: this is a long sentence on purpose. It should' // &
'be longer than 72 characters;'//new_line('a') // &
' -2) second bullet point' )
|
The output as shown looks very good. My one concern is what might happen if the output unit is asynchronous. In that case the output from different write statements to the same unit might become separated by writes from other parts of the code. This is not a new problem. It was inherent in my original approach. A way around that is to write the output initially to a single string, inserting |
This issue was indeed present before the proposed changes. Note that the
Nice proposition. I believe I finished my changes and it is ready for reviewers. I tested them in a real program with several scenarios, and I was satisfied with the output. Hopefully I covered all possible scenarios. |
Outside of the two minor comments, the code looks good to me. |
I will wait that other users review the proposed changes too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neat change, since length
must be less than max_width
already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay, I think this is an improvement, thank you!
Please merge if/when ready. |
Thanks for the final review. With 3 reviewers, I will now merge it. |
I used it mainly in one of our Fortran programs and was in overal pleased by this implementation.
@wclodius2 are you still interested in implementing such a proposition? ...some code...
call global%log_message('Initial value is: '//value2char(rdummy)
...some code...
call global%log_message('New value is: '//value2char(rdummy)
...some code... It would have been nice to have something like: ...some code...
call global%append_to_buffer_message('Initial value is: '//value2char(rdummy))
...some code...
call global%appent_to_buffer_message('New value is: '//value2char(rdummy))
...some code...
call global%log_message() !write he buffer to file unit(s), and initialise the buffer to'' This is probably further than your initial thoughs |
Yes it is further than my initial thoughts, which was to make the code thread/asynchronous IO "safe". I could do what you want as part of my rewrite, but what you are proposing has some ambiguities. In the appended strings what would you want done with date/time, module/procedure? What should be the formatting of the appended string? |
I would expect that date/time/module/procedure woud be initialized once when the string is still empty. Additional appended strings would not contain this information. It might be no sense, and could be considered later if others are interested. At this stage, I think it is more important to have a code thread/asynchronous IO safe. |
A proposition to support
new_line
properly when inserted in a message as, e.g.,: