-
Notifications
You must be signed in to change notification settings - Fork 182
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
Logger #228
Logger #228
Conversation
New documentation for the proposed stdlib_logger.f90 module. The documentation differs in style from that of the other modules in the following ways: 1. I thought it benefitted from an introduction giving an overview of the module 2. It has a section describing the constants used as error codes with a table summarizing the constants. The other modules do not appear to have significant public constants 3. It has a section summarizing the derived type. The other modules do not define a public derived type. 4. It has a section describing the `global_logger` variable. The other modules do not define a public variable. 5. It has a table summarizing the various procedures/methods in one place. I think using the module benefits from this summary 6. With the extra material the procedure/method description are one heading higher than in the other documentation. I don't think this is noticeable. 7. The "syntax" has the self argument at an awkward position. The other modules don't have the equivalent of the self argument, and I couldn't see another place to logically put it. 8. The "syntax" follows the standard in using a single pair of square brackets to delimit a run of optional arguments, rather than the other document's use of a pair of square brackets for each optional argument. This is easily changed. 9. The document follows the standard in identifying the class of each procedure. 10. I follow the standard in describing the intent of each argument. The other documentation omits that. This is easily changed. 11. I am wordier than the other documenters. This is hard to change. 12. I ended up upper casing only specifiers that are character strings. I can lower case those, upper case other specifiers or Fortran keywords easily. I just need specific guidance on how to upper/lower case.
The source code for the stdlib_logger.f90 module. It defines one derived type, several constants and procedures/methods to implement loggers, and one variable intended to serve as a global logger.
The test code is quite a bit of a mess. The procedures add_log_file, add_log_unit, and remove_log_unit have failure modes that are modified with a `stat` argument, and need to be tested to be sure the codes do not wrongly add/remove a unit when the stat argument is not success, and ensure that the stat stat argument returns the correct error code. Any suggestions you have to improve it would be appreciated.
These won't overwrite existing files
Great, thanks William, I will review it. |
Thank you @wclodius2 for this PR. I will review it this weekend |
Two reviewers will be great.
… On Sep 3, 2020, at 1:04 PM, Jeremie Vandenplas ***@***.***> wrote:
Thank you @wclodius2 <https://github.com/wclodius2> for this PR. I will review it this weekend
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#228 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/APTQDOTEVLEKXSRSLZKKIELSD7SFRANCNFSM4QSNH5WA>.
|
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.
Thank you @wclodius2 for this PR. I reviewed the specs, and I like this proposition for a logger. I added several comments. Some of them could be applied at other parts of the specs.
I will review the rest later.
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.
Here are some additional comments
It was indeed to be more explicit, but also to follow the same logic as for
the declaration of variables inside the derived type (private default), and
of the module (private default too).
Le dim. 6 sept. 2020 à 22:39, Milan Curcic <[email protected]> a
écrit :
… ***@***.**** commented on this pull request.
------------------------------
In src/stdlib_logger.f90
<#228 (comment)>:
> +! procedure, pass(self) :: assert
+ procedure, pass(self) :: add_log_file
+ procedure, pass(self) :: add_log_unit
+ procedure, pass(self) :: configuration
+ procedure, pass(self) :: configure
+ procedure, pass(self) :: log_error
+ procedure, pass(self) :: log_information
+ procedure, pass(self) :: log_io_error
+ procedure, pass(self) :: log_message
+ procedure, pass(self) :: log_text_error
+ procedure, pass(self) :: log_units_assigned
+ procedure, pass(self) :: log_warning
+ procedure, pass(self) :: remove_log_unit
I don't think this change is needed. Type-bound methods are public by
default unless explicitly set to private, right? Unless that with this
change you aim to be more explicit.
—
You are receiving this because your review was requested.
Reply to this email directly, view it on GitHub
<#228 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AD5RO7H2Y4U25BP64TBWS3LSEPXQDANCNFSM4QSNH5WA>
.
|
You're right, we should be consistent. Your suggested change is fine with me. |
Co-authored-by: Jeremie Vandenplas <[email protected]>
Co-authored-by: Jeremie Vandenplas <[email protected]>
Co-authored-by: Jeremie Vandenplas <[email protected]>
Co-authored-by: Jeremie Vandenplas <[email protected]>
Co-authored-by: Jeremie Vandenplas <[email protected]>
Co-authored-by: Jeremie Vandenplas <[email protected]>
Co-authored-by: Jeremie Vandenplas <[email protected]>
Co-authored-by: Jeremie Vandenplas <[email protected]>
Co-authored-by: Jeremie Vandenplas <[email protected]>
Co-authored-by: Jeremie Vandenplas <[email protected]>
Co-authored-by: Jeremie Vandenplas <[email protected]>
Co-authored-by: Jeremie Vandenplas <[email protected]>
Co-authored-by: Jeremie Vandenplas <[email protected]>
Co-authored-by: Jeremie Vandenplas <[email protected]>
Co-authored-by: Jeremie Vandenplas <[email protected]>
Co-authored-by: Jeremie Vandenplas <[email protected]>
I think I have committed all outstanding suggestions by @jvdp1 (Thank you!). Considering the size of this PR and small number of reviewers, let's leave it open for another week or so before merging. |
I agree. I think it would be good to discuss it during the next monthly call. |
I have needed a breather, and you two have also put in a lot of useful work. One additional change I have thought of doing is to add an optional |
This could solve indeed some potential issues with parallel programming. This proposition would be more robust IMO. |
Made the error code name consistent with that used for my bitsets and error_codes modules, where for ease of lookup I put what is invalid before the invalid.
If there are no objections, I'll merge this tomorrow into master. If anybody would like more time to review, just write here. |
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.
Here is my review:
-
Overall I am fine with merging as is.
-
This is what I would consider a high level API. If there is demand, we can provide a low level API that does not use a derived type, thus passing all configuration as arguments. In this case such low level API might not be as useful.
-
Does this design allow to extend it in the future to write all logs into a string? That would be helpful for things like interactive usage in a Jupyter notebook, to send all logs over it it from the kernel.
-
I don't have an opinion on the more general issue of: unlike some of the other functionality in
stdlib
, such as statistics, linear algebra, special functions etc. where there is a lot of prior art (in scipy, matlab, etc.) regarding their API, this logger API is in some sense designed in this PR. As such, it is not clear this is the best design, and it doesn't have usage yet. Down the road, for such new APIs, it might make sense to implement them as fpm packages first. And only later "standardize" in stdlib. However, at the same time, this logger API is experimental. So I think there is no harm including it also, with the understanding that the API might change in the future as we gain experience using it.
Answering each of the points;
* Good
* I have trouble seeing the usefulness of a low level API, for a logger. FWIW the loggers in FLIBS, Futility, SLATEC, and Python are all higher level than what you describe.
* I have trouble interpreting “write all logs into a string”. What functionality do you see over redirecting standard output?
- Do you mean all logs into a single string? With Fortran’s concatenation semantics that can be O(N**2), though with growable strings doubling when necessary, I guess that could be O(N ln N).
- Do you mean each log command into its own string? Easily do able, but I don’t see the use.
- Do you mean each log to a list of strings, to be concatenated on demand?
* FWIW Python,,does have a logger, https://docs.python.org/3/library/logging.html <https://docs.python.org/3/library/logging.html>. It is impractical to do its “child” hierarchy in Fortran. we could add the option of turning off output depending on the error level: error > warning > info.
… On Sep 28, 2020, at 10:04 AM, Ondřej Čertík ***@***.***> wrote:
@certik approved this pull request.
Here is my review:
Overall I am fine with merging as is.
This is what I would consider a high level API. If there is demand, we can provide a low level API that does not use a derived type, thus passing all configuration as arguments. In this case such low level API might not be as useful.
Does this design allow to extend it in the future to write all logs into a string? That would be helpful for things like interactive usage in a Jupyter notebook, to send all logs over it it from the kernel.
I don't have an opinion on the more general issue of: unlike some of the other functionality in stdlib, such as statistics, linear algebra, special functions etc. where there is a lot of prior art (in scipy, matlab, etc.) regarding their API, this logger API is in some sense designed in this PR. As such, it is not clear this is the best design, and it doesn't have usage yet. Down the road, for such new APIs, it might make sense to implement them as fpm packages first. And only later "standardize" in stdlib. However, at the same time, this logger API is experimental. So I think there is no harm including it also, with the understanding that the API might change in the future as we gain experience using it.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub <#228 (review)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/APTQDOVABFA7ICC5ZRO7NU3SICX2NANCNFSM4QSNH5WA>.
|
I agree a lower level API might not be useful. Regarding saving to a string, Python has a concept of Handlers: https://docs.python.org/3/howto/logging.html#useful-handlers, which allow to specify where the log messages are being written. You might decide to send them over a network, or do something else with them, and use standard output separately. So you cannot just redirect a standard output. The best interface would be to provide a user call back every time a message is written. That way users can overwrite this and do whatever they want. |
What could be done for "handlers" is define for the
or define an array of class handler with a method
|
Merging, thank you all and especially @wclodius2! |
The main files to focus on are src/stdlib_logger.f90, src/tests/logger/test_stdlib_logger.f90, and doc/specs/stdlib_logger.md. I have also updated the CMakeLists.txt, and Makefile.manual so they should compile with this branch, but my original testing was with a download of the current main branch and not this older one. Note I had some problems with the other source code when compiled with a couple years old version of ifort, but no problems with gfortran.