Skip to content

Add Command sonic-clear logging #1

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

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
Draft

Conversation

matiAlfaro
Copy link

@matiAlfaro matiAlfaro commented Jan 29, 2024

What I did

Added command
sonic-clear logging - delete syslog & syslog.1
sonic-clear logging -a/--all - delete syslog* files

How I did it

Equivalent to "show logging" command, working on files at /var/log or at /var/log.tmpfs
delete relevant syslog* files

How to verify it

  1. clear logging when no syslog files exist
  2. clear logging when only syslog file exist
  3. clear logging when syslog & syslog.1 files exits
  4. clear logging when syslog, syslog.1 and syslog2.gz files exits

Repeat 1-4 with
Clear logging --all

verify also that show logging behave correctly after clear

Previous command output (if the output of a command-line utility has changed)

NR

New command output (if the output of a command-line utility has changed)

none

@shiraez
Copy link

shiraez commented Jan 29, 2024

Looks good,
But it can be problematic if this PR merges:
sonic-net#3132

@matiAlfaro
Copy link
Author

I think that one is already part of master, I'll have another look.
Was also thinking to clear the files instead of deleting them

@VladimirKuk
Copy link

  1. There are /var/log/syslog.X directories (where X is running number) which also contain some older log files.
  2. Also, maybe we should add age parameter to delete "older than" files instead of deleting all of them.

@shiraez
Copy link

shiraez commented Jan 30, 2024

BTW it looks like they added a test to the show logging

@amazor
Copy link

amazor commented Feb 1, 2024

What Python version is used in SONiC?

Signed-off-by: mati <[email protected]>
@matiAlfaro
Copy link
Author

What Python version is used in SONiC?

Not sure if correct for all platform/builds, but VS (master) runs 3.11.2
RD-AC5X (master) runs 3.9.2

Fixed Problems/New Changes:
change format syntax to new form
use glob only where needed

Should be Tested:

~

Signed-off-by: mati <[email protected]>
@matiAlfaro matiAlfaro requested a review from amazor February 1, 2024 12:16
Signed-off-by: mati <[email protected]>
Copy link

@amazor amazor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me

@matiAlfaro
Copy link
Author

BTW it looks like they added a test to the show logging

don't know if needed, don't think it's worth the effort, but if mandatory ...

@matiAlfaro matiAlfaro marked this pull request as draft February 15, 2024 07:24
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

Successfully merging this pull request may close these issues.

4 participants