コード例 #1
0
 def __init__(self):
     config = self.app.config
     logfile = self.logfile = config.LOG_FILE
     self.loglevel = config.LOGGING_LEVEL
     self.format = config.DEFAULT_WORKER_LOG_FMT \
                   if os.getenv('IS_WORKER', False) \
                   else config.DEFAULT_LOG_FMT
     colorized = config.LOG_FORCE_COLORIZED = self.colorized = \
         config.LOG_FORCE_COLORIZED or self.colorize(logfile)
     self.colored = colored(enabled=colorized)
     self.request_logger = None
     self.tornado_logger = None
コード例 #2
0
ファイル: log.py プロジェクト: cradenbyrg/thriftpool
 def __init__(self):
     self.logfile = self.app.config.LOG_FILE
     self.loglevel = self.app.config.LOGGING_LEVEL
     self.format = self.app.config.DEFAULT_LOG_FMT
     self.colored = colored(enabled=self.colorize(self.logfile))
     self.request_logger = None
コード例 #3
0
ファイル: test_term.py プロジェクト: minisotm/thriftpool
    def test_colors(self):
        colors = (
            ('black', term.BLACK),
            ('red', term.RED),
            ('green', term.GREEN),
            ('yellow', term.YELLOW),
            ('blue', term.BLUE),
            ('magenta', term.MAGENTA),
            ('cyan', term.CYAN),
            ('white', term.WHITE),
        )

        for name, key in colors:
            self.assertIn(fg(30 + key), str(colored().names[name]('foo')))

        self.assertTrue(str(colored().bold('f')))
        self.assertTrue(str(colored().underline('f')))
        self.assertTrue(str(colored().blink('f')))
        self.assertTrue(str(colored().reverse('f')))
        self.assertTrue(str(colored().bright('f')))
        self.assertTrue(str(colored().ired('f')))
        self.assertTrue(str(colored().igreen('f')))
        self.assertTrue(str(colored().iyellow('f')))
        self.assertTrue(str(colored().iblue('f')))
        self.assertTrue(str(colored().imagenta('f')))
        self.assertTrue(str(colored().icyan('f')))
        self.assertTrue(str(colored().iwhite('f')))
        self.assertTrue(str(colored().reset('f')))

        self.assertTrue(str(colored().green('∂bar')))

        self.assertTrue(colored().red('éefoo') + colored().green('∂bar'))

        self.assertEqual(colored().red('foo').no_color(), 'foo')

        self.assertTrue(repr(colored().blue('åfoo')))

        self.assertIn("''", repr(colored()))

        c = colored()
        s = c.red('foo', c.blue('bar'), c.green('baz'))
        self.assertTrue(s.no_color())

        c._fold_no_color(s, 'øfoo')
        c._fold_no_color('fooå', s)

        c = colored().red('åfoo')
        self.assertEqual(
            c._add(c, 'baræ'),
            '\x1b[1;31m\xe5foo\x1b[0mbar\xe6',
        )

        c2 = colored().blue('ƒƒz')
        c3 = c._add(c, c2)
        self.assertEqual(
            c3,
            '\x1b[1;31m\xe5foo\x1b[0m\x1b[1;34m\u0192\u0192z\x1b[0m',
        )
コード例 #4
0
 def __init__(self, app=None, stdout=sys.stdout, stderr=sys.stderr):
     self.app = thriftpool.thriftpool if app is None else app
     self.colored = colored(
         enabled=all([isatty(out) for out in (sys.stderr, sys.stdout)]))
     self.stdout = stdout
     self.stderr = stderr
コード例 #5
0
ファイル: base.py プロジェクト: Shemela/thriftpool
 def __init__(self, app=None, stdout=sys.stdout, stderr=sys.stderr):
     self.app = thriftpool.thriftpool if app is None else app
     self.colored = colored(enabled=all([isatty(out) for out
                                         in (sys.stderr, sys.stdout)]))
     self.stdout = stdout
     self.stderr = stderr
コード例 #6
0
 def __init__(self):
     self.logfile = self.app.config.LOG_FILE
     self.loglevel = self.app.config.LOGGING_LEVEL
     self.format = self.app.config.DEFAULT_LOG_FMT
     self.colored = colored(enabled=self.colorize(self.logfile))
     self.request_logger = None
コード例 #7
0
ファイル: test_term.py プロジェクト: Shemela/thriftpool
    def test_colors(self):
        colors = (
            ('black', term.BLACK),
            ('red', term.RED),
            ('green', term.GREEN),
            ('yellow', term.YELLOW),
            ('blue', term.BLUE),
            ('magenta', term.MAGENTA),
            ('cyan', term.CYAN),
            ('white', term.WHITE),
        )

        for name, key in colors:
            self.assertIn(fg(30 + key), str(colored().names[name]('foo')))

        self.assertTrue(str(colored().bold('f')))
        self.assertTrue(str(colored().underline('f')))
        self.assertTrue(str(colored().blink('f')))
        self.assertTrue(str(colored().reverse('f')))
        self.assertTrue(str(colored().bright('f')))
        self.assertTrue(str(colored().ired('f')))
        self.assertTrue(str(colored().igreen('f')))
        self.assertTrue(str(colored().iyellow('f')))
        self.assertTrue(str(colored().iblue('f')))
        self.assertTrue(str(colored().imagenta('f')))
        self.assertTrue(str(colored().icyan('f')))
        self.assertTrue(str(colored().iwhite('f')))
        self.assertTrue(str(colored().reset('f')))

        self.assertTrue(str(colored().green('∂bar')))

        self.assertTrue(
            colored().red('éefoo') + colored().green('∂bar'))

        self.assertEqual(
            colored().red('foo').no_color(), 'foo')

        self.assertTrue(
            repr(colored().blue('åfoo')))

        self.assertIn("''", repr(colored()))

        c = colored()
        s = c.red('foo', c.blue('bar'), c.green('baz'))
        self.assertTrue(s.no_color())

        c._fold_no_color(s, 'øfoo')
        c._fold_no_color('fooå', s)

        c = colored().red('åfoo')
        self.assertEqual(
            c._add(c, 'baræ'),
            '\x1b[1;31m\xe5foo\x1b[0mbar\xe6',
        )

        c2 = colored().blue('ƒƒz')
        c3 = c._add(c, c2)
        self.assertEqual(
            c3,
            '\x1b[1;31m\xe5foo\x1b[0m\x1b[1;34m\u0192\u0192z\x1b[0m',
        )