##// END OF EJS Templates
timperproxy will just measure the time of queries, and formatting will be handled by the new sql_formatter of queries from sqlalchemy itself. Updated ini files for new way logging
marcink -
r1186:b9ea10d3 beta
parent child Browse files
Show More
@@ -1,221 +1,232 b''
1 1 ################################################################################
2 2 ################################################################################
3 3 # RhodeCode - Pylons environment configuration #
4 4 # #
5 5 # The %(here)s variable will be replaced with the parent directory of this file#
6 6 ################################################################################
7 7
8 8 [DEFAULT]
9 9 debug = true
10 10 ################################################################################
11 11 ## Uncomment and replace with the address which should receive ##
12 12 ## any error reports after application crash ##
13 13 ## Additionally those settings will be used by RhodeCode mailing system ##
14 14 ################################################################################
15 15 #email_to = admin@localhost
16 16 #error_email_from = paste_error@localhost
17 17 #app_email_from = rhodecode-noreply@localhost
18 18 #error_message =
19 19
20 20 #smtp_server = mail.server.com
21 21 #smtp_username =
22 22 #smtp_password =
23 23 #smtp_port =
24 24 #smtp_use_tls = false
25 25 #smtp_use_ssl = true
26 26
27 27 [server:main]
28 28 ##nr of threads to spawn
29 29 threadpool_workers = 5
30 30
31 31 ##max request before thread respawn
32 32 threadpool_max_requests = 6
33 33
34 34 ##option to use threads of process
35 35 use_threadpool = true
36 36
37 37 use = egg:Paste#http
38 38 host = 0.0.0.0
39 39 port = 5000
40 40
41 41 [app:main]
42 42 use = egg:rhodecode
43 43 full_stack = true
44 44 static_files = true
45 45 lang=en
46 46 cache_dir = %(here)s/data
47 47 index_dir = %(here)s/data/index
48 48 app_instance_uuid = develop
49 49 cut_off_limit = 256000
50 50 force_https = false
51 51 commit_parse_limit = 25
52 52 use_gravatar = true
53 53
54 54 ####################################
55 55 ### CELERY CONFIG ####
56 56 ####################################
57 57 use_celery = false
58 58 broker.host = localhost
59 59 broker.vhost = rabbitmqhost
60 60 broker.port = 5672
61 61 broker.user = rabbitmq
62 62 broker.password = qweqwe
63 63
64 64 celery.imports = rhodecode.lib.celerylib.tasks
65 65
66 66 celery.result.backend = amqp
67 67 celery.result.dburi = amqp://
68 68 celery.result.serialier = json
69 69
70 70 #celery.send.task.error.emails = true
71 71 #celery.amqp.task.result.expires = 18000
72 72
73 73 celeryd.concurrency = 2
74 74 #celeryd.log.file = celeryd.log
75 75 celeryd.log.level = debug
76 76 celeryd.max.tasks.per.child = 1
77 77
78 78 #tasks will never be sent to the queue, but executed locally instead.
79 79 celery.always.eager = false
80 80
81 81 ####################################
82 82 ### BEAKER CACHE ####
83 83 ####################################
84 84 beaker.cache.data_dir=%(here)s/data/cache/data
85 85 beaker.cache.lock_dir=%(here)s/data/cache/lock
86 86
87 87 beaker.cache.regions=super_short_term,short_term,long_term,sql_cache_short,sql_cache_med,sql_cache_long
88 88
89 89 beaker.cache.super_short_term.type=memory
90 90 beaker.cache.super_short_term.expire=10
91 91
92 92 beaker.cache.short_term.type=memory
93 93 beaker.cache.short_term.expire=60
94 94
95 95 beaker.cache.long_term.type=memory
96 96 beaker.cache.long_term.expire=36000
97 97
98 98 beaker.cache.sql_cache_short.type=memory
99 99 beaker.cache.sql_cache_short.expire=10
100 100
101 101 beaker.cache.sql_cache_med.type=memory
102 102 beaker.cache.sql_cache_med.expire=360
103 103
104 104 beaker.cache.sql_cache_long.type=file
105 105 beaker.cache.sql_cache_long.expire=3600
106 106
107 107 ####################################
108 108 ### BEAKER SESSION ####
109 109 ####################################
110 110 ## Type of storage used for the session, current types are
111 111 ## dbm, file, memcached, database, and memory.
112 112 ## The storage uses the Container API
113 113 ##that is also used by the cache system.
114 114 beaker.session.type = file
115 115
116 116 beaker.session.key = rhodecode
117 117 beaker.session.secret = g654dcno0-9873jhgfreyu
118 118 beaker.session.timeout = 36000
119 119
120 120 ##auto save the session to not to use .save()
121 121 beaker.session.auto = False
122 122
123 123 ##true exire at browser close
124 124 #beaker.session.cookie_expires = 3600
125 125
126 126
127 127 ################################################################################
128 128 ## WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT* ##
129 129 ## Debug mode will enable the interactive debugging tool, allowing ANYONE to ##
130 130 ## execute malicious code after an exception is raised. ##
131 131 ################################################################################
132 132 #set debug = false
133 133
134 134 ##################################
135 135 ### LOGVIEW CONFIG ###
136 136 ##################################
137 137 logview.sqlalchemy = #faa
138 138 logview.pylons.templating = #bfb
139 139 logview.pylons.util = #eee
140 140
141 141 #########################################################
142 142 ### DB CONFIGS - EACH DB WILL HAVE IT'S OWN CONFIG ###
143 143 #########################################################
144 144 #sqlalchemy.db1.url = sqlite:///%(here)s/rhodecode.db
145 145 sqlalchemy.db1.url = postgresql://postgres:qwe@localhost/rhodecode
146 #sqlalchemy.db1.echo = False
147 #sqlalchemy.db1.pool_recycle = 3600
146 sqlalchemy.db1.echo = True
147 sqlalchemy.db1.pool_recycle = 3600
148 148 sqlalchemy.convert_unicode = true
149 149
150 150 ################################
151 151 ### LOGGING CONFIGURATION ####
152 152 ################################
153 153 [loggers]
154 154 keys = root, routes, rhodecode, sqlalchemy,beaker,templates
155 155
156 156 [handlers]
157 keys = console
157 keys = console, console_sql
158 158
159 159 [formatters]
160 keys = generic,color_formatter
160 keys = generic, color_formatter, color_formatter_sql
161 161
162 162 #############
163 163 ## LOGGERS ##
164 164 #############
165 165 [logger_root]
166 166 level = NOTSET
167 167 handlers = console
168 168
169 169 [logger_routes]
170 170 level = DEBUG
171 handlers = console
171 handlers =
172 172 qualname = routes.middleware
173 173 # "level = DEBUG" logs the route matched and routing variables.
174 propagate = 0
174 propagate = 1
175 175
176 176 [logger_beaker]
177 level = ERROR
178 handlers = console
177 level = DEBUG
178 handlers =
179 179 qualname = beaker.container
180 propagate = 0
180 propagate = 1
181 181
182 182 [logger_templates]
183 183 level = INFO
184 handlers = console
184 handlers =
185 185 qualname = pylons.templating
186 propagate = 0
186 propagate = 1
187 187
188 188 [logger_rhodecode]
189 189 level = DEBUG
190 handlers = console
190 handlers =
191 191 qualname = rhodecode
192 propagate = 0
192 propagate = 1
193 193
194 194 [logger_sqlalchemy]
195 level = ERROR
196 handlers = console
195 level = INFO
196 handlers = console_sql
197 197 qualname = sqlalchemy.engine
198 198 propagate = 0
199 199
200 200 ##############
201 201 ## HANDLERS ##
202 202 ##############
203 203
204 204 [handler_console]
205 205 class = StreamHandler
206 206 args = (sys.stderr,)
207 207 level = NOTSET
208 208 formatter = color_formatter
209 209
210 [handler_console_sql]
211 class = StreamHandler
212 args = (sys.stderr,)
213 level = NOTSET
214 formatter = color_formatter_sql
215
210 216 ################
211 217 ## FORMATTERS ##
212 218 ################
213 219
214 220 [formatter_generic]
215 221 format = %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
216 222 datefmt = %Y-%m-%d %H:%M:%S
217 223
218 224 [formatter_color_formatter]
219 225 class=rhodecode.lib.colored_formatter.ColorFormatter
220 226 format= %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
227 datefmt = %Y-%m-%d %H:%M:%S
228
229 [formatter_color_formatter_sql]
230 class=rhodecode.lib.colored_formatter.ColorFormatterSql
231 format= %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
221 232 datefmt = %Y-%m-%d %H:%M:%S No newline at end of file
@@ -1,220 +1,232 b''
1 1 ################################################################################
2 2 ################################################################################
3 3 # RhodeCode - Pylons environment configuration #
4 4 # #
5 5 # The %(here)s variable will be replaced with the parent directory of this file#
6 6 ################################################################################
7 7
8 8 [DEFAULT]
9 9 debug = true
10 10 ################################################################################
11 11 ## Uncomment and replace with the address which should receive ##
12 12 ## any error reports after application crash ##
13 13 ## Additionally those settings will be used by RhodeCode mailing system ##
14 14 ################################################################################
15 15 #email_to = admin@localhost
16 16 #error_email_from = paste_error@localhost
17 17 #app_email_from = rhodecode-noreply@localhost
18 18 #error_message =
19 19
20 20 #smtp_server = mail.server.com
21 21 #smtp_username =
22 22 #smtp_password =
23 23 #smtp_port =
24 24 #smtp_use_tls = false
25 25 #smtp_use_ssl = true
26 26
27 27 [server:main]
28 28 ##nr of threads to spawn
29 29 threadpool_workers = 5
30 30
31 31 ##max request before thread respawn
32 threadpool_max_requests = 6
32 threadpool_max_requests = 10
33 33
34 34 ##option to use threads of process
35 35 use_threadpool = true
36 36
37 37 use = egg:Paste#http
38 38 host = 127.0.0.1
39 39 port = 8001
40 40
41 41 [app:main]
42 42 use = egg:rhodecode
43 43 full_stack = true
44 static_files = false
44 static_files = true
45 45 lang=en
46 46 cache_dir = %(here)s/data
47 47 index_dir = %(here)s/data/index
48 app_instance_uuid = prod1234
48 49 cut_off_limit = 256000
49 50 force_https = false
50 commit_parse_limit = 25
51 commit_parse_limit = 50
51 52 use_gravatar = true
52 53
53 54 ####################################
54 55 ### CELERY CONFIG ####
55 56 ####################################
56 57 use_celery = false
57 58 broker.host = localhost
58 59 broker.vhost = rabbitmqhost
59 60 broker.port = 5672
60 61 broker.user = rabbitmq
61 62 broker.password = qweqwe
62 63
63 64 celery.imports = rhodecode.lib.celerylib.tasks
64 65
65 66 celery.result.backend = amqp
66 67 celery.result.dburi = amqp://
67 68 celery.result.serialier = json
68 69
69 70 #celery.send.task.error.emails = true
70 71 #celery.amqp.task.result.expires = 18000
71 72
72 73 celeryd.concurrency = 2
73 74 #celeryd.log.file = celeryd.log
74 75 celeryd.log.level = debug
75 76 celeryd.max.tasks.per.child = 1
76 77
77 78 #tasks will never be sent to the queue, but executed locally instead.
78 79 celery.always.eager = false
79 80
80 81 ####################################
81 82 ### BEAKER CACHE ####
82 83 ####################################
83 84 beaker.cache.data_dir=%(here)s/data/cache/data
84 85 beaker.cache.lock_dir=%(here)s/data/cache/lock
85 86
86 87 beaker.cache.regions=super_short_term,short_term,long_term,sql_cache_short,sql_cache_med,sql_cache_long
87 88
88 89 beaker.cache.super_short_term.type=memory
89 90 beaker.cache.super_short_term.expire=10
90 91
91 92 beaker.cache.short_term.type=memory
92 93 beaker.cache.short_term.expire=60
93 94
94 95 beaker.cache.long_term.type=memory
95 96 beaker.cache.long_term.expire=36000
96 97
97 98 beaker.cache.sql_cache_short.type=memory
98 99 beaker.cache.sql_cache_short.expire=10
99 100
100 101 beaker.cache.sql_cache_med.type=memory
101 102 beaker.cache.sql_cache_med.expire=360
102 103
103 104 beaker.cache.sql_cache_long.type=file
104 105 beaker.cache.sql_cache_long.expire=3600
105 106
106 107 ####################################
107 108 ### BEAKER SESSION ####
108 109 ####################################
109 110 ## Type of storage used for the session, current types are
110 111 ## dbm, file, memcached, database, and memory.
111 112 ## The storage uses the Container API
112 113 ##that is also used by the cache system.
113 114 beaker.session.type = file
114 115
115 116 beaker.session.key = rhodecode
116 117 beaker.session.secret = g654dcno0-9873jhgfreyu
117 118 beaker.session.timeout = 36000
118 119
119 120 ##auto save the session to not to use .save()
120 121 beaker.session.auto = False
121 122
122 123 ##true exire at browser close
123 124 #beaker.session.cookie_expires = 3600
124 125
125 126
126 127 ################################################################################
127 128 ## WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT* ##
128 129 ## Debug mode will enable the interactive debugging tool, allowing ANYONE to ##
129 130 ## execute malicious code after an exception is raised. ##
130 131 ################################################################################
131 132 set debug = false
132 133
133 134 ##################################
134 135 ### LOGVIEW CONFIG ###
135 136 ##################################
136 137 logview.sqlalchemy = #faa
137 138 logview.pylons.templating = #bfb
138 139 logview.pylons.util = #eee
139 140
140 141 #########################################################
141 142 ### DB CONFIGS - EACH DB WILL HAVE IT'S OWN CONFIG ###
142 143 #########################################################
143 144 #sqlalchemy.db1.url = sqlite:///%(here)s/rhodecode.db
144 145 sqlalchemy.db1.url = postgresql://postgres:qwe@localhost/rhodecode
145 #sqlalchemy.db1.echo = False
146 #sqlalchemy.db1.pool_recycle = 3600
146 sqlalchemy.db1.echo = True
147 sqlalchemy.db1.pool_recycle = 3600
147 148 sqlalchemy.convert_unicode = true
148 149
149 150 ################################
150 151 ### LOGGING CONFIGURATION ####
151 152 ################################
152 153 [loggers]
153 154 keys = root, routes, rhodecode, sqlalchemy,beaker,templates
154 155
155 156 [handlers]
156 keys = console
157 keys = console, console_sql
157 158
158 159 [formatters]
159 keys = generic,color_formatter
160 keys = generic, color_formatter, color_formatter_sql
160 161
161 162 #############
162 163 ## LOGGERS ##
163 164 #############
164 165 [logger_root]
165 level = INFO
166 level = NOTSET
166 167 handlers = console
167 168
168 169 [logger_routes]
169 level = INFO
170 handlers = console
170 level = DEBUG
171 handlers =
171 172 qualname = routes.middleware
172 173 # "level = DEBUG" logs the route matched and routing variables.
173 propagate = 0
174 propagate = 1
174 175
175 176 [logger_beaker]
176 level = ERROR
177 handlers = console
177 level = DEBUG
178 handlers =
178 179 qualname = beaker.container
179 propagate = 0
180 propagate = 1
180 181
181 182 [logger_templates]
182 183 level = INFO
183 handlers = console
184 handlers =
184 185 qualname = pylons.templating
185 propagate = 0
186 propagate = 1
186 187
187 188 [logger_rhodecode]
188 189 level = DEBUG
189 handlers = console
190 handlers =
190 191 qualname = rhodecode
191 propagate = 0
192 propagate = 1
192 193
193 194 [logger_sqlalchemy]
194 level = ERROR
195 handlers = console
195 level = INFO
196 handlers = console_sql
196 197 qualname = sqlalchemy.engine
197 198 propagate = 0
198 199
199 200 ##############
200 201 ## HANDLERS ##
201 202 ##############
202 203
203 204 [handler_console]
204 205 class = StreamHandler
205 206 args = (sys.stderr,)
206 level = NOTSET
207 level = INFO
207 208 formatter = color_formatter
208 209
210 [handler_console_sql]
211 class = StreamHandler
212 args = (sys.stderr,)
213 level = WARN
214 formatter = color_formatter_sql
215
209 216 ################
210 217 ## FORMATTERS ##
211 218 ################
212 219
213 220 [formatter_generic]
214 221 format = %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
215 222 datefmt = %Y-%m-%d %H:%M:%S
216 223
217 224 [formatter_color_formatter]
218 225 class=rhodecode.lib.colored_formatter.ColorFormatter
219 226 format= %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
227 datefmt = %Y-%m-%d %H:%M:%S
228
229 [formatter_color_formatter_sql]
230 class=rhodecode.lib.colored_formatter.ColorFormatterSql
231 format= %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
220 232 datefmt = %Y-%m-%d %H:%M:%S No newline at end of file
@@ -1,220 +1,231 b''
1 1 ################################################################################
2 2 ################################################################################
3 3 # RhodeCode - Pylons environment configuration #
4 4 # #
5 5 # The %(here)s variable will be replaced with the parent directory of this file#
6 6 ################################################################################
7 7
8 8 [DEFAULT]
9 9 debug = true
10 10 ################################################################################
11 11 ## Uncomment and replace with the address which should receive ##
12 12 ## any error reports after application crash ##
13 13 ## Additionally those settings will be used by RhodeCode mailing system ##
14 14 ################################################################################
15 15 #email_to = admin@localhost
16 16 #error_email_from = paste_error@localhost
17 17 #app_email_from = rhodecode-noreply@localhost
18 18 #error_message =
19 19
20 20 #smtp_server = mail.server.com
21 21 #smtp_username =
22 22 #smtp_password =
23 23 #smtp_port =
24 24 #smtp_use_tls = false
25 25 #smtp_use_ssl = true
26 26
27 27 [server:main]
28 28 ##nr of threads to spawn
29 29 threadpool_workers = 5
30 30
31 31 ##max request before thread respawn
32 32 threadpool_max_requests = 10
33 33
34 34 ##option to use threads of process
35 35 use_threadpool = true
36 36
37 37 use = egg:Paste#http
38 38 host = 127.0.0.1
39 39 port = 5000
40 40
41 41 [app:main]
42 42 use = egg:rhodecode
43 43 full_stack = true
44 44 static_files = true
45 45 lang=en
46 46 cache_dir = %(here)s/data
47 47 index_dir = %(here)s/data/index
48 48 app_instance_uuid = ${app_instance_uuid}
49 49 cut_off_limit = 256000
50 50 force_https = false
51 51 commit_parse_limit = 50
52 52 use_gravatar = true
53 53
54 54 ####################################
55 55 ### CELERY CONFIG ####
56 56 ####################################
57 57 use_celery = false
58 58 broker.host = localhost
59 59 broker.vhost = rabbitmqhost
60 60 broker.port = 5672
61 61 broker.user = rabbitmq
62 62 broker.password = qweqwe
63 63
64 64 celery.imports = rhodecode.lib.celerylib.tasks
65 65
66 66 celery.result.backend = amqp
67 67 celery.result.dburi = amqp://
68 68 celery.result.serialier = json
69 69
70 70 #celery.send.task.error.emails = true
71 71 #celery.amqp.task.result.expires = 18000
72 72
73 73 celeryd.concurrency = 2
74 74 #celeryd.log.file = celeryd.log
75 75 celeryd.log.level = debug
76 76 celeryd.max.tasks.per.child = 1
77 77
78 78 #tasks will never be sent to the queue, but executed locally instead.
79 79 celery.always.eager = false
80 80
81 81 ####################################
82 82 ### BEAKER CACHE ####
83 83 ####################################
84 84 beaker.cache.data_dir=%(here)s/data/cache/data
85 85 beaker.cache.lock_dir=%(here)s/data/cache/lock
86 86
87 87 beaker.cache.regions=super_short_term,short_term,long_term,sql_cache_short,sql_cache_med,sql_cache_long
88 88
89 89 beaker.cache.super_short_term.type=memory
90 90 beaker.cache.super_short_term.expire=10
91 91
92 92 beaker.cache.short_term.type=memory
93 93 beaker.cache.short_term.expire=60
94 94
95 95 beaker.cache.long_term.type=memory
96 96 beaker.cache.long_term.expire=36000
97 97
98 98 beaker.cache.sql_cache_short.type=memory
99 99 beaker.cache.sql_cache_short.expire=10
100 100
101 101 beaker.cache.sql_cache_med.type=memory
102 102 beaker.cache.sql_cache_med.expire=360
103 103
104 104 beaker.cache.sql_cache_long.type=file
105 105 beaker.cache.sql_cache_long.expire=3600
106 106
107 107 ####################################
108 108 ### BEAKER SESSION ####
109 109 ####################################
110 110 ## Type of storage used for the session, current types are
111 111 ## dbm, file, memcached, database, and memory.
112 112 ## The storage uses the Container API
113 113 ##that is also used by the cache system.
114 114 beaker.session.type = file
115 115
116 116 beaker.session.key = rhodecode
117 117 beaker.session.secret = ${app_instance_secret}
118 118 beaker.session.timeout = 36000
119 119
120 120 ##auto save the session to not to use .save()
121 121 beaker.session.auto = False
122 122
123 123 ##true exire at browser close
124 124 #beaker.session.cookie_expires = 3600
125 125
126 126
127 127 ################################################################################
128 128 ## WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT* ##
129 129 ## Debug mode will enable the interactive debugging tool, allowing ANYONE to ##
130 130 ## execute malicious code after an exception is raised. ##
131 131 ################################################################################
132 132 set debug = false
133 133
134 134 ##################################
135 135 ### LOGVIEW CONFIG ###
136 136 ##################################
137 137 logview.sqlalchemy = #faa
138 138 logview.pylons.templating = #bfb
139 139 logview.pylons.util = #eee
140 140
141 141 #########################################################
142 142 ### DB CONFIGS - EACH DB WILL HAVE IT'S OWN CONFIG ###
143 143 #########################################################
144 144 sqlalchemy.db1.url = sqlite:///%(here)s/rhodecode.db
145 #sqlalchemy.db1.echo = False
146 #sqlalchemy.db1.pool_recycle = 3600
145 sqlalchemy.db1.echo = True
146 sqlalchemy.db1.pool_recycle = 3600
147 147 sqlalchemy.convert_unicode = true
148 148
149 149 ################################
150 150 ### LOGGING CONFIGURATION ####
151 151 ################################
152 152 [loggers]
153 153 keys = root, routes, rhodecode, sqlalchemy,beaker,templates
154 154
155 155 [handlers]
156 keys = console
156 keys = console, console_sql
157 157
158 158 [formatters]
159 keys = generic,color_formatter
159 keys = generic, color_formatter, color_formatter_sql
160 160
161 161 #############
162 162 ## LOGGERS ##
163 163 #############
164 164 [logger_root]
165 level = INFO
165 level = NOTSET
166 166 handlers = console
167 167
168 168 [logger_routes]
169 level = INFO
170 handlers = console
169 level = DEBUG
170 handlers =
171 171 qualname = routes.middleware
172 172 # "level = DEBUG" logs the route matched and routing variables.
173 propagate = 0
173 propagate = 1
174 174
175 175 [logger_beaker]
176 level = ERROR
177 handlers = console
176 level = DEBUG
177 handlers =
178 178 qualname = beaker.container
179 propagate = 0
179 propagate = 1
180 180
181 181 [logger_templates]
182 182 level = INFO
183 handlers = console
183 handlers =
184 184 qualname = pylons.templating
185 propagate = 0
185 propagate = 1
186 186
187 187 [logger_rhodecode]
188 188 level = DEBUG
189 handlers = console
189 handlers =
190 190 qualname = rhodecode
191 propagate = 0
191 propagate = 1
192 192
193 193 [logger_sqlalchemy]
194 level = ERROR
195 handlers = console
194 level = INFO
195 handlers = console_sql
196 196 qualname = sqlalchemy.engine
197 197 propagate = 0
198 198
199 199 ##############
200 200 ## HANDLERS ##
201 201 ##############
202 202
203 203 [handler_console]
204 204 class = StreamHandler
205 205 args = (sys.stderr,)
206 level = NOTSET
206 level = INFO
207 207 formatter = color_formatter
208 208
209 [handler_console_sql]
210 class = StreamHandler
211 args = (sys.stderr,)
212 level = WARN
213 formatter = color_formatter_sql
214
209 215 ################
210 216 ## FORMATTERS ##
211 217 ################
212 218
213 219 [formatter_generic]
214 220 format = %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
215 221 datefmt = %Y-%m-%d %H:%M:%S
216 222
217 223 [formatter_color_formatter]
218 224 class=rhodecode.lib.colored_formatter.ColorFormatter
219 225 format= %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
226 datefmt = %Y-%m-%d %H:%M:%S
227
228 [formatter_color_formatter_sql]
229 class=rhodecode.lib.colored_formatter.ColorFormatterSql
230 format= %(asctime)s.%(msecs)03d %(levelname)-5.5s [%(name)s] %(message)s
220 231 datefmt = %Y-%m-%d %H:%M:%S No newline at end of file
@@ -1,38 +1,83 b''
1 1
2 2 import logging
3 3
4 4 BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = xrange(30, 38)
5 5
6 6 # Sequences
7 7 RESET_SEQ = "\033[0m"
8 8 COLOR_SEQ = "\033[1;%dm"
9 9 BOLD_SEQ = "\033[1m"
10 10
11 11 COLORS = {
12 12 'CRITICAL': MAGENTA, # level 50
13 13 'ERROR': RED, # level 40
14 14 'WARNING': CYAN, # level 30
15 15 'INFO': GREEN, # level 20
16 16 'DEBUG': BLUE, # level 10
17 'SQL' : YELLOW
17 18 }
18 19
20 def one_space_trim(s):
21 if s.find(" ") == -1:
22 return s
23 else:
24 s = s.replace(' ', ' ')
25 return one_space_trim(s)
26
27 def format_sql(sql):
28 sql = sql.replace('\n', '')
29 sql = one_space_trim(sql)
30 sql = sql\
31 .replace(',', ',\n\t')\
32 .replace('SELECT', '\n\tSELECT \n\t')\
33 .replace('UPDATE', '\n\tUPDATE \n\t')\
34 .replace('DELETE', '\n\tDELETE \n\t')\
35 .replace('FROM', '\n\tFROM')\
36 .replace('ORDER BY', '\n\tORDER BY')\
37 .replace('LIMIT', '\n\tLIMIT')\
38 .replace('WHERE', '\n\tWHERE')\
39 .replace('AND', '\n\tAND')\
40 .replace('LEFT', '\n\tLEFT')\
41 .replace('INNER', '\n\tINNER')\
42 .replace('INSERT', '\n\tINSERT')\
43 .replace('DELETE', '\n\tDELETE')
44 return sql
45
19 46 class ColorFormatter(logging.Formatter):
20 47
21 48 def __init__(self, *args, **kwargs):
22 49 # can't do super(...) here because Formatter is an old school class
23 50 logging.Formatter.__init__(self, *args, **kwargs)
24 51
25 52 def format(self, record):
26 53 """
27 54 Changes record's levelname to use with COLORS enum
28 55 """
29 56
30 57 levelname = record.levelname
31 58 start = COLOR_SEQ % (COLORS[levelname])
32 59 def_record = logging.Formatter.format(self, record)
33 60 end = RESET_SEQ
34 61
35 62 colored_record = start + def_record + end
36 63 return colored_record
37 64
38 logging.ColorFormatter = ColorFormatter
65
66 class ColorFormatterSql(logging.Formatter):
67
68 def __init__(self, *args, **kwargs):
69 # can't do super(...) here because Formatter is an old school class
70 logging.Formatter.__init__(self, *args, **kwargs)
71
72 def format(self, record):
73 """
74 Changes record's levelname to use with COLORS enum
75 """
76
77 start = COLOR_SEQ % (COLORS['SQL'])
78 def_record = format_sql(logging.Formatter.format(self, record))
79 end = RESET_SEQ
80
81 colored_record = start + def_record + end
82 return colored_record
83
@@ -1,59 +1,28 b''
1 1 from sqlalchemy.interfaces import ConnectionProxy
2 2 import time
3 3 from sqlalchemy import log
4 4 BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = xrange(30, 38)
5 5
6 6 def color_sql(sql):
7 7 COLOR_SEQ = "\033[1;%dm"
8 8 COLOR_SQL = YELLOW
9 9 normal = '\x1b[0m'
10 10 return COLOR_SEQ % COLOR_SQL + sql + normal
11 11
12 def one_space_trim(s):
13 if s.find(" ") == -1:
14 return s
15 else:
16 s = s.replace(' ', ' ')
17 return one_space_trim(s)
18
19 def format_sql(sql):
20 sql = color_sql(sql)
21 sql = sql.replace('\n', '')
22 sql = one_space_trim(sql)
23 sql = sql\
24 .replace(',', ',\n\t')\
25 .replace('SELECT', '\n\tSELECT \n\t')\
26 .replace('UPDATE', '\n\tUPDATE \n\t')\
27 .replace('DELETE', '\n\tDELETE \n\t')\
28 .replace('FROM', '\n\tFROM')\
29 .replace('ORDER BY', '\n\tORDER BY')\
30 .replace('LIMIT', '\n\tLIMIT')\
31 .replace('WHERE', '\n\tWHERE')\
32 .replace('AND', '\n\tAND')\
33 .replace('LEFT', '\n\tLEFT')\
34 .replace('INNER', '\n\tINNER')\
35 .replace('INSERT', '\n\tINSERT')\
36 .replace('DELETE', '\n\tDELETE')
37 return sql
38
39
40 12 class TimerProxy(ConnectionProxy):
41 13
42 14 def __init__(self):
43 15 super(TimerProxy, self).__init__()
44 16 self.logging_name = 'timerProxy'
45 17 self.log = log.instance_logger(self, True)
46 18
47 def cursor_execute(self, execute, cursor, statement, parameters, context, executemany):
19 def cursor_execute(self, execute, cursor, statement, parameters,
20 context, executemany):
48 21
49 22 now = time.time()
50 23 try:
51 self.log.info(">>>>> STARTING QUERY >>>>>")
24 self.log.info(color_sql(">>>>> STARTING QUERY >>>>>"))
52 25 return execute(cursor, statement, parameters, context)
53 26 finally:
54 27 total = time.time() - now
55 try:
56 self.log.info(format_sql("Query: %s" % statement % parameters))
57 except TypeError:
58 self.log.info(format_sql("Query: %s %s" % (statement, parameters)))
59 self.log.info("<<<<< TOTAL TIME: %f <<<<<" % total)
28 self.log.info(color_sql("<<<<< TOTAL TIME: %f <<<<<" % total))
General Comments 0
You need to be logged in to leave comments. Login now