From 35578985c9cf76f12d8ef6837cc4df02350657e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Pfeuffer?= Date: Wed, 14 Sep 2022 14:35:35 +0200 Subject: [PATCH] Reduce the output from the realm trace log (#2121) This reduces the amount of lines logged with log level 'trace' from the DefaultRealm. This is done by concatenating the single permissions and roles in a single line. A log with the new layout looks something like this (the [...] would list all further permissions in the real log output): TRACE sonia.scm.security.DefaultRealm - authorization summary: username : scmadmin roles : user scope : permissions: repository:*:ChTG0dBeUH , group:autocomplete , repository:*:[...] In contrast, with the old layout it looks like this: TRACE sonia.scm.security.DefaultRealm - authorization summary: username : scmadmin roles : - user scope : permissions: - repository:*:ChTG0dBeUH - group:autocomplete - repository:*:5DTFWwBTiY - repository:*:ASTGBIVz11D - user:changeApiKeys:scmadmin - user:changePassword:scmadmin - user:changePublicKeys:scmadmin - user:readAuthorizedKeys,writeAuthorizedKeys:scmadmin - * - user:read:scmadmin - user:autocomplete - repository:*:4rT7VPex5J --- gradle/changelog/reduce_log.yaml | 2 ++ .../src/main/java/sonia/scm/security/DefaultRealm.java | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 gradle/changelog/reduce_log.yaml diff --git a/gradle/changelog/reduce_log.yaml b/gradle/changelog/reduce_log.yaml new file mode 100644 index 0000000000..75d9c49538 --- /dev/null +++ b/gradle/changelog/reduce_log.yaml @@ -0,0 +1,2 @@ +- type: changed + description: Reduce the output from the realm trace log ([#2121](https://github.com/scm-manager/scm-manager/pull/2121)) diff --git a/scm-webapp/src/main/java/sonia/scm/security/DefaultRealm.java b/scm-webapp/src/main/java/sonia/scm/security/DefaultRealm.java index 63696bc6c4..d03d15e97a 100644 --- a/scm-webapp/src/main/java/sonia/scm/security/DefaultRealm.java +++ b/scm-webapp/src/main/java/sonia/scm/security/DefaultRealm.java @@ -43,6 +43,7 @@ import sonia.scm.plugin.Extension; import javax.inject.Inject; import javax.inject.Singleton; +import java.util.Iterator; import java.util.Set; /** @@ -163,8 +164,11 @@ public class DefaultRealm extends AuthorizingRealm { private void append(StringBuilder buffer, Iterable iterable) { if (iterable != null) { - for (Object item : iterable) { - buffer.append(SEPARATOR).append(" - ").append(item); + for (Iterator iter = iterable.iterator(); iter.hasNext(); ) { + buffer.append(iter.next()); + if (iter.hasNext()) { + buffer.append(" , "); + } } } }