annotate pylons_app/lib/colored_formatter.py @ 153:a5a3bcc5ee89

Added colored formatter to project, and configs
author Marcin Kuzminski <marcin@python-works.com>
date Sun, 16 May 2010 15:06:20 +0200
parents
children 779dabcaae28
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
153
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
1 #import logging
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
2 ## now we patch Python code to add color support to logging.StreamHandler
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
3 #def add_coloring_to_emit_windows(fn):
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
4 # # add methods we need to the class
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
5 # def _out_handle(self):
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
6 # import ctypes
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
7 # return ctypes.windll.kernel32.GetStdHandle(self.STD_OUTPUT_HANDLE)
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
8 # out_handle = property(_out_handle)
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
9 #
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
10 # def _set_color(self, code):
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
11 # import ctypes
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
12 # # Constants from the Windows API
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
13 # self.STD_OUTPUT_HANDLE = -11
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
14 # hdl = ctypes.windll.kernel32.GetStdHandle(self.STD_OUTPUT_HANDLE)
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
15 # ctypes.windll.kernel32.SetConsoleTextAttribute(hdl, code)
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
16 #
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
17 # setattr(logging.StreamHandler, '_set_color', _set_color)
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
18 #
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
19 # def new(*args):
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
20 # FOREGROUND_BLUE = 0x0001 # text color contains blue.
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
21 # FOREGROUND_GREEN = 0x0002 # text color contains green.
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
22 # FOREGROUND_RED = 0x0004 # text color contains red.
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
23 # FOREGROUND_INTENSITY = 0x0008 # text color is intensified.
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
24 # FOREGROUND_WHITE = FOREGROUND_BLUE|FOREGROUND_GREEN |FOREGROUND_RED
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
25 # # winbase.h
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
26 # STD_INPUT_HANDLE = -10
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
27 # STD_OUTPUT_HANDLE = -11
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
28 # STD_ERROR_HANDLE = -12
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
29 #
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
30 # # wincon.h
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
31 # FOREGROUND_BLACK = 0x0000
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
32 # FOREGROUND_BLUE = 0x0001
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
33 # FOREGROUND_GREEN = 0x0002
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
34 # FOREGROUND_CYAN = 0x0003
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
35 # FOREGROUND_RED = 0x0004
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
36 # FOREGROUND_MAGENTA = 0x0005
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
37 # FOREGROUND_YELLOW = 0x0006
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
38 # FOREGROUND_GREY = 0x0007
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
39 # FOREGROUND_INTENSITY = 0x0008 # foreground color is intensified.
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
40 #
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
41 # BACKGROUND_BLACK = 0x0000
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
42 # BACKGROUND_BLUE = 0x0010
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
43 # BACKGROUND_GREEN = 0x0020
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
44 # BACKGROUND_CYAN = 0x0030
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
45 # BACKGROUND_RED = 0x0040
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
46 # BACKGROUND_MAGENTA = 0x0050
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
47 # BACKGROUND_YELLOW = 0x0060
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
48 # BACKGROUND_GREY = 0x0070
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
49 # BACKGROUND_INTENSITY = 0x0080 # background color is intensified.
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
50 #
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
51 # levelno = args[1].levelno
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
52 # if(levelno>=50):
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
53 # color = BACKGROUND_YELLOW | FOREGROUND_RED | FOREGROUND_INTENSITY | BACKGROUND_INTENSITY
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
54 # elif(levelno>=40):
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
55 # color = FOREGROUND_RED | FOREGROUND_INTENSITY
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
56 # elif(levelno>=30):
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
57 # color = FOREGROUND_YELLOW | FOREGROUND_INTENSITY
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
58 # elif(levelno>=20):
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
59 # color = FOREGROUND_GREEN
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
60 # elif(levelno>=10):
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
61 # color = FOREGROUND_MAGENTA
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
62 # else:
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
63 # color = FOREGROUND_WHITE
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
64 # args[0]._set_color(color)
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
65 #
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
66 # ret = fn(*args)
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
67 # args[0]._set_color( FOREGROUND_WHITE )
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
68 # #print "after"
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
69 # return ret
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
70 # return new
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
71 #
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
72 #def add_coloring_to_emit_ansi(fn):
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
73 # # add methods we need to the class
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
74 # def new(*args):
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
75 # levelno = args[1].levelno
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
76 # if(levelno>=50):
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
77 # color = '\x1b[31m' # red
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
78 # elif(levelno>=40):
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
79 # color = '\x1b[31m' # red
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
80 # elif(levelno>=30):
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
81 # color = '\x1b[33m' # yellow
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
82 # elif(levelno>=20):
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
83 # color = '\x1b[32m' # green
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
84 # elif(levelno>=10):
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
85 # color = '\x1b[35m' # pink
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
86 # else:
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
87 # color = '\x1b[0m' # normal
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
88 # args[1].msg = color + args[1].msg + '\x1b[0m' # normal
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
89 # #print "after"
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
90 # return fn(*args)
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
91 # return new
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
92 #
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
93 #import platform
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
94 #if platform.system()=='Windows':
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
95 # # Windows does not support ANSI escapes and we are using API calls to set the console color
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
96 # logging.StreamHandler.emit = add_coloring_to_emit_windows(logging.StreamHandler.emit)
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
97 #else:
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
98 # # all non-Windows platforms are supporting ANSI escapes so we use them
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
99 # logging.StreamHandler.emit = add_coloring_to_emit_ansi(logging.StreamHandler.emit)
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
100 # #log = logging.getLogger()
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
101 # #log.addFilter(log_filter())
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
102 # #//hdlr = logging.StreamHandler()
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
103 # #//hdlr.setFormatter(formatter())
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
104
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
105 import logging
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
106
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
107 BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = xrange(30, 38)
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
108
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
109 # Sequences
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
110 RESET_SEQ = "\033[0m"
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
111 COLOR_SEQ = "\033[1;%dm"
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
112 BOLD_SEQ = "\033[1m"
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
113
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
114 COLORS = {
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
115 'CRITICAL': MAGENTA, # level 50
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
116 'ERROR': RED, # level 40
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
117 'WARNING': CYAN, # level 30
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
118 'INFO': GREEN, # level 20
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
119 'DEBUG': BLUE, # level 10
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
120 }
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
121
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
122 class ColorFormatter(logging.Formatter):
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
123
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
124 def __init__(self, *args, **kwargs):
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
125 # can't do super(...) here because Formatter is an old school class
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
126 logging.Formatter.__init__(self, *args, **kwargs)
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
127
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
128 def format(self, record):
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
129 """
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
130 Changes record's levelname to use with COLORS enum
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
131 """
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
132
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
133 levelname = record.levelname
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
134 start = COLOR_SEQ % (COLORS[levelname])
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
135 def_record = logging.Formatter.format(self, record)
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
136 end = RESET_SEQ
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
137
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
138 colored_record = start + def_record + end
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
139 return colored_record
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
140
a5a3bcc5ee89 Added colored formatter to project, and configs
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
141 logging.ColorFormatter = ColorFormatter