From 652958eefa4b2cfc275422740190dfd803b2f19f Mon Sep 17 00:00:00 2001 From: Kirill Elagin Date: Fri, 8 May 2020 00:11:38 +0300 Subject: [PATCH 1/2] postgres: Do not log timestamp By default, postgres prefixes each log line with a timestamp. On NixOS logs are written to journal anyway, so they include an external timestamp, so the timestamp ends up being printed twice, which clutters the log. * Add a module option to change the log prefix. * Set it to upstream default sans timestamp. --- nixos/modules/services/databases/postgresql.nix | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/nixos/modules/services/databases/postgresql.nix b/nixos/modules/services/databases/postgresql.nix index 0b79a996dc7..269510036a6 100644 --- a/nixos/modules/services/databases/postgresql.nix +++ b/nixos/modules/services/databases/postgresql.nix @@ -17,6 +17,7 @@ let hba_file = '${pkgs.writeText "pg_hba.conf" cfg.authentication}' ident_file = '${pkgs.writeText "pg_ident.conf" cfg.identMap}' log_destination = 'stderr' + log_line_prefix = '${cfg.logLinePrefix}' listen_addresses = '${if cfg.enableTCPIP then "*" else "localhost"}' port = ${toString cfg.port} ${cfg.extraConfig} @@ -192,6 +193,17 @@ in ''; }; + logLinePrefix = mkOption { + type = types.str; + default = "[%p] "; + example = "%m [%p] "; + description = '' + A printf-style string that is output at the beginning of each log line. + Upstream default is '%m [%p] ', i.e. it includes the timestamp. We do + not include the timestamp, because journal has it anyway. + ''; + }; + extraPlugins = mkOption { type = types.listOf types.path; default = []; From 084bd32bad6223882d8f13b48a83b96e8c6a151f Mon Sep 17 00:00:00 2001 From: Kirill Elagin Date: Wed, 13 May 2020 23:33:08 +0300 Subject: [PATCH 2/2] postgresql: Fix formatting in option description Co-authored-by: Mario Rodas --- nixos/modules/services/databases/postgresql.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/services/databases/postgresql.nix b/nixos/modules/services/databases/postgresql.nix index 269510036a6..a65872de2a7 100644 --- a/nixos/modules/services/databases/postgresql.nix +++ b/nixos/modules/services/databases/postgresql.nix @@ -199,7 +199,7 @@ in example = "%m [%p] "; description = '' A printf-style string that is output at the beginning of each log line. - Upstream default is '%m [%p] ', i.e. it includes the timestamp. We do + Upstream default is '%m [%p] ', i.e. it includes the timestamp. We do not include the timestamp, because journal has it anyway. ''; };