示例#1
0
文件: args.py 项目: tuxxon/gitfs
    def check_args(self, args):
        # check allow_other and allow_root
        if args.allow_other:
            args.allow_root = False
        else:
            args.allow_root = True

        # check log_level
        if args.debug:
            args.log_level = "debug"

        # setup logging
        if args.log != "syslog":
            if args.log in ("-", "/dev/stdout"):
                handler = StreamHandler(sys.stdout)
            else:
                handler = TimedRotatingFileHandler(args.log, when="midnight")
            handler.setFormatter(
                Formatter(
                    fmt="%(asctime)s %(threadName)s: "
                    "%(message)s",
                    datefmt="%B-%d-%Y %H:%M:%S",
                ))
        else:
            if sys.platform == "darwin":
                handler = SysLogHandler(address="/var/run/syslog")
            else:
                handler = SysLogHandler(address="/dev/log")
            logger_fmt = (
                "GitFS on {mount_point} [%(process)d]: %(threadName)s: "
                "%(message)s".format(mount_point=args.mount_point))
            handler.setFormatter(Formatter(fmt=logger_fmt))

        if args.sentry_dsn != "":
            from raven.conf import setup_logging
            from raven.handlers.logging import SentryHandler

            sentry_handler = SentryHandler(
                args.sentry_dsn,
                tags={
                    "owner": args.user,
                    "remote": args.remote_url,
                    "mountpoint": args.mount_point,
                },
            )
            sentry_handler.setLevel("ERROR")
            setup_logging(sentry_handler)
            log.addHandler(sentry_handler)

        handler.setLevel(args.log_level.upper())
        log.setLevel(args.log_level.upper())
        log.addHandler(handler)

        # set cache size
        lru_cache.maxsize = args.cache_size

        # return absolute repository's path
        args.repo_path = os.path.abspath(args.repo_path)

        return args
示例#2
0
    def check_args(self, args):
        # check allow_other and allow_root
        if args.allow_other:
            args.allow_root = False
        else:
            args.allow_root = True

        # check log_level
        if args.debug:
            args.log_level = 'debug'

        # setup logging
        if args.log != "syslog":
            if args.log in ('-', '/dev/stdout'):
                handler = StreamHandler(sys.stdout)
            else:
                handler = TimedRotatingFileHandler(args.log, when="midnight")
            handler.setFormatter(
                Formatter(fmt='%(asctime)s %(threadName)s: '
                          '%(message)s',
                          datefmt='%B-%d-%Y %H:%M:%S'))
        else:
            if sys.platform == 'darwin':
                handler = SysLogHandler(address="/var/run/syslog")
            else:
                handler = SysLogHandler(address="/dev/log")
            logger_fmt = 'GitFS on {mount_point} [%(process)d]: %(threadName)s: '\
                         '%(message)s'.format(mount_point=args.mount_point)
            handler.setFormatter(Formatter(fmt=logger_fmt))

        if args.sentry_dsn != '':
            from raven.conf import setup_logging
            from raven.handlers.logging import SentryHandler

            sentry_handler = SentryHandler(args.sentry_dsn)
            sentry_handler.setLevel("ERROR")
            setup_logging(sentry_handler)
            log.addHandler(sentry_handler)

        handler.setLevel(args.log_level.upper())
        log.setLevel(args.log_level.upper())
        log.addHandler(handler)

        # set cache size
        lru_cache.maxsize = args.cache_size

        # return absolute repository's path
        args.repo_path = os.path.abspath(args.repo_path)

        return args
示例#3
0
文件: args.py 项目: Marius786/gitfs
    def check_args(self, args):
        # check allow_other and allow_root
        if args.allow_other:
            args.allow_root = False
        else:
            args.allow_root = True

        # check log_level
        if args.debug:
            args.log_level = 'debug'

        # setup logging
        if args.log != "syslog":
            if args.log in ('-', '/dev/stdout'):
                handler = StreamHandler(sys.stdout)
            else:
                handler = TimedRotatingFileHandler(args.log, when="midnight")
            handler.setFormatter(Formatter(fmt='%(asctime)s %(threadName)s: '
                                           '%(message)s',
                                           datefmt='%B-%d-%Y %H:%M:%S'))
        else:
            if sys.platform == 'darwin':
                handler = SysLogHandler(address="/var/run/syslog")
            else:
                handler = SysLogHandler(address="/dev/log")
            logger_fmt = 'GitFS on {mount_point} [%(process)d]: %(threadName)s: '\
                         '%(message)s'.format(mount_point=args.mount_point)
            handler.setFormatter(Formatter(fmt=logger_fmt))

        if args.sentry_dsn != '':
            from raven.conf import setup_logging
            from raven.handlers.logging import SentryHandler

            sentry_handler = SentryHandler(args.sentry_dsn)
            sentry_handler.setLevel("ERROR")
            setup_logging(sentry_handler)
            log.addHandler(sentry_handler)

        handler.setLevel(args.log_level.upper())
        log.setLevel(args.log_level.upper())
        log.addHandler(handler)

        # set cache size
        lru_cache.maxsize = args.cache_size

        # return absolute repository's path
        args.repo_path = os.path.abspath(args.repo_path)

        return args