Skip to content
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 sonic-clear logging command #3151

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

matiAlfaro
Copy link
Contributor

###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
clear logging when no syslog files exist
clear logging when only syslog file exist
clear logging when syslog & syslog.1 files exits
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)

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

Signed-off-by: mati <mati@marvell.com>
Signed-off-by: mati <mati@marvell.com>
@matiAlfaro matiAlfaro changed the title Add sonic clear command Add sonic-clear logging command Feb 4, 2024
Signed-off-by: mati <mati@marvell.com>
@matiAlfaro
Copy link
Contributor Author

@mihirpat1 would you be able to review?

@mihirpat1 mihirpat1 requested a review from prgeor February 7, 2024 08:29
@cli.command()
def logging(all):
"""Clear logging files"""
if os.path.exists("/var/log.tmpfs"):
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we not plan to delete existing logs in /var/log/ if both the directories /var/log/ and /var/log.tmpfs/ have syslogs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, thanks.

Signed-off-by: matiAlfaro <mati@marvell.com>
clear/main.py Outdated
@cli.command()
def logging(all):
"""Clear logging files"""
log_path_arr = ["/var/log"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we put a check here to ensure /var/log directory exists before setting log_path_arr?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Signed-off-by: matiAlfaro <mati@marvell.com>
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.

3 participants