• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python fancylogger.setLogFormat函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中vsc.utils.fancylogger.setLogFormat函数的典型用法代码示例。如果您正苦于以下问题:Python setLogFormat函数的具体用法?Python setLogFormat怎么用?Python setLogFormat使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了setLogFormat函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_easybuilderror

    def test_easybuilderror(self):
        """Tests for EasyBuildError."""
        fd, tmplog = tempfile.mkstemp()
        os.close(fd)

        # set log format, for each regex searching
        setLogFormat("%(name)s :: %(message)s")

        # if no logger is available, and no logger is specified, use default 'root' fancylogger
        logToFile(tmplog, enable=True)
        self.assertErrorRegex(EasyBuildError, 'BOOM', raise_easybuilderror, 'BOOM')
        logToFile(tmplog, enable=False)

        log_re = re.compile("^%s ::.* BOOM \(at .*:[0-9]+ in [a-z_]+\)$" % getRootLoggerName(), re.M)
        logtxt = open(tmplog, 'r').read()
        self.assertTrue(log_re.match(logtxt), "%s matches %s" % (log_re.pattern, logtxt))

        # test formatting of message
        self.assertErrorRegex(EasyBuildError, 'BOOMBAF', raise_easybuilderror, 'BOOM%s', 'BAF')

        # a '%s' in a value used to template the error message should not print a traceback!
        self.mock_stderr(True)
        self.assertErrorRegex(EasyBuildError, 'err: msg: %s', raise_easybuilderror, "err: %s", "msg: %s")
        stderr = self.get_stderr()
        self.mock_stderr(False)
        # stderr should be *empty* (there should definitely not be a traceback)
        self.assertEqual(stderr, '')

        os.remove(tmplog)
开发者ID:cyiops,项目名称:easybuild-framework,代码行数:29,代码来源:build_log.py


示例2: test_loggedexception_defaultlogger

    def test_loggedexception_defaultlogger(self):
        """Test LoggedException custom exception class."""
        fd, tmplog = tempfile.mkstemp()
        os.close(fd)

        # set log format, for each regex searching
        setLogFormat("%(name)s :: %(message)s")

        # if no logger is available, and no logger is specified, use default 'root' fancylogger
        logToFile(tmplog, enable=True)
        self.assertErrorRegex(LoggedException, 'BOOM', raise_loggedexception, 'BOOM')
        logToFile(tmplog, enable=False)

        log_re = re.compile("^%s :: BOOM( \(at .*:[0-9]+ in raise_loggedexception\))?$" % getRootLoggerName(), re.M)
        logtxt = open(tmplog, 'r').read()
        self.assertTrue(log_re.match(logtxt), "%s matches %s" % (log_re.pattern, logtxt))

        # test formatting of message
        self.assertErrorRegex(LoggedException, 'BOOMBAF', raise_loggedexception, 'BOOM%s', 'BAF')

        # test log message that contains '%s' without any formatting arguments being passed
        # test formatting of message
        self.assertErrorRegex(LoggedException, "BOOM '%s'", raise_loggedexception, "BOOM '%s'")

        os.remove(tmplog)
开发者ID:brettbode,项目名称:vsc-base,代码行数:25,代码来源:exceptions.py


示例3: run

    def run(self, args):
        """Run 'create' subcommand."""
        optparser = CreateOptions(go_args=args, envvar_prefix=self.envvar_prefix, usage=self.usage_txt)
        options = optparser.options
        if not validate_pbs_option(options):
            sys.stderr.write('Missing config options. Exiting.\n')
            return 1

        label = options.label

        if not hc.validate_label(label, hc.known_cluster_labels()):
            sys.exit(1)

        if not hc.validate_hodconf_or_dist(options.hodconf, options.dist):
            sys.exit(1)

        try:
            j = PbsHodJob(optparser)
            hc.report_cluster_submission(label)
            j.run()
            jobs = j.state()
            hc.post_job_submission(label, jobs, optparser.options.workdir)
            return 0
        except StandardError as e:
            fancylogger.setLogFormat(fancylogger.TEST_LOGGING_FORMAT)
            fancylogger.logToScreen(enable=True)
            _log.raiseException(e.message)
开发者ID:ehiggs,项目名称:hanythingondemand,代码行数:27,代码来源:create.py


示例4: test_loggedexception_location

    def test_loggedexception_location(self):
        """Test inclusion of location information in log message for LoggedException."""

        class TestException(LoggedException):
            LOC_INFO_TOP_PKG_NAMES = None
            INCLUDE_LOCATION = True

        def raise_testexception(msg, *args, **kwargs):
            """Utility function: just raise a TestException."""
            raise TestException(msg, *args, **kwargs)

        fd, tmplog = tempfile.mkstemp()
        os.close(fd)

        # set log format, for each regex searching
        setLogFormat("%(name)s :: %(message)s")

        # no location with default LOC_INFO_TOP_PKG_NAMES ([])
        logToFile(tmplog, enable=True)
        self.assertErrorRegex(LoggedException, "BOOM", raise_testexception, "BOOM")
        logToFile(tmplog, enable=False)

        rootlogname = getRootLoggerName()

        log_re = re.compile("^%s :: BOOM$" % rootlogname, re.M)
        logtxt = open(tmplog, "r").read()
        self.assertTrue(log_re.match(logtxt), "%s matches %s" % (log_re.pattern, logtxt))

        f = open(tmplog, "w")
        f.write("")
        f.close()

        # location is included if LOC_INFO_TOP_PKG_NAMES is defined
        TestException.LOC_INFO_TOP_PKG_NAMES = ["vsc"]
        logToFile(tmplog, enable=True)
        self.assertErrorRegex(LoggedException, "BOOM", raise_testexception, "BOOM")
        logToFile(tmplog, enable=False)

        log_re = re.compile(r"^%s :: BOOM \(at vsc/utils/testing.py:[0-9]+ in assertErrorRegex\)$" % rootlogname)
        logtxt = open(tmplog, "r").read()
        self.assertTrue(log_re.match(logtxt), "%s matches %s" % (log_re.pattern, logtxt))

        f = open(tmplog, "w")
        f.write("")
        f.close()

        # absolute path of location is included if there's no match in LOC_INFO_TOP_PKG_NAMES
        TestException.LOC_INFO_TOP_PKG_NAMES = ["foobar"]
        logToFile(tmplog, enable=True)
        self.assertErrorRegex(LoggedException, "BOOM", raise_testexception, "BOOM")
        logToFile(tmplog, enable=False)

        log_re = re.compile(r"^%s :: BOOM \(at .*/vsc/utils/testing.py:[0-9]+ in assertErrorRegex\)$" % rootlogname)
        logtxt = open(tmplog, "r").read()
        self.assertTrue(log_re.match(logtxt), "%s matches %s" % (log_re.pattern, logtxt))

        os.remove(tmplog)
开发者ID:ocaisa,项目名称:vsc-base,代码行数:57,代码来源:exceptions.py


示例5: run

 def run(self, args):
     """Run 'clean' subcommand."""
     optparser = CleanOptions(go_args=args, envvar_prefix=self.envvar_prefix, usage=self.usage_txt)
     try:
         pbs = rm_pbs.Pbs(optparser)
         state = pbs.state()
         labels = hc.known_cluster_labels()
         rm_master = rm_pbs.master_hostname()
         info = hc.mk_cluster_info_dict(labels, state, master=rm_master)
         hc.clean_cluster_info(rm_master, info)
     except StandardError as err:
         fancylogger.setLogFormat(fancylogger.TEST_LOGGING_FORMAT)
         fancylogger.logToScreen(enable=True)
         _log.raiseException(err.message)
开发者ID:ehiggs,项目名称:hanythingondemand,代码行数:14,代码来源:clean.py


示例6: run

    def run(self, args):
        """Run 'batch' subcommand."""
        optparser = BatchOptions(go_args=args, envvar_prefix=self.envvar_prefix, usage=self.usage_txt)
        options = optparser.options
        if not validate_pbs_option(options):
            sys.stderr.write('Missing config options. Exiting.\n')
            return 1

        if optparser.options.script is None:
            sys.stderr.write('Missing script. Exiting.\n')
            return 1

        # resolve script path to absolute path
        optparser.options.script = os.path.abspath(optparser.options.script)

        if not os.path.exists(optparser.options.script):
            sys.stderr.write("Specified script does not exist: %s. Exiting.\n" % optparser.options.script)
            return 1

        # make sure script is executable
        cur_perms = os.stat(optparser.options.script)[stat.ST_MODE]
        if not (cur_perms & stat.S_IXUSR):
            print "Specified script %s is not executable yet, fixing that..." % optparser.options.script
            os.chmod(optparser.options.script, cur_perms|stat.S_IXUSR)

        label = options.label

        if not hc.validate_label(label, hc.known_cluster_labels()):
            sys.exit(1)

        if not hc.validate_hodconf_or_dist(options.hodconf, options.dist):
            sys.exit(1)

        try:
            j = PbsHodJob(optparser)
            hc.report_cluster_submission(label)
            j.run()
            jobs = j.state()
            hc.post_job_submission(label, jobs, optparser.options.workdir)
            return 0
        except StandardError as e:
            fancylogger.setLogFormat(fancylogger.TEST_LOGGING_FORMAT)
            fancylogger.logToScreen(enable=True)
            _log.raiseException(e.message)
开发者ID:ehiggs,项目名称:hanythingondemand,代码行数:44,代码来源:batch.py


示例7: test_log_levels

    def test_log_levels(self):
        """Test whether log levels are respected"""
        fd, tmplog = tempfile.mkstemp()
        os.close(fd)

        # set log format, for each regex searching
        setLogFormat("%(name)s [%(levelname)s] :: %(message)s")

        # test basic log methods
        logToFile(tmplog, enable=True)
        log = getLogger('test_easybuildlog')

        for level in ['ERROR', 'WARNING', 'INFO', 'DEBUG', 'DEVEL']:
            log.setLevelName(level)
            log.raiseError = False
            log.error('kaput')
            log.deprecated('almost kaput', '10000000000000')
            log.raiseError = True
            log.warn('this is a warning')
            log.info('fyi')
            log.debug('gdb')
            log.devel('tmi')

        logToFile(tmplog, enable=False)
        logtxt = read_file(tmplog)

        root = getRootLoggerName()

        devel_msg = r"%s.test_easybuildlog \[DEVEL\] :: tmi" % root
        debug_msg = r"%s.test_easybuildlog \[DEBUG\] :: gdb" % root
        info_msg = r"%s.test_easybuildlog \[INFO\] :: fyi" % root
        warning_msg = r"%s.test_easybuildlog \[WARNING\] :: this is a warning" % root
        deprecated_msg = r"%s.test_easybuildlog \[WARNING\] :: Deprecated functionality, .*: almost kaput; see .*" % root
        error_msg = r"%s.test_easybuildlog \[ERROR\] :: EasyBuild crashed with an error \(at .* in .*\): kaput" % root

        expected_logtxt = '\n'.join([
            error_msg,
            error_msg, deprecated_msg, warning_msg,
            error_msg, deprecated_msg, warning_msg, info_msg,
            error_msg, deprecated_msg, warning_msg, info_msg, debug_msg,
            error_msg, deprecated_msg, warning_msg, info_msg, debug_msg, devel_msg,
        ])
        logtxt_regex = re.compile(r'^%s' % expected_logtxt, re.M)
        self.assertTrue(logtxt_regex.search(logtxt), "Pattern '%s' found in %s" % (logtxt_regex.pattern, logtxt))
开发者ID:cyiops,项目名称:easybuild-framework,代码行数:44,代码来源:build_log.py


示例8: test_classname_in_log

    def test_classname_in_log(self):
        """Do a log and check if the classname is correctly in it"""
        _stderr = sys.stderr

        class Foobar:
            def somefunction(self):
                logger = fancylogger.getLogger(fname=True, clsname=True)
                logger.warn('we are logging something here')

        stringfile = StringIO()
        sys.stderr = stringfile
        handler = fancylogger.logToScreen()

        Foobar().somefunction()
        self.assertTrue('Foobar.somefunction' in stringfile.getvalue())
        stringfile.close()

        # restore
        fancylogger.logToScreen(enable=False, handler=handler)
        # and again
        stringfile = StringIO()
        sys.stderr = stringfile
        handler = fancylogger.logToScreen()
        classless_function()
        self.assertTrue('?.classless_function' in stringfile.getvalue())

        # restore
        fancylogger.logToScreen(enable=False, handler=handler)
        stringfile = StringIO()
        sys.stderr = stringfile

        fancylogger.setLogFormat("%(className)s blabla")
        handler = fancylogger.logToScreen()
        logger = fancylogger.getLogger(fname=False, clsname=False)
        logger.warn("blabla")
        print stringfile.getvalue()
        # this will only hold in debug mode, so also disable the test
        if __debug__:
            self.assertTrue('FancyLoggerTest' in stringfile.getvalue())
        # restore
        fancylogger.logToScreen(enable=False, handler=handler)
        sys.stderr = _stderr
开发者ID:Iepoev,项目名称:vsc-base,代码行数:42,代码来源:fancylogger.py


示例9: test_easybuilderror

    def test_easybuilderror(self):
        """Tests for EasyBuildError."""
        fd, tmplog = tempfile.mkstemp()
        os.close(fd)

        # set log format, for each regex searching
        setLogFormat("%(name)s :: %(message)s")

        # if no logger is available, and no logger is specified, use default 'root' fancylogger
        logToFile(tmplog, enable=True)
        self.assertErrorRegex(EasyBuildError, 'BOOM', raise_easybuilderror, 'BOOM')
        logToFile(tmplog, enable=False)

        log_re = re.compile("^%s :: BOOM \(at .*:[0-9]+ in [a-z_]+\)$" % getRootLoggerName(), re.M)
        logtxt = open(tmplog, 'r').read()
        self.assertTrue(log_re.match(logtxt), "%s matches %s" % (log_re.pattern, logtxt))

        # test formatting of message
        self.assertErrorRegex(EasyBuildError, 'BOOMBAF', raise_easybuilderror, 'BOOM%s', 'BAF')

        os.remove(tmplog)
开发者ID:dlagrava,项目名称:easybuild-framework,代码行数:21,代码来源:build_log.py


示例10: test_loggedexception_callerlogger

    def test_loggedexception_callerlogger(self):
        """Test LoggedException custom exception class."""
        fd, tmplog = tempfile.mkstemp()
        os.close(fd)

        # set log format, for each regex searching
        setLogFormat("%(name)s :: %(message)s")

        logger = getLogger('testlogger_local')

        # if no logger is specified, logger available in calling context should be used
        logToFile(tmplog, enable=True)
        self.assertErrorRegex(LoggedException, 'BOOM', raise_loggedexception, 'BOOM')
        logToFile(tmplog, enable=False)

        rootlog = getRootLoggerName()
        log_re = re.compile("^%s(.testlogger_local)? :: BOOM( \(at .*:[0-9]+ in raise_loggedexception\))?$" % rootlog)
        logtxt = open(tmplog, 'r').read()
        self.assertTrue(log_re.match(logtxt), "%s matches %s" % (log_re.pattern, logtxt))

        os.remove(tmplog)
开发者ID:brettbode,项目名称:vsc-base,代码行数:21,代码来源:exceptions.py


示例11: test_loggedexception_specifiedlogger

    def test_loggedexception_specifiedlogger(self):
        """Test LoggedException custom exception class."""
        fd, tmplog = tempfile.mkstemp()
        os.close(fd)

        # set log format, for each regex searching
        setLogFormat("%(name)s :: %(message)s")

        logger1 = getLogger('testlogger_one')
        logger2 = getLogger('testlogger_two')

        # if logger is specified, it should be used
        logToFile(tmplog, enable=True)
        self.assertErrorRegex(LoggedException, 'BOOM', raise_loggedexception, 'BOOM', logger=logger1)
        logToFile(tmplog, enable=False)

        rootlog = getRootLoggerName()
        log_re = re.compile("^%s.testlogger_one :: BOOM \(at .*:[0-9]+ in raise_loggedexception\)$" % rootlog, re.M)
        logtxt = open(tmplog, 'r').read()
        self.assertTrue(log_re.match(logtxt), "%s matches %s" % (log_re.pattern, logtxt))

        os.remove(tmplog)
开发者ID:Goggin,项目名称:vsc-base,代码行数:22,代码来源:exceptions.py


示例12: _log_and_raise

 def _log_and_raise(self, err):
     """Report error that occured, and raise Exception"""
     fancylogger.setLogFormat(fancylogger.TEST_LOGGING_FORMAT)
     fancylogger.logToScreen(enable=True)
     self.log.raiseException(str(err))
开发者ID:boegel,项目名称:hanythingondemand,代码行数:5,代码来源:subcommand.py


示例13: test_easybuildlog

    def test_easybuildlog(self):
        """Tests for EasyBuildLog."""
        fd, tmplog = tempfile.mkstemp()
        os.close(fd)

        # set log format, for each regex searching
        setLogFormat("%(name)s [%(levelname)s] :: %(message)s")

        # test basic log methods
        logToFile(tmplog, enable=True)
        log = getLogger('test_easybuildlog')
        log.setLevelName('DEBUG')
        log.debug("123 debug")
        log.info("foobar info")
        log.warn("justawarning")
        log.raiseError = False
        log.error("kaput")
        log.raiseError = True
        try:
            log.exception("oops")
        except EasyBuildError:
            pass
        logToFile(tmplog, enable=False)
        logtxt = read_file(tmplog)

        root = getRootLoggerName()

        expected_logtxt = '\n'.join([
            r"%s.test_easybuildlog \[DEBUG\] :: 123 debug" % root,
            r"%s.test_easybuildlog \[INFO\] :: foobar info" % root,
            r"%s.test_easybuildlog \[WARNING\] :: justawarning" % root,
            r"%s.test_easybuildlog \[ERROR\] :: EasyBuild crashed with an error \(at .* in .*\): kaput" % root,
            r"%s.test_easybuildlog \[ERROR\] :: .*EasyBuild encountered an exception \(at .* in .*\): oops" % root,
            '',
        ])
        logtxt_regex = re.compile(r'^%s' % expected_logtxt, re.M)
        self.assertTrue(logtxt_regex.search(logtxt), "Pattern '%s' found in %s" % (logtxt_regex.pattern, logtxt))

        # wipe log so we can reuse it
        write_file(tmplog, '')

        # test formatting log messages by providing extra arguments
        logToFile(tmplog, enable=True)
        log.warn("%s", "bleh"),
        log.info("%s+%s = %d", '4', '2', 42)
        args = ['this', 'is', 'just', 'a', 'test']
        log.debug("%s %s %s %s %s", *args)
        log.raiseError = False
        log.error("foo %s baz", 'baz')
        log.raiseError = True
        logToFile(tmplog, enable=False)
        logtxt = read_file(tmplog)
        expected_logtxt = '\n'.join([
            r"%s.test_easybuildlog \[WARNING\] :: bleh" % root,
            r"%s.test_easybuildlog \[INFO\] :: 4\+2 = 42" % root,
            r"%s.test_easybuildlog \[DEBUG\] :: this is just a test" % root,
            r"%s.test_easybuildlog \[ERROR\] :: EasyBuild crashed with an error \(at .* in .*\): foo baz baz" % root,
            '',
        ])
        logtxt_regex = re.compile(r'^%s' % expected_logtxt, re.M)
        self.assertTrue(logtxt_regex.search(logtxt), "Pattern '%s' found in %s" % (logtxt_regex.pattern, logtxt))

        # test deprecated behaviour: raise EasyBuildError on log.error and log.exception
        os.environ['EASYBUILD_DEPRECATED'] = '2.1'
        init_config()

        log.warning("No raise for warnings")
        self.assertErrorRegex(EasyBuildError, 'EasyBuild crashed with an error', log.error, 'foo')
        self.assertErrorRegex(EasyBuildError, 'EasyBuild encountered an exception', log.exception, 'bar')
开发者ID:dlagrava,项目名称:easybuild-framework,代码行数:69,代码来源:build_log.py


示例14: tearDown

 def tearDown(self):
     """Cleanup after test."""
     super(BuildLogTest, self).tearDown()
     # restore default logging format
     setLogFormat(LOGGING_FORMAT)
开发者ID:dlagrava,项目名称:easybuild-framework,代码行数:5,代码来源:build_log.py


示例15: test_easybuildlog

    def test_easybuildlog(self):
        """Tests for EasyBuildLog."""
        fd, tmplog = tempfile.mkstemp()
        os.close(fd)

        # compose versions older/newer than current version
        depr_ver = int(os.environ['EASYBUILD_DEPRECATED'])
        older_ver = str(depr_ver - 1)
        newer_ver = str(depr_ver + 1)

        # set log format, for each regex searching
        setLogFormat("%(name)s [%(levelname)s] :: %(message)s")

        # test basic log methods
        logToFile(tmplog, enable=True)
        log = getLogger('test_easybuildlog')
        self.mock_stderr(True)
        log.setLevelName('DEBUG')
        log.debug("123 debug")
        log.info("foobar info")
        log.warn("justawarning")
        log.deprecated("anotherwarning", newer_ver)
        log.deprecated("onemorewarning", '1.0', '2.0')
        log.deprecated("lastwarning", '1.0', max_ver='2.0')
        log.error("kaput")
        log.error("err: %s", 'msg: %s')
        stderr = self.get_stderr()
        self.mock_stderr(False)

        more_info = "see http://easybuild.readthedocs.org/en/latest/Deprecated-functionality.html for more information"
        expected_stderr = '\n'.join([
            "Deprecated functionality, will no longer work in v10000001: anotherwarning; " + more_info,
            "Deprecated functionality, will no longer work in v2.0: onemorewarning",
            "Deprecated functionality, will no longer work in v2.0: lastwarning",
        ]) + '\n'
        self.assertEqual(stderr, expected_stderr)

        try:
            log.exception("oops")
        except EasyBuildError:
            pass
        logToFile(tmplog, enable=False)
        logtxt = read_file(tmplog)

        root = getRootLoggerName()

        expected_logtxt = '\n'.join([
            r"%s.test_easybuildlog \[DEBUG\] :: 123 debug" % root,
            r"%s.test_easybuildlog \[INFO\] :: foobar info" % root,
            r"%s.test_easybuildlog \[WARNING\] :: justawarning" % root,
            r"%s.test_easybuildlog \[WARNING\] :: Deprecated functionality.*anotherwarning.*" % root,
            r"%s.test_easybuildlog \[WARNING\] :: Deprecated functionality.*onemorewarning.*" % root,
            r"%s.test_easybuildlog \[WARNING\] :: Deprecated functionality.*lastwarning.*" % root,
            r"%s.test_easybuildlog \[ERROR\] :: EasyBuild crashed with an error \(at .* in .*\): kaput" % root,
            root + r".test_easybuildlog \[ERROR\] :: EasyBuild crashed with an error \(at .* in .*\): err: msg: %s",
            r"%s.test_easybuildlog \[ERROR\] :: .*EasyBuild encountered an exception \(at .* in .*\): oops" % root,
            '',
        ])
        logtxt_regex = re.compile(r'^%s' % expected_logtxt, re.M)
        self.assertTrue(logtxt_regex.search(logtxt), "Pattern '%s' found in %s" % (logtxt_regex.pattern, logtxt))

        self.assertErrorRegex(EasyBuildError, "DEPRECATED \(since .*: kaput", log.deprecated, "kaput", older_ver)
        self.assertErrorRegex(EasyBuildError, "DEPRECATED \(since .*: 2>1", log.deprecated, "2>1", '2.0', '1.0')
        self.assertErrorRegex(EasyBuildError, "DEPRECATED \(since .*: 2>1", log.deprecated, "2>1", '2.0', max_ver='1.0')

        # wipe log so we can reuse it
        write_file(tmplog, '')

        # test formatting log messages by providing extra arguments
        logToFile(tmplog, enable=True)
        log.warn("%s", "bleh"),
        log.info("%s+%s = %d", '4', '2', 42)
        args = ['this', 'is', 'just', 'a', 'test']
        log.debug("%s %s %s %s %s", *args)
        log.error("foo %s baz", 'baz')
        logToFile(tmplog, enable=False)
        logtxt = read_file(tmplog)
        expected_logtxt = '\n'.join([
            r"%s.test_easybuildlog \[WARNING\] :: bleh" % root,
            r"%s.test_easybuildlog \[INFO\] :: 4\+2 = 42" % root,
            r"%s.test_easybuildlog \[DEBUG\] :: this is just a test" % root,
            r"%s.test_easybuildlog \[ERROR\] :: EasyBuild crashed with an error \(at .* in .*\): foo baz baz" % root,
            '',
        ])
        logtxt_regex = re.compile(r'^%s' % expected_logtxt, re.M)
        self.assertTrue(logtxt_regex.search(logtxt), "Pattern '%s' found in %s" % (logtxt_regex.pattern, logtxt))
开发者ID:cyiops,项目名称:easybuild-framework,代码行数:86,代码来源:build_log.py


示例16: exception

        """Print exception message and raise EasyBuildError."""
        # don't raise the exception from within error
        ebmsg = "EasyBuild encountered an exception %s: " + msg
        args = (self.caller_info(),) + args

        self.raiseError = False
        fancylogger.FancyLogger.exception(self, ebmsg, *args)
        self.raiseError = True

        self.deprecated("Use 'raise EasyBuildError' rather than exception() logging method that raises", '3.0')
        raise EasyBuildError(ebmsg, *args)


# set format for logger
LOGGING_FORMAT = EB_MSG_PREFIX + ' %(asctime)s %(name)s %(levelname)s %(message)s'
fancylogger.setLogFormat(LOGGING_FORMAT)

# set the default LoggerClass to EasyBuildLog
fancylogger.logging.setLoggerClass(EasyBuildLog)

# you can't easily set another LoggerClass before fancylogger calls getLogger on import
_init_fancylog = fancylogger.getLogger(fname=False)
del _init_fancylog.manager.loggerDict[_init_fancylog.name]

# we need to make sure there is a handler
fancylogger.logToFile(filename=os.devnull)

# EasyBuildLog
_init_easybuildlog = fancylogger.getLogger(fname=False)

开发者ID:dnangellight,项目名称:easybuild-framework,代码行数:29,代码来源:build_log.py


示例17: tearDown

 def tearDown(self):
     """Cleanup after test."""
     # restore default logging format
     setLogFormat(LOGGING_FORMAT)
开发者ID:FredHutch,项目名称:easybuild-framework,代码行数:4,代码来源:build_log.py



注:本文中的vsc.utils.fancylogger.setLogFormat函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python generaloption.simple_option函数代码示例发布时间:2022-05-26
下一篇:
Python fancylogger.logToScreen函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap