Closed twip-os closed 11 months ago
@twip-os definitely a good feature. Here are some remarks.
log
? Thank you for this pull request.
I have to review a little bit more in detail, however I have similar questions than Johann and would like to briefly discuss them here:
itom.log
is ok, since it is contained in the itom module. However, wouldn't it be great if one could optionally add a logging category (info, warning, error among others)? This could either be done by a new enumeration or maybe by an optional string value. Check the method PyArg_ParseTupleAndKeywords
for a simpler parsing of mandatory and optional parameters, including a proper error message, if failed. Python cerr failures would then be added as category error
.log
by an alternative log=C:/mylogdir/logfile.txt
.Thank you for the answers.
I don't now if a logging category in the itom.lock method is required, since python errors and warnings are already captured and can be used for this purpose but if you think it is useful I can add it of course. The other question would be about categories in the log file. At the moment there are the qt categories (qDebug, qWarning...) and I added only a "Python" category since I thought that the format of the python errors sticks out very good already. But separate categories like e.g. "PyError", "PyWarning" and "PyInfo" could of course be added and would simplify searching for the category.
I checked out some other programs and they are logging automatically to the user directory (AppData/Local or AppData/Roaming on windows). This would be sufficient for our needs. My proposal would be:
Just another question / remark:
itom.log
is to close to the log-function as a logarithm, especially if itom is globally imported, like in the comand line / console? We had a similar conflict with the (old) itom.filter function (now itom.algorithms.xyz), that was in conflict with the built-in method filter. However, log
is not built-in, but only part of numpy, among others. An alternative could be itom.addLog
. Just a question?itom.log
is fine for me. I cust wanted to discuss it... As it is not a build-in method we can keep it like this. You may overwrite it by import from e.g. numpy, but that's same issue for all build-in methods which can bei overwritten...
I added the Copy Log method in the help section. I was not sure if it was necessary to use invoke to call the copyLog method but did it like it was done on methods in UiOrganizer. At the moment the copy is not performed if a file with the same name already exists in the target directory. Then a error message is displayed for the first file that could not be copied. Please tell me if this behaviour is OK or if you'd like to e.g. copy and replace without asking.
For me, the copy log behaviour is ok. Since there is almost no user interaction here, it would maybe make sense to show a simple message bar after a successful copy operation, that tells the user that all available log files of itom are properly copied to directory XY.
Furthermore, I checked our Windows system on our machines and it would be ok that log files are saved per default to something like C:\Users\<UserName>\AppData\Local\qitom
. Therefore, I would propose the following scheme:
What do you think about this?
By message bar you mean an information dialog with only an OK button or some message bar down on the window?
For me your proposed logging behavior would be good. I will implement it if no one complains.
OK, I implemented the command line arguments and logging to the user directory. I also updated the documentation for the command line arguments and the main window for the copy log function. If I got you right, you would like some more detailed documentation. Where should this be located?
I added the information of default logging in the getting started chapter. I think we can find some better or additional chapters to add such information and refering to the startup chapter?
Should we add a new chapter about logging describing new funtionalities?
besides the two spelling errors in the rst-anchor (see hint above), everything is super now. I just would say, that adding a small sub-section concerning the logging, especially the rotating files and the quota, could be added to the startup-and-arguments section. It is not the perfect place, however it is too small for a dedicated page. Therefore let it put there. Once, this is done, it would say that we can merge it. Thx again.
I finally found the time to write some lines about the logging process.
We at twip would love to have the ability to log everything to the same file. From cpp code, from python and also if we are only using the addInManager without the itom IDE. Also log rotation would be nice to log permanently without infinitely growing files.
I created a proposal of how this could be done here:
I tried to match the structure and style of the existing code but was not exactly sure where to put everything. Also I left out the copyright and definitions in the headers regarding the visual leak detector and qt mocs which I found in other headers because I was not sure how it would be right.
Please tell me if you also think that this would be a nice feature and if so, if any adaptions are needed.
Cheers Thomas