diff options
| author | Christophe Monniez <moc@odoo.com> | 2020-04-24 11:59:18 +0000 |
|---|---|---|
| committer | Christophe Monniez <moc@odoo.com> | 2020-04-27 15:20:02 +0000 |
| commit | 397158b6df3996f071293aaa3908085bea379285 (patch) | |
| tree | 0439f6064853d06fab7baa602f832704c56bb77d /odoo | |
| parent | 02a5be42054e8c83b579bc81466645fcaad1ce46 (diff) | |
[FIX] core: log full path in ir_logging when using postgresql handler
When the PostgreSQLHandler is used to store some logs in the ir_logging
table of a database, the log record pathname is truncated to keep only
the relevant part of the path. In some circumstances, the path is
wrongly truncated, leading to totally invalid paths.
e.g.: When using an addon-path like `/data/build/enteprise` the removed
part correspond to the length of `/data/build/odoo/`. The resulting path
is `prise/....`.
With this commit, the full path is kept.
This commit is mainly a fix for the runbot logs and should not have an
impact on existing databases.
closes odoo/odoo#50246
X-original-commit: f3c96aa21ad0d8756fadc1608107438ba8cd6c05
Signed-off-by: Christophe Monniez (moc) <moc@odoo.com>
Diffstat (limited to 'odoo')
| -rw-r--r-- | odoo/netsvc.py | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/odoo/netsvc.py b/odoo/netsvc.py index 3e387352d0d..e3e2fa57204 100644 --- a/odoo/netsvc.py +++ b/odoo/netsvc.py @@ -24,8 +24,6 @@ def log(logger, level, prefix, msg, depth=None): logger.log(level, indent+line) indent=indent_after -path_prefix = os.path.realpath(os.path.dirname(os.path.dirname(__file__))) - class PostgreSQLHandler(logging.Handler): """ PostgreSQL Logging Handler will store logs in the database, by default the current database, can be set using --log-db=DBNAME @@ -48,7 +46,7 @@ class PostgreSQLHandler(logging.Handler): # we do not use record.levelname because it may have been changed by ColoredFormatter. levelname = logging.getLevelName(record.levelno) - val = ('server', ct_db, record.name, levelname, msg, record.pathname[len(path_prefix)+1:], record.lineno, record.funcName) + val = ('server', ct_db, record.name, levelname, msg, record.pathname, record.lineno, record.funcName) cr.execute(""" INSERT INTO ir_logging(create_date, type, dbname, name, level, message, path, line, func) VALUES (NOW() at time zone 'UTC', %s, %s, %s, %s, %s, %s, %s, %s) |
