http://hg.code.sf.net:8000/p/roundup/code/atom-log/tip/roundup/logcontext.py Mercurial Repository: p/roundup/code: roundup/logcontext.py history 2026-04-09T00:09:29-04:00 bug: fix typing for pre 3.9 python. http://hg.code.sf.net:8000/p/roundup/code/#changeset-13732c1d839231f69b715aff04ccd88559f41086 John Rouillard rouilj@ieee.org 2026-04-09T00:09:29-04:00 2026-04-09T00:09:29-04:00
changeset 13732c1d8392
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description bug: fix typing for pre 3.9 python.

when I added basic typing to logcontext.py I used a spec unsupported in
3.8and earlier.
files
feat: improve store_trace_reason with extract parameter http://hg.code.sf.net:8000/p/roundup/code/#changeset-f80c566f5726c55c8654ec24a9f73a138b2c8a6f John Rouillard rouilj@ieee.org 2026-04-06T22:10:23-04:00 2026-04-06T22:10:23-04:00
changeset f80c566f5726
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description feat: improve store_trace_reason with extract parameter

store_trace_reason() used embedded code to extract reason based on the
location passed to the function.

This change adds support for extract keyword that is a Python
expression eval'ed when the underlying function/method is called. All
callers now set the extract parameter. The prior embedded code has
been removed from store_trace_reason().

Failure to eval the expression results in an roundup.logcontext error
severity log. Also updated docs.

Also replaced env['REQUEST_URI'] with env['PATH_INFO'] for web based
entry points as REQUEST_URI isn't documented as a required key and
some other front end (e.g. zope, cgi) might not supply this.
files
feat: add nanoid pkg trace_id gen and decorator for setting processName http://hg.code.sf.net:8000/p/roundup/code/#changeset-b09ef85f0da62646efe031ee76934ee9b158ae07 John Rouillard rouilj@ieee.org 2025-12-08T00:23:14-05:00 2025-12-08T00:23:14-05:00
changeset b09ef85f0da6
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description feat: add nanoid pkg trace_id gen and decorator for setting processName

nanoid is a shorter unique id generator and faster than uuid.
I truncate nanoid id's to 12 chars to make it more readable.

Also added decorator to allow setting the default processName
definition in the logging module. admin.py and wsgi_handler now set
processName. configuration.py knows how to overide the processName if
set to the default MainProcess.

Updated install docs to add nanoid as optional, how to switch to
different trace_id output. pydoc generated docs include logcontext
module and are referenced from admin.py.
files
fix: use getloing value --unknown-- on error. http://hg.code.sf.net:8000/p/roundup/code/#changeset-df9fc9080e5af5e81dd29d35eff02ed4f5fae3d8 John Rouillard rouilj@ieee.org 2025-09-17T01:33:09-04:00 2025-09-17T01:33:09-04:00
changeset df9fc9080e5a
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description fix: use getloing value --unknown-- on error.

In case there is a real user with name unknown, Unlikely for account to
to have dashes in name.
files
fix: os.getlogin fails with OSError in CI. http://hg.code.sf.net:8000/p/roundup/code/#changeset-756cdf8e34f23aa74c0c9f1ce7f5361711f42219 John Rouillard rouilj@ieee.org 2025-09-17T01:31:12-04:00 2025-09-17T01:31:12-04:00
changeset 756cdf8e34f2
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description fix: os.getlogin fails with OSError in CI.
files
fix: remove nolocal on unset param in logcontext.py http://hg.code.sf.net:8000/p/roundup/code/#changeset-3df6b898807490c789e46729fc31f2157040ea54 John Rouillard rouilj@ieee.org 2025-09-17T01:05:35-04:00 2025-09-17T01:05:35-04:00
changeset 3df6b8988074
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description fix: remove nolocal on unset param in logcontext.py

flake8 was failing in ci on it.
files
feature: add thread local trace_id and trace_reason to logging. http://hg.code.sf.net:8000/p/roundup/code/#changeset-14c7c07b32d846e405260147a3112e8c8b15642a John Rouillard rouilj@ieee.org 2025-09-16T22:53:00-04:00 2025-09-16T22:53:00-04:00
changeset 14c7c07b32d8
branch
bookmark
tag
user John Rouillard <rouilj@ieee.org>
description feature: add thread local trace_id and trace_reason to logging.

Added trace_id to default logging so that all logs for a given request
share the same trace_id.

This allows correlation of logs across a request.

admin_guide.txt, upgrading.txt:
add docs
update sample configs to include trace_id.
rewrite logging docs in admin_guide. Hopefully they are clearer now.
clean up some stuff in the logging config file docs.

admin.py:

add decorators to run_command to enable trace_id.
change calls to db.commit() to use run_command to get trace_id.

configuration.py:

clean up imports.
update docstrings, comments and inline docs.
add trace_id to default log format.
add function for testing decorated with trace_id.
add support for dumping stack trace in logging.
add check for pytest in sys.modules to enable log propagation when
pytest is running. Otherwise tests fail as the caplog logger doesn't
see the roundup logs.

logcontext.py:

new file to handle thread local contextvar mangement.

mailgw.py:

add decorators for trace_id etc.

scripts/roundup_xlmrpc_server.py:

add decorators for trace_id etc.
fix encoding bug turning bytes into a string.
fix command line issue where we can't set encoding. (not sure if
changing encoding via command line even works)

cgi/client.py

decorate two entry points for trace_id etc.

cgi/wsgi_handler.py:

decorate entry point for trace_id etc.

test/test_config.py:

add test for trace_id in new log format.
test various cases for sinfo and errors in formating msg.
files