forked from Mirror/frr
Merge pull request #15471 from opensourcerouting/frrreload_logfile
tools: Add option to frr-reload to specify alternate logfile
This commit is contained in:
commit
1ef4f19009
|
@ -25,6 +25,8 @@ There are several options that control the behavior of ``frr-reload``:
|
||||||
* ``--stdout``: print output to stdout
|
* ``--stdout``: print output to stdout
|
||||||
* ``--bindir BINDIR``: path to the vtysh executable
|
* ``--bindir BINDIR``: path to the vtysh executable
|
||||||
* ``--confdir CONFDIR``: path to the existing daemon config files
|
* ``--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
|
* ``--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
|
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
|
* ``--daemon DAEMON``: by default ``frr-reload.py`` assumes that we are using
|
||||||
|
|
|
@ -2113,12 +2113,17 @@ if __name__ == "__main__":
|
||||||
help="Use logfmt as log format",
|
help="Use logfmt as log format",
|
||||||
default=False,
|
default=False,
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--logfile",
|
||||||
|
help="logfile for frr-reload",
|
||||||
|
default="/var/log/frr/frr-reload.log",
|
||||||
|
)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
# For --test log to stdout
|
# 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 --logfmt, use the logfmt format
|
# If --logfmt, use the logfmt format
|
||||||
formatter = logging.Formatter("%(asctime)s %(levelname)5s: %(message)s")
|
formatter = logging.Formatter("%(asctime)s %(levelname)5s: %(message)s")
|
||||||
handler = logging.StreamHandler()
|
handler = logging.StreamHandler()
|
||||||
|
@ -2133,9 +2138,9 @@ if __name__ == "__main__":
|
||||||
logging.WARNING, "\033[91m%s\033[0m" % logging.getLevelName(logging.WARNING)
|
logging.WARNING, "\033[91m%s\033[0m" % logging.getLevelName(logging.WARNING)
|
||||||
)
|
)
|
||||||
if args.reload:
|
if args.reload:
|
||||||
if not os.path.isdir("/var/log/frr/"):
|
if not os.path.isdir(os.path.dirname(args.logfile)):
|
||||||
os.makedirs("/var/log/frr/", mode=0o0755)
|
os.makedirs(os.path.dirname(args.logfile), mode=0o0755)
|
||||||
handler = logging.FileHandler("/var/log/frr/frr-reload.log")
|
handler = logging.FileHandler(args.logfile)
|
||||||
if args.stdout:
|
if args.stdout:
|
||||||
handler = logging.StreamHandler(sys.stdout)
|
handler = logging.StreamHandler(sys.stdout)
|
||||||
handler.setFormatter(formatter)
|
handler.setFormatter(formatter)
|
||||||
|
|
Loading…
Reference in a new issue