##// END OF EJS Templates
application: add debug mode that switches logging to debug....
marcink -
r3270:312a83d9 default
parent child Browse files
Show More
@@ -5,6 +5,7 b''
5 ################################################################################
5 ################################################################################
6
6
7 [DEFAULT]
7 [DEFAULT]
8 ## Debug flag sets all loggers to debug, and enables request tracking
8 debug = true
9 debug = true
9
10
10 ################################################################################
11 ################################################################################
@@ -414,6 +415,7 b' search.location = %(here)s/data/index'
414 ########################################
415 ########################################
415 ## channelstream enables persistent connections and live notification
416 ## channelstream enables persistent connections and live notification
416 ## in the system. It's also used by the chat system
417 ## in the system. It's also used by the chat system
418
417 channelstream.enabled = false
419 channelstream.enabled = false
418
420
419 ## server address for channelstream server on the backend
421 ## server address for channelstream server on the backend
@@ -490,14 +492,6 b' appenlight.request_keys_blacklist ='
490 ## (by default the client ignores own entries: appenlight_client.client)
492 ## (by default the client ignores own entries: appenlight_client.client)
491 appenlight.log_namespace_blacklist =
493 appenlight.log_namespace_blacklist =
492
494
493
494 ################################################################################
495 ## WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT* ##
496 ## Debug mode will enable the interactive debugging tool, allowing ANYONE to ##
497 ## execute malicious code after an exception is raised. ##
498 ################################################################################
499 #set debug = false
500
501 # enable debug style page
495 # enable debug style page
502 debug_style = true
496 debug_style = true
503
497
@@ -5,7 +5,8 b''
5 ################################################################################
5 ################################################################################
6
6
7 [DEFAULT]
7 [DEFAULT]
8 debug = true
8 ## Debug flag sets all loggers to debug, and enables request tracking
9 debug = false
9
10
10 ################################################################################
11 ################################################################################
11 ## EMAIL CONFIGURATION ##
12 ## EMAIL CONFIGURATION ##
@@ -389,6 +390,7 b' search.location = %(here)s/data/index'
389 ########################################
390 ########################################
390 ## channelstream enables persistent connections and live notification
391 ## channelstream enables persistent connections and live notification
391 ## in the system. It's also used by the chat system
392 ## in the system. It's also used by the chat system
393
392 channelstream.enabled = false
394 channelstream.enabled = false
393
395
394 ## server address for channelstream server on the backend
396 ## server address for channelstream server on the backend
@@ -466,14 +468,6 b' appenlight.request_keys_blacklist ='
466 appenlight.log_namespace_blacklist =
468 appenlight.log_namespace_blacklist =
467
469
468
470
469 ################################################################################
470 ## WARNING: *THE LINE BELOW MUST BE UNCOMMENTED ON A PRODUCTION ENVIRONMENT* ##
471 ## Debug mode will enable the interactive debugging tool, allowing ANYONE to ##
472 ## execute malicious code after an exception is raised. ##
473 ################################################################################
474 set debug = false
475
476
477 ###########################################
471 ###########################################
478 ### MAIN RHODECODE DATABASE CONFIG ###
472 ### MAIN RHODECODE DATABASE CONFIG ###
479 ###########################################
473 ###########################################
@@ -524,6 +518,7 b' vcs.scm_app_implementation = http'
524 ## Push/Pull operations hooks protocol, available options are:
518 ## Push/Pull operations hooks protocol, available options are:
525 ## `http` - use http-rpc backend (default)
519 ## `http` - use http-rpc backend (default)
526 vcs.hooks.protocol = http
520 vcs.hooks.protocol = http
521
527 ## Host on which this instance is listening for hooks. If vcsserver is in other location
522 ## Host on which this instance is listening for hooks. If vcsserver is in other location
528 ## this should be adjusted.
523 ## this should be adjusted.
529 vcs.hooks.host = 127.0.0.1
524 vcs.hooks.host = 127.0.0.1
@@ -3,6 +3,16 b''
3 Enabling Debug Mode
3 Enabling Debug Mode
4 -------------------
4 -------------------
5
5
6 Debug Mode will enable debug logging, and request tracking middleware. Debug Mode
7 enabled DEBUG log-level which allows tracking various information about authentication
8 failures, LDAP connection, email etc.
9
10 The request tracking will add a special
11 unique ID: `| req_id:00000000-0000-0000-0000-000000000000` at the end of each log line.
12 The req_id is the same for each individual requests, it means that if you want to
13 track particular user logs only, and exclude other concurrent ones
14 simply grep by `req_id` uuid which you'll have to find for the individual request.
15
6 To enable debug mode on a |RCE| instance you need to set the debug property
16 To enable debug mode on a |RCE| instance you need to set the debug property
7 in the :file:`/home/{user}/.rccontrol/{instance-id}/rhodecode.ini` file. To
17 in the :file:`/home/{user}/.rccontrol/{instance-id}/rhodecode.ini` file. To
8 do this, use the following steps
18 do this, use the following steps
@@ -11,14 +21,10 b' 1. Open the file and set the ``debug`` l'
11 2. Restart you instance using the ``rccontrol restart`` command,
21 2. Restart you instance using the ``rccontrol restart`` command,
12 see the following example:
22 see the following example:
13
23
14 You can also set the log level, the follow are the valid options;
15 ``debug``, ``info``, ``warning``, or ``fatal``.
16
17 .. code-block:: ini
24 .. code-block:: ini
18
25
19 [DEFAULT]
26 [DEFAULT]
20 debug = true
27 debug = true
21 pdebug = false
22
28
23 .. code-block:: bash
29 .. code-block:: bash
24
30
@@ -27,6 +33,7 b' You can also set the log level, the foll'
27 Instance "enterprise-1" successfully stopped.
33 Instance "enterprise-1" successfully stopped.
28 Instance "enterprise-1" successfully started.
34 Instance "enterprise-1" successfully started.
29
35
36
30 Debug and Logging Configuration
37 Debug and Logging Configuration
31 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
38 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
32
39
@@ -47,7 +54,7 b' the ``debug`` level.'
47 ### LOGGING CONFIGURATION ####
54 ### LOGGING CONFIGURATION ####
48 ################################
55 ################################
49 [loggers]
56 [loggers]
50 keys = root, sqlalchemy, rhodecode, ssh_wrapper
57 keys = root, sqlalchemy, beaker, celery, rhodecode, ssh_wrapper
51
58
52 [handlers]
59 [handlers]
53 keys = console, console_sql, file, file_rotating
60 keys = console, console_sql, file, file_rotating
@@ -62,11 +69,16 b' the ``debug`` level.'
62 level = NOTSET
69 level = NOTSET
63 handlers = console
70 handlers = console
64
71
65 [logger_routes]
72 [logger_sqlalchemy]
73 level = INFO
74 handlers = console_sql
75 qualname = sqlalchemy.engine
76 propagate = 0
77
78 [logger_beaker]
66 level = DEBUG
79 level = DEBUG
67 handlers =
80 handlers =
68 qualname = routes.middleware
81 qualname = beaker.container
69 ## "level = DEBUG" logs the route matched and routing variables.
70 propagate = 1
82 propagate = 1
71
83
72 [logger_rhodecode]
84 [logger_rhodecode]
@@ -75,11 +87,16 b' the ``debug`` level.'
75 qualname = rhodecode
87 qualname = rhodecode
76 propagate = 1
88 propagate = 1
77
89
78 [logger_sqlalchemy]
90 [logger_ssh_wrapper]
79 level = INFO
91 level = DEBUG
80 handlers = console_sql
92 handlers =
81 qualname = sqlalchemy.engine
93 qualname = ssh_wrapper
82 propagate = 0
94 propagate = 1
95
96 [logger_celery]
97 level = DEBUG
98 handlers =
99 qualname = celery
83
100
84 ##############
101 ##############
85 ## HANDLERS ##
102 ## HANDLERS ##
@@ -88,18 +105,18 b' the ``debug`` level.'
88 [handler_console]
105 [handler_console]
89 class = StreamHandler
106 class = StreamHandler
90 args = (sys.stderr,)
107 args = (sys.stderr, )
91 level = INFO
108 level = DEBUG
92 formatter = generic
109 formatter = generic
93
110
94 [handler_console_sql]
111 [handler_console_sql]
95 class = StreamHandler
112 class = StreamHandler
96 args = (sys.stderr,)
113 args = (sys.stderr, )
97 level = WARN
114 level = INFO
98 formatter = generic
115 formatter = generic
99
116
100 [handler_file]
117 [handler_file]
101 class = FileHandler
118 class = FileHandler
102 args = ('rhodecode.log', 'a',)
119 args = ('rhodecode_debug.log', 'a',)
103 level = INFO
120 level = INFO
104 formatter = generic
121 formatter = generic
105
122
@@ -107,6 +124,25 b' the ``debug`` level.'
107 class = logging.handlers.TimedRotatingFileHandler
124 class = logging.handlers.TimedRotatingFileHandler
108 # 'D', 5 - rotate every 5days
125 # 'D', 5 - rotate every 5days
109 # you can set 'h', 'midnight'
126 # you can set 'h', 'midnight'
110 args = ('rhodecode.log', 'D', 5, 10,)
127 args = ('rhodecode_debug_rotated.log', 'D', 5, 10,)
111 level = INFO
128 level = INFO
112 formatter = generic
129 formatter = generic
130
131 ################
132 ## FORMATTERS ##
133 ################
134
135 [formatter_generic]
136 class = rhodecode.lib.logging_formatter.ExceptionAwareFormatter
137 format = %(asctime)s.%(msecs)03d [%(process)d] %(levelname)-5.5s [%(name)s] %(message)s
138 datefmt = %Y-%m-%d %H:%M:%S
139
140 [formatter_color_formatter]
141 class = rhodecode.lib.logging_formatter.ColorFormatter
142 format = %(asctime)s.%(msecs)03d [%(process)d] %(levelname)-5.5s [%(name)s] %(message)s
143 datefmt = %Y-%m-%d %H:%M:%S
144
145 [formatter_color_formatter_sql]
146 class = rhodecode.lib.logging_formatter.ColorFormatterSql
147 format = %(asctime)s.%(msecs)03d [%(process)d] %(levelname)-5.5s [%(name)s] %(message)s
148 datefmt = %Y-%m-%d %H:%M:%S No newline at end of file
@@ -89,6 +89,10 b' def make_pyramid_app(global_config, **se'
89 # will be replaced by the value of the environment variable "NAME" in this case.
89 # will be replaced by the value of the environment variable "NAME" in this case.
90 start_time = time.time()
90 start_time = time.time()
91
91
92 debug = asbool(global_config.get('debug'))
93 if debug:
94 enable_debug()
95
92 environ = {'ENV_{}'.format(key): value for key, value in os.environ.items()}
96 environ = {'ENV_{}'.format(key): value for key, value in os.environ.items()}
93
97
94 global_config = _substitute_values(global_config, environ)
98 global_config = _substitute_values(global_config, environ)
@@ -118,6 +122,7 b' def make_pyramid_app(global_config, **se'
118 total_time = time.time() - start_time
122 total_time = time.time() - start_time
119 log.info('Pyramid app `%s` created and configured in %.2fs',
123 log.info('Pyramid app `%s` created and configured in %.2fs',
120 pyramid_app.func_name, total_time)
124 pyramid_app.func_name, total_time)
125
121 return pyramid_app
126 return pyramid_app
122
127
123
128
@@ -432,6 +437,114 b' def sanitize_settings_and_apply_defaults'
432 return settings
437 return settings
433
438
434
439
440 def enable_debug():
441 """
442 Helper to enable debug on running instance
443 :return:
444 """
445 import tempfile
446 import textwrap
447 import logging.config
448
449 ini_template = textwrap.dedent("""
450 #####################################
451 ### DEBUG LOGGING CONFIGURATION ####
452 #####################################
453 [loggers]
454 keys = root, sqlalchemy, beaker, celery, rhodecode, ssh_wrapper
455
456 [handlers]
457 keys = console, console_sql
458
459 [formatters]
460 keys = generic, color_formatter, color_formatter_sql
461
462 #############
463 ## LOGGERS ##
464 #############
465 [logger_root]
466 level = NOTSET
467 handlers = console
468
469 [logger_sqlalchemy]
470 level = INFO
471 handlers = console_sql
472 qualname = sqlalchemy.engine
473 propagate = 0
474
475 [logger_beaker]
476 level = DEBUG
477 handlers =
478 qualname = beaker.container
479 propagate = 1
480
481 [logger_rhodecode]
482 level = DEBUG
483 handlers =
484 qualname = rhodecode
485 propagate = 1
486
487 [logger_ssh_wrapper]
488 level = DEBUG
489 handlers =
490 qualname = ssh_wrapper
491 propagate = 1
492
493 [logger_celery]
494 level = DEBUG
495 handlers =
496 qualname = celery
497
498
499 ##############
500 ## HANDLERS ##
501 ##############
502
503 [handler_console]
504 class = StreamHandler
505 args = (sys.stderr, )
506 level = DEBUG
507 formatter = color_formatter
508
509 [handler_console_sql]
510 # "level = DEBUG" logs SQL queries and results.
511 # "level = INFO" logs SQL queries.
512 # "level = WARN" logs neither. (Recommended for production systems.)
513 class = StreamHandler
514 args = (sys.stderr, )
515 level = WARN
516 formatter = color_formatter_sql
517
518 ################
519 ## FORMATTERS ##
520 ################
521
522 [formatter_generic]
523 class = rhodecode.lib.logging_formatter.ExceptionAwareFormatter
524 format = %(asctime)s.%(msecs)03d [%(process)d] %(levelname)-5.5s [%(name)s] %(message)s | %(req_id)s
525 datefmt = %Y-%m-%d %H:%M:%S
526
527 [formatter_color_formatter]
528 class = rhodecode.lib.logging_formatter.ColorRequestTrackingFormatter
529 format = %(asctime)s.%(msecs)03d [%(process)d] %(levelname)-5.5s [%(name)s] %(message)s | %(req_id)s
530 datefmt = %Y-%m-%d %H:%M:%S
531
532 [formatter_color_formatter_sql]
533 class = rhodecode.lib.logging_formatter.ColorFormatterSql
534 format = %(asctime)s.%(msecs)03d [%(process)d] %(levelname)-5.5s [%(name)s] %(message)s
535 datefmt = %Y-%m-%d %H:%M:%S
536 """)
537
538 with tempfile.NamedTemporaryFile(prefix='rc_debug_logging_', suffix='.ini',
539 delete=False) as f:
540 log.info('Saved Temporary DEBUG config at %s', f.name)
541 f.write(ini_template)
542
543 logging.config.fileConfig(f.name)
544 log.debug('DEBUG MODE ON')
545 os.remove(f.name)
546
547
435 def _sanitize_appenlight_settings(settings):
548 def _sanitize_appenlight_settings(settings):
436 _bool_setting(settings, 'appenlight', 'false')
549 _bool_setting(settings, 'appenlight', 'false')
437
550
@@ -14,7 +14,6 b' function registerRCRoutes() {'
14 // routes registration
14 // routes registration
15 pyroutes.register('favicon', '/favicon.ico', []);
15 pyroutes.register('favicon', '/favicon.ico', []);
16 pyroutes.register('robots', '/robots.txt', []);
16 pyroutes.register('robots', '/robots.txt', []);
17 pyroutes.register('auth_home', '/_admin/auth*traverse', []);
18 pyroutes.register('global_integrations_new', '/_admin/integrations/new', []);
17 pyroutes.register('global_integrations_new', '/_admin/integrations/new', []);
19 pyroutes.register('global_integrations_home', '/_admin/integrations', []);
18 pyroutes.register('global_integrations_home', '/_admin/integrations', []);
20 pyroutes.register('global_integrations_list', '/_admin/integrations/%(integration)s', ['integration']);
19 pyroutes.register('global_integrations_list', '/_admin/integrations/%(integration)s', ['integration']);
@@ -30,6 +29,7 b' function registerRCRoutes() {'
30 pyroutes.register('repo_integrations_list', '/%(repo_name)s/settings/integrations/%(integration)s', ['repo_name', 'integration']);
29 pyroutes.register('repo_integrations_list', '/%(repo_name)s/settings/integrations/%(integration)s', ['repo_name', 'integration']);
31 pyroutes.register('repo_integrations_create', '/%(repo_name)s/settings/integrations/%(integration)s/new', ['repo_name', 'integration']);
30 pyroutes.register('repo_integrations_create', '/%(repo_name)s/settings/integrations/%(integration)s/new', ['repo_name', 'integration']);
32 pyroutes.register('repo_integrations_edit', '/%(repo_name)s/settings/integrations/%(integration)s/%(integration_id)s', ['repo_name', 'integration', 'integration_id']);
31 pyroutes.register('repo_integrations_edit', '/%(repo_name)s/settings/integrations/%(integration)s/%(integration_id)s', ['repo_name', 'integration', 'integration_id']);
32 pyroutes.register('auth_home', '/_admin/auth*traverse', []);
33 pyroutes.register('ops_ping', '/_admin/ops/ping', []);
33 pyroutes.register('ops_ping', '/_admin/ops/ping', []);
34 pyroutes.register('ops_error_test', '/_admin/ops/error', []);
34 pyroutes.register('ops_error_test', '/_admin/ops/error', []);
35 pyroutes.register('ops_redirect_test', '/_admin/ops/redirect', []);
35 pyroutes.register('ops_redirect_test', '/_admin/ops/redirect', []);
General Comments 0
You need to be logged in to leave comments. Login now