···7272 inherit (cfg) plugins;
7373 };
74747575- logConfig = logName: {
7575+ defaultCommonLogConfig = {
7676 version = 1;
7777 formatters.journal_fmt.format = "%(name)s: [%(request)s] %(message)s";
7878 handlers.journal = {
7979 class = "systemd.journal.JournalHandler";
8080 formatter = "journal_fmt";
8181- SYSLOG_IDENTIFIER = logName;
8281 };
8382 root = {
8483 level = "INFO";
···8685 };
8786 disable_existing_loggers = false;
8887 };
8888+8989+ defaultCommonLogConfigText = generators.toPretty { } defaultCommonLogConfig;
9090+8991 logConfigText = logName:
9090- let
9191- expr = ''
9292- {
9393- version = 1;
9494- formatters.journal_fmt.format = "%(name)s: [%(request)s] %(message)s";
9595- handlers.journal = {
9696- class = "systemd.journal.JournalHandler";
9797- formatter = "journal_fmt";
9898- SYSLOG_IDENTIFIER = "${logName}";
9999- };
100100- root = {
101101- level = "INFO";
102102- handlers = [ "journal" ];
103103- };
104104- disable_existing_loggers = false;
105105- };
106106- '';
107107- in
10892 lib.literalMD ''
10993 Path to a yaml file generated from this Nix expression:
1109411195 ```
112112- ${expr}
9696+ ${generators.toPretty { } (
9797+ recursiveUpdate defaultCommonLogConfig { handlers.journal.SYSLOG_IDENTIFIER = logName; }
9898+ )}
11399 ```
114100 '';
115115- genLogConfigFile = logName: format.generate "synapse-log-${logName}.yaml" (logConfig logName);
101101+102102+ genLogConfigFile = logName: format.generate
103103+ "synapse-log-${logName}.yaml"
104104+ (cfg.log // optionalAttrs (cfg.log?handlers.journal) {
105105+ handlers.journal = cfg.log.handlers.journal // {
106106+ SYSLOG_IDENTIFIER = logName;
107107+ };
108108+ });
116109in {
117110118111 imports = [
···393386 description = lib.mdDoc ''
394387 The directory where matrix-synapse stores its stateful data such as
395388 certificates, media and uploads.
389389+ '';
390390+ };
391391+392392+ log = mkOption {
393393+ type = types.attrsOf format.type;
394394+ defaultText = literalExpression defaultCommonLogConfigText;
395395+ description = mdDoc ''
396396+ Default configuration for the loggers used by `matrix-synapse` and its workers.
397397+ The defaults are added with the default priority which means that
398398+ these will be merged with additional declarations. These additional
399399+ declarations also take precedence over the defaults when declared
400400+ with at least normal priority. For instance
401401+ the log-level for synapse and its workers can be changed like this:
402402+403403+ ```nix
404404+ { lib, ... }: {
405405+ services.matrix-synapse.log.root.level = "WARNING";
406406+ }
407407+ ```
408408+409409+ And another field can be added like this:
410410+411411+ ```nix
412412+ {
413413+ services.matrix-synapse.log = {
414414+ loggers."synapse.http.matrixfederationclient".level = "DEBUG";
415415+ };
416416+ }
417417+ ```
418418+419419+ Additionally, the field `handlers.journal.SYSLOG_IDENTIFIER` will be added to
420420+ each log config, i.e.
421421+ * `synapse` for `matrix-synapse.service`
422422+ * `synapse-<worker name>` for `matrix-synapse-worker-<worker name>.service`
423423+424424+ This is only done if this option has a `handlers.journal` field declared.
425425+426426+ To discard all settings declared by this option for each worker and synapse,
427427+ `lib.mkForce` can be used.
428428+429429+ To discard all settings declared by this option for a single worker or synapse only,
430430+ [](#opt-services.matrix-synapse.workers._name_.worker_log_config) or
431431+ [](#opt-services.matrix-synapse.settings.log_config) can be used.
396432 '';
397433 };
398434···99210289931029 # default them, so they are additive
9941030 services.matrix-synapse.extras = defaultExtras;
10311031+10321032+ services.matrix-synapse.log = mapAttrsRecursive (const mkDefault) defaultCommonLogConfig;
99510339961034 users.users.matrix-synapse = {
9971035 group = "matrix-synapse";