···72 inherit (cfg) plugins;
73 };
7475- logConfig = logName: {
76 version = 1;
77 formatters.journal_fmt.format = "%(name)s: [%(request)s] %(message)s";
78 handlers.journal = {
79 class = "systemd.journal.JournalHandler";
80 formatter = "journal_fmt";
81- SYSLOG_IDENTIFIER = logName;
82 };
83 root = {
84 level = "INFO";
···86 };
87 disable_existing_loggers = false;
88 };
00089 logConfigText = logName:
90- let
91- expr = ''
92- {
93- version = 1;
94- formatters.journal_fmt.format = "%(name)s: [%(request)s] %(message)s";
95- handlers.journal = {
96- class = "systemd.journal.JournalHandler";
97- formatter = "journal_fmt";
98- SYSLOG_IDENTIFIER = "${logName}";
99- };
100- root = {
101- level = "INFO";
102- handlers = [ "journal" ];
103- };
104- disable_existing_loggers = false;
105- };
106- '';
107- in
108 lib.literalMD ''
109 Path to a yaml file generated from this Nix expression:
110111 ```
112- ${expr}
00113 ```
114 '';
115- genLogConfigFile = logName: format.generate "synapse-log-${logName}.yaml" (logConfig logName);
0000000116in {
117118 imports = [
···393 description = lib.mdDoc ''
394 The directory where matrix-synapse stores its stateful data such as
395 certificates, media and uploads.
0000000000000000000000000000000000000000000396 '';
397 };
398···992993 # default them, so they are additive
994 services.matrix-synapse.extras = defaultExtras;
00995996 users.users.matrix-synapse = {
997 group = "matrix-synapse";
···72 inherit (cfg) plugins;
73 };
7475+ defaultCommonLogConfig = {
76 version = 1;
77 formatters.journal_fmt.format = "%(name)s: [%(request)s] %(message)s";
78 handlers.journal = {
79 class = "systemd.journal.JournalHandler";
80 formatter = "journal_fmt";
081 };
82 root = {
83 level = "INFO";
···85 };
86 disable_existing_loggers = false;
87 };
88+89+ defaultCommonLogConfigText = generators.toPretty { } defaultCommonLogConfig;
90+91 logConfigText = logName:
00000000000000000092 lib.literalMD ''
93 Path to a yaml file generated from this Nix expression:
9495 ```
96+ ${generators.toPretty { } (
97+ recursiveUpdate defaultCommonLogConfig { handlers.journal.SYSLOG_IDENTIFIER = logName; }
98+ )}
99 ```
100 '';
101+102+ genLogConfigFile = logName: format.generate
103+ "synapse-log-${logName}.yaml"
104+ (cfg.log // optionalAttrs (cfg.log?handlers.journal) {
105+ handlers.journal = cfg.log.handlers.journal // {
106+ SYSLOG_IDENTIFIER = logName;
107+ };
108+ });
109in {
110111 imports = [
···386 description = lib.mdDoc ''
387 The directory where matrix-synapse stores its stateful data such as
388 certificates, media and uploads.
389+ '';
390+ };
391+392+ log = mkOption {
393+ type = types.attrsOf format.type;
394+ defaultText = literalExpression defaultCommonLogConfigText;
395+ description = mdDoc ''
396+ Default configuration for the loggers used by `matrix-synapse` and its workers.
397+ The defaults are added with the default priority which means that
398+ these will be merged with additional declarations. These additional
399+ declarations also take precedence over the defaults when declared
400+ with at least normal priority. For instance
401+ the log-level for synapse and its workers can be changed like this:
402+403+ ```nix
404+ { lib, ... }: {
405+ services.matrix-synapse.log.root.level = "WARNING";
406+ }
407+ ```
408+409+ And another field can be added like this:
410+411+ ```nix
412+ {
413+ services.matrix-synapse.log = {
414+ loggers."synapse.http.matrixfederationclient".level = "DEBUG";
415+ };
416+ }
417+ ```
418+419+ Additionally, the field `handlers.journal.SYSLOG_IDENTIFIER` will be added to
420+ each log config, i.e.
421+ * `synapse` for `matrix-synapse.service`
422+ * `synapse-<worker name>` for `matrix-synapse-worker-<worker name>.service`
423+424+ This is only done if this option has a `handlers.journal` field declared.
425+426+ To discard all settings declared by this option for each worker and synapse,
427+ `lib.mkForce` can be used.
428+429+ To discard all settings declared by this option for a single worker or synapse only,
430+ [](#opt-services.matrix-synapse.workers._name_.worker_log_config) or
431+ [](#opt-services.matrix-synapse.settings.log_config) can be used.
432 '';
433 };
434···10281029 # default them, so they are additive
1030 services.matrix-synapse.extras = defaultExtras;
1031+1032+ services.matrix-synapse.log = mapAttrsRecursive (const mkDefault) defaultCommonLogConfig;
10331034 users.users.matrix-synapse = {
1035 group = "matrix-synapse";