comparison doc/admin_guide.txt @ 8433:de1dac9abcb6

feat: change comment in dictConfig json file to // from # Emacs json mode at least will properly indent when using // as a comment character and not #.
author John Rouillard <rouilj@ieee.org>
date Tue, 26 Aug 2025 22:24:00 -0400
parents 7f7749d86da8
children 1a93dc58f975
comparison
equal deleted inserted replaced
8432:7f7749d86da8 8433:de1dac9abcb6
108 108
109 dictConfigs are specified in JSON format with support for comments. 109 dictConfigs are specified in JSON format with support for comments.
110 The file name in the tracker's config for the ``logging`` -> ``config`` 110 The file name in the tracker's config for the ``logging`` -> ``config``
111 setting must end with ``.json`` to choose the correct processing. 111 setting must end with ``.json`` to choose the correct processing.
112 112
113 Comments have to be in one of two forms: 113 Comments have to be in one of two forms based on javascript line
114 114 comments:
115 1. A ``#`` with preceding white space is considered a comment and is 115
116 stripped from the file before being passed to the json parser. This 116 1. A ``//`` possibly indented with whitespace on a line is considereda
117 is a "block comment". 117 a comment and is stripped from the file before being passed to the
118 118 json parser. This is a "line comment".
119 2. A ``#`` preceded by at least three 119
120 white space characters is stripped from the end of the line before 120 2. A ``//` with at least three white space characters before it is
121 begin passed to the json parser. This is an "inline comment". 121 stripped from the end of the line before begin passed to the json
122 parser. This is an "inline comment".
123
124 Block style comments are not supported.
122 125
123 Other than this the file is a standard json file that matches the 126 Other than this the file is a standard json file that matches the
124 `Configuration dictionary schema 127 `Configuration dictionary schema
125 <https://docs.python.org/3/library/logging.config.html#configuration-dictionary-schema>`_ 128 <https://docs.python.org/3/library/logging.config.html#configuration-dictionary-schema>`_
126 defined in the Python documentation. 129 defined in the Python documentation.
127 130
128 131
129 Example dictConfig Logging Config 132 Example dictConfig Logging Config
130 ................................. 133 .................................
131 134
132 Note that this file is not actually JSON format as it include comments. 135 Note that this file is not actually JSON format as it include
133 So you can not use tools that expect JSON (linters, formatters) to 136 comments. However by using javascript style comments, some tools that
134 work with it. 137 expect JSON (editors, linters, formatters) might work with it. A
138 command like ``sed -e 's#^\s*//.*##' -e 's#\s*\s\s\s//.*##'
139 logging.json`` can be used to strip comments for programs that need
140 it.
135 141
136 The config below works with the `Waitress wsgi server 142 The config below works with the `Waitress wsgi server
137 <https://github.com/Pylons/waitress>`_ configured to use the 143 <https://github.com/Pylons/waitress>`_ configured to use the
138 roundup.wsgi channel. It also controls the `TransLogger middleware 144 roundup.wsgi channel. It also controls the `TransLogger middleware
139 <https://github.com/pasteorg/paste>`_ configured to use 145 <https://github.com/pasteorg/paste>`_ configured to use
141 log file is specified relative to the current working directory not 147 log file is specified relative to the current working directory not
142 the tracker home. The tracker home is the subdirectory demo under the 148 the tracker home. The tracker home is the subdirectory demo under the
143 current working directory. The commented config is:: 149 current working directory. The commented config is::
144 150
145 { 151 {
146 "version": 1, # only supported version 152 "version": 1, // only supported version
147 "disable_existing_loggers": false, # keep the wsgi loggers 153 "disable_existing_loggers": false, // keep the wsgi loggers
148 154
149 "formatters": { 155 "formatters": {
150 # standard format for Roundup messages 156 // standard format for Roundup messages
151 "standard": { 157 "standard": {
152 "format": "%(asctime)s %(levelname)s %(name)s:%(module)s %(msg)s" 158 "format": "%(asctime)s %(ctx_id)s %(levelname)s %(name)s:%(module)s %(msg)s"
153 }, 159 },
154 # used for waitress wsgi server to produce httpd style logs 160 // used for waitress wsgi server to produce httpd style logs
155 "http": { 161 "http": {
156 "format": "%(message)s" 162 "format": "%(message)s"
157 } 163 }
158 }, 164 },
159 "handlers": { 165 "handlers": {
160 # create an access.log style http log file 166 // create an access.log style http log file
161 "access": { 167 "access": {
162 "level": "INFO", 168 "level": "INFO",
163 "formatter": "http", 169 "formatter": "http",
164 "class": "logging.FileHandler", 170 "class": "logging.FileHandler",
165 "filename": "demo/access.log" 171 "filename": "demo/access.log"
166 }, 172 },
167 # logging for roundup.* loggers 173 // logging for roundup.* loggers
168 "roundup": { 174 "roundup": {
169 "level": "DEBUG", 175 "level": "DEBUG",
170 "formatter": "standard", 176 "formatter": "standard",
171 "class": "logging.FileHandler", 177 "class": "logging.FileHandler",
172 "filename": "demo/roundup.log" 178 "filename": "demo/roundup.log"
173 }, 179 },
174 # print to stdout - fall through for other logging 180 // print to stdout - fall through for other logging
175 "default": { 181 "default": {
176 "level": "DEBUG", 182 "level": "DEBUG",
177 "formatter": "standard", 183 "formatter": "standard",
178 "class": "logging.StreamHandler", 184 "class": "logging.StreamHandler",
179 "stream": "ext://sys.stdout" 185 "stream": "ext://sys.stdout"
185 "default" 191 "default"
186 ], 192 ],
187 "level": "DEBUG", 193 "level": "DEBUG",
188 "propagate": false 194 "propagate": false
189 }, 195 },
190 # used by roundup.* loggers 196 // used by roundup.* loggers
191 "roundup": { 197 "roundup": {
192 "handlers": [ 198 "handlers": [
193 "roundup" 199 "roundup"
194 ], 200 ],
195 "level": "DEBUG", 201 "level": "DEBUG",
196 "propagate": false # note pytest testing with caplog requires 202 "propagate": false // note pytest testing with caplog requires
197 # this to be true 203 // this to be true
198 }, 204 },
199 "roundup.hyperdb": { 205 "roundup.hyperdb": {
200 "handlers": [ 206 "handlers": [
201 "roundup" 207 "roundup"
202 ], 208 ],
203 "level": "INFO", # can be a little noisy use INFO for production 209 "level": "INFO", // can be a little noisy use INFO for production
204 "propagate": false 210 "propagate": false
205 }, 211 },
206 "roundup.wsgi": { # using the waitress framework 212 "roundup.wsgi": { // using the waitress framework
207 "handlers": [ 213 "handlers": [
208 "roundup" 214 "roundup"
209 ], 215 ],
210 "level": "DEBUG", 216 "level": "DEBUG",
211 "propagate": false 217 "propagate": false
212 }, 218 },
213 "roundup.wsgi.translogger": { # httpd style logging 219 "roundup.wsgi.translogger": { // httpd style logging
214 "handlers": [ 220 "handlers": [
215 "access" 221 "access"
216 ], 222 ],
217 "level": "DEBUG", 223 "level": "DEBUG",
218 "propagate": false 224 "propagate": false

Roundup Issue Tracker: http://roundup-tracker.org/