Add `-c, --clear` argument for `log` and `log_distccd` actions to clear log files (#344)

This commit is contained in:
drebrez 2017-08-07 20:56:35 +02:00 committed by Oliver Smith
parent 6a129669a3
commit 257666799e
2 changed files with 8 additions and 5 deletions

View File

@ -124,12 +124,16 @@ def stats(args):
def log(args):
if args.clear_log:
pmb.helpers.run.user(args, ["truncate", "-s", "0", args.log], log=False)
pmb.helpers.run.user(args, ["tail", "-f", args.log, "-n", args.lines],
log=False)
def log_distccd(args):
logpath = "/home/user/distccd.log"
if args.clear_log:
pmb.chroot.user(args, ["truncate", "-s", "0", logpath], log=False)
pmb.chroot.user(args, ["tail", "-f", logpath, "-n", args.lines], log=False)

View File

@ -134,11 +134,10 @@ def arguments():
"log_distccd",
help="follow the distccd logfile")
for action in [log, log_distccd]:
action.add_argument(
"-n",
"--lines",
default="30",
help="count of initial output lines")
action.add_argument("-n", "--lines", default="30",
help="count of initial output lines")
action.add_argument("-c", "--clear", help="clear the log",
action="store_true", dest="clear_log")
# Action: zap
zap = sub.add_parser("zap", help="safely delete chroot folders")