-
Notifications
You must be signed in to change notification settings - Fork 66
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
Add logger rotation for python services #1512
Add logger rotation for python services #1512
Conversation
bd747b8
to
75e9d29
Compare
It does not zip logs from the camera manager since the extension is a date and not a .log file, we should fix on the camera manager, but for everything else it's working. |
core/services/log_zipper/main.py
Outdated
for file in files: | ||
try: | ||
os.remove(file) | ||
logger.debug(f"Deleted file: {file}") | ||
except OSError as e: | ||
logger.debug(f"Error deleting file: {file} - {e}") |
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.
As I said in the other PR, we should check if the file is opened (by some other service) before removing it, otherwise, we would lose all the next log lines until the service creates another log file.
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.
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.
Yeah, I'm not sure why your code is not working, makes sense to me. My only concern is if using attrs
parameter to create the info
dict is populating correctly the open_files
. Have you tried calling Process.open_files()
instead? I believe it might skip some processes when an exception happens when it tries to access the process information, and by calling Process.open_files()
you'd get the exception.
As an alternative, from the terminal it's usually done with lsof <filename>
, maybe you could just call it from Python and check its return?
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.
Can we use delete_everything here instead of os.remove?
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.
@joaoantoniocardoso check the latest version
68f334a
to
927ab66
Compare
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.
Now I can't click on 'remove' 👀
Remove is disabled if the size is under 100MB. |
Makes sense. I'll let it run for a while here to see the rotation. Anything specific you want me to pay attention to? |
Keep in mind that the PR is zipping things in a higher frequency to help with the test. |
setuptools.setup( | ||
name="log_zipper", | ||
version="0.1.0", | ||
description="logrotate but better", |
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.
that's a bold statement isn't it 😆
try: | ||
logger.add(get_new_log_path(SERVICE_NAME)) | ||
init_logger(SERVICE_NAME) | ||
except Exception as e: | ||
print(f"unable to set logging path: {e}") |
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.
If the logger can fail, we should check everywhere if we want the services to be prevented or not running without logs.
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.
If the logger can fail, we should check everywhere if we want the services to be prevented or not running without logs.
That's not related to this PR.
927ab66
to
78f520b
Compare
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.
78f520b
to
9a89dbf
Compare
…minutes Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
9a89dbf
to
86f6531
Compare
@ES-Alexander where should this be documented ? |
What's the most relevant UI element?
I feel like the behaviour change is most noticeable in the file browser, so maybe we should
I'm unsure whether it's relevant to change the Available Services docs, and it's also possible we want to rename the Log Browser section to Autopilot Log Browser, or at least clarify the text in it to make it explicit that that's for autopilot logs, not BlueOS service logs. |
I'd vote to change to |
@joaoantoniocardoso fair enough - I also think it would be helpful to clarify, although on reflection it might be preferable to have a shorter name like "Autopilot Logs" instead. Regardless, the documentation follows the implementation, so this is a BlueOS issue. Maybe we can discuss preferences in the next BlueOS meeting :-) We could also consider having separated "Autopilot" and "BlueOS" sections in the menu-bar :-P |
"Flight logs" maybe?
…On Sun, Mar 12, 2023, 01:08 ES-Alexander ***@***.***> wrote:
I'd vote to change to Autopilot Log Browser as I've found myself entering
the wrong page a few times when searching for our services logs. 😆
@joaoantoniocardoso <https://github.com/joaoantoniocardoso> fair enough -
I also think it would be helpful to clarify, although on reflection it
might be preferable to have a shorter name like "Autopilot Logs" instead.
Regardless, the documentation follows the implementation, so this is a
BlueOS issue. Maybe we can discuss preferences in the next BlueOS meeting
:-)
We could also consider having separated "Autopilot" and "BlueOS" sections
in the menu-bar :-P
—
Reply to this email directly, view it on GitHub
<#1512 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA6T53H2ZYJ23BM4JIH5D5TW3VD4NANCNFSM6AAAAAAVEWUPZM>
.
You are receiving this because your review was requested.Message ID:
***@***.***>
|
No description provided.