Add IdentifiedUser#getLoggableName()
Callers that want to include a unique identifier of an IdentifiedUser into a log currently use getUserName() but this method may return null which makes the log useless. Instead of letting every caller handle the null case add a new getLoggableName() method to IdentifiedUser that is guaranteed to return a unique name for the user. We can't offer this method on CurrentUser level since CurrentUser has no access to the account and a user name may not be set. Change-Id: I79433c5e37f8d5186e281c2590578e0aecf85e71 Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
@@ -918,7 +918,7 @@ class ReceiveCommits {
|
||||
reject(cmd, "invalid project configuration");
|
||||
logError(
|
||||
"User "
|
||||
+ user.getUserName()
|
||||
+ user.getLoggableName()
|
||||
+ " tried to push invalid project configuration "
|
||||
+ cmd.getNewId().name()
|
||||
+ " for "
|
||||
@@ -994,7 +994,7 @@ class ReceiveCommits {
|
||||
reject(cmd, "invalid project configuration");
|
||||
logError(
|
||||
"User "
|
||||
+ user.getUserName()
|
||||
+ user.getLoggableName()
|
||||
+ " tried to push invalid project configuration "
|
||||
+ cmd.getNewId().name()
|
||||
+ " for "
|
||||
|
@@ -447,7 +447,7 @@ public class CommitValidators {
|
||||
} catch (ConfigInvalidException | IOException e) {
|
||||
log.error(
|
||||
"User "
|
||||
+ user.getUserName()
|
||||
+ user.getLoggableName()
|
||||
+ " tried to push an invalid project configuration "
|
||||
+ receiveEvent.command.getNewId().name()
|
||||
+ " for project "
|
||||
|
Reference in New Issue
Block a user