From 47bdceb77a6c7c4db3937c4eac4447a79eea181e Mon Sep 17 00:00:00 2001 From: Karl Gustav Sterneberg <kg@roxen.com> Date: Tue, 10 Dec 2019 14:04:30 +0100 Subject: [PATCH] Search.Utils.Logger: Added support for specifying indentation width when creating a Logger instance. [WS-581] --- lib/modules/Search.pmod/Utils.pmod | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/modules/Search.pmod/Utils.pmod b/lib/modules/Search.pmod/Utils.pmod index 86b28c9449..b5412407c0 100644 --- a/lib/modules/Search.pmod/Utils.pmod +++ b/lib/modules/Search.pmod/Utils.pmod @@ -672,6 +672,8 @@ class Logger { private int last_log_purge_time; private constant log_purge_freq = 8*60*60; // Purge log every 8 h or so. + private string indentation = " "; + private Sql.Sql get_db() { Sql.Sql db; #if constant(DBManager) @@ -689,10 +691,13 @@ class Logger { //! @decl void create(Sql.Sql db_object, int profile, int stderr_logging) //! @decl void create(string db_url, int profile, int stderr_logging) - void create(string|Sql.Sql _logdb, int _profile, int _stderr_logging) { + void create(string|Sql.Sql _logdb, int _profile, int _stderr_logging, void|int indentation_width) { logdb = _logdb; profile = _profile; stderr_logging = _stderr_logging; + if (!zero_type(indentation_width)) { + indentation = sprintf("%"+indentation_width+"n"); + } // create table eventlog (event int unsigned auto_increment primary key, // at timestamp not null, code int unsigned not null, extra varchar(255)) @@ -715,8 +720,8 @@ class Logger { "warning" : "Warning", "notice" : "Notice", ]); - werror(sprintf("%sSearch: %s: %s\n", - " : ", + werror(sprintf("%s: Search: %s: %s\n", + indentation, types[type], extra?sprintf(codes[(int)code], @(extra/"\n")):codes[(int)code])); } -- GitLab