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

tools: Add option to frr-reload to specify alternate logfile #15471

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/user/frr-reload.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ There are several options that control the behavior of ``frr-reload``:
* ``--stdout``: print output to stdout
* ``--bindir BINDIR``: path to the vtysh executable
* ``--confdir CONFDIR``: path to the existing daemon config files
* ``--logfile FILENAME``: file (with path) to logfile for the reload operation.
Default is ``/var/log/frr/frr-reload.log``
* ``--rundir RUNDIR``: path to a folder to be used to write the temporary files
needed by the script to do its job. The script should have write access to it
* ``--daemon DAEMON``: by default ``frr-reload.py`` assumes that we are using
Expand Down
14 changes: 10 additions & 4 deletions tools/frr-reload.py
Original file line number Diff line number Diff line change
Expand Up @@ -1904,11 +1904,17 @@ def compare_context_objects(newconf, running):
help="Used by topotest to not delete debug or log file commands",
)

parser.add_argument(
"--logfile",
help="logfile for frr-reload",
default="/var/log/frr/frr-reload.log",
)

args = parser.parse_args()

# Logging
# For --test log to stdout
# For --reload log to /var/log/frr/frr-reload.log
# For --reload log to --logfile (default: "/var/log/frr/frr-reload.log")
if args.test or args.stdout:
logging.basicConfig(format="%(asctime)s %(levelname)5s: %(message)s")

Expand All @@ -1921,11 +1927,11 @@ def compare_context_objects(newconf, running):
)

elif args.reload:
if not os.path.isdir("/var/log/frr/"):
os.makedirs("/var/log/frr/", mode=0o0755)
if not os.path.isdir(os.path.dirname(args.logfile)):
Copy link
Contributor

Choose a reason for hiding this comment

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

Please update the comment at the top of the block to read

# For --reload log to --logfile (default: "/var/log/frr/frr-reload.log")

Copy link
Member Author

Choose a reason for hiding this comment

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

done

os.makedirs(os.path.dirname(args.logfile), mode=0o0755)

logging.basicConfig(
filename="/var/log/frr/frr-reload.log",
filename=args.logfile,
format="%(asctime)s %(levelname)5s: %(message)s",
)

Expand Down
Loading