~yerinalexey/pcrond

82dc2199e5ccefd5917f720c5426e560ccab3e5c — Alexey Yerin 5 months ago 7a7d0e8
fix: drop logging

It's doesn't work for some reason, so it has to go
1 files changed, 0 insertions(+), 19 deletions(-)

M scripts/pcrond
M scripts/pcrond => scripts/pcrond +0 -19
@@ 1,10 1,6 @@
#!/usr/bin/env python

import logging

VERSION = "1.0"
logger = logging.getLogger()


def parse_args():
    import argparse


@@ 12,30 8,15 @@ def parse_args():
    parser.add_argument('-r', '--crontabfile',
                        help='the crontab file (default ~/.local/crontab)',
                        default='~/.local/crontab')
    parser.add_argument('-l', '--logfile',
                        help='the log file (default ~/.local/pcrond.log)',
                        default='~/.local/pcrond.log')
    parser.add_argument('-v', '--version', action='store_true', help='print version then exit')
    parser.add_argument('-x', '--debug', action='store_true', help='enable debug logging')
    args = parser.parse_args()
    return args


def setup_logger(args):             # HOPE this affects modules too
    logginglevel = logging.DEBUG if args.debug else logging.INFO
    handler = logging.handlers.RotatingFileHandler(filename=args.logfile,
                                                   level=logginglevel,
                                                   maxBytes=2000,
                                                   backupCount=10)
    logger.addHandler(handler)


if __name__ == "__main__":
    args = parse_args()
    if args.version:
        print(VERSION)
        exit(0)
    setup_logger(args)

    from pcrond import scheduler
    scheduler.load_crontab_file(args.crontabfile)