Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-62688

User.toString() should print the users ID not fullname

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Minor Minor
    • core
    • None
    • Jenkins 2.243

      User.toString rturns the users full name. 

      However a full name may not be unique and as such when used in log messages we get something that is less than helpful.

       

      toString is generally only used for for debugging and logging aids and as such we should print the user's Id so we can actually identify the user. 
      This also makes it easier to use in log statements as you can just use the code user  rather than user != null ? user.getId() : null  (which when coupled with logging that may not happen removes some code without having to utilize messageSuppliers or surround a one line block with if (Logger.isEnabled(Level.BLAH)) { ... } 

       

          [JENKINS-62688] User.toString() should print the users ID not fullname

          James Nord created issue -
          James Nord made changes -
          Assignee New: James Nord [ teilo ]
          James Nord made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]
          James Nord made changes -
          Description Original: {{[User.toString|[https://github.com/jenkinsci/jenkins/blob/jenkins-2.240/core/src/main/java/hudson/model/User.java]]}} prints the users full name. 

          However a full name may not be unique and as such when used in log messages we get something that is less than helpful.

           

          {{toString}} is generally only used for for debugging and logging aids and as such we should print the user's Id so we can actually identify the user. 
          This also makes it easier to use in log statements as you can just use the code {{user}}  rather than {{user != null ? user.getId() : null}}  (which when coupled with logging that may not happen removes some code without having to utilize {{messageSuppliers}} or surround a one line block with {{if (Logger.isEnabled(Level.BLAH)) \{ ... } }}

           
          New: [{{User.toString}}|[https://github.com/jenkinsci/jenkins/blob/jenkins-2.240/core/src/main/java/hudson/model/User.java]] prints the users full name. 

          However a full name may not be unique and as such when used in log messages we get something that is less than helpful.

           

          {{toString}} is generally only used for for debugging and logging aids and as such we should print the user's Id so we can actually identify the user. 
          This also makes it easier to use in log statements as you can just use the code {{user}}  rather than {{user != null ? user.getId() : null}}  (which when coupled with logging that may not happen removes some code without having to utilize {{messageSuppliers}} or surround a one line block with {{if (Logger.isEnabled(Level.BLAH)) \{ ... } }}

           
          James Nord made changes -
          Description Original: [{{User.toString}}|[https://github.com/jenkinsci/jenkins/blob/jenkins-2.240/core/src/main/java/hudson/model/User.java]] prints the users full name. 

          However a full name may not be unique and as such when used in log messages we get something that is less than helpful.

           

          {{toString}} is generally only used for for debugging and logging aids and as such we should print the user's Id so we can actually identify the user. 
          This also makes it easier to use in log statements as you can just use the code {{user}}  rather than {{user != null ? user.getId() : null}}  (which when coupled with logging that may not happen removes some code without having to utilize {{messageSuppliers}} or surround a one line block with {{if (Logger.isEnabled(Level.BLAH)) \{ ... } }}

           
          New: [{{User.toString}}|https://github.com/jenkinsci/jenkins/blob/jenkins-2.240/core/src/main/java/hudson/model/User.java] prints the users full name. 

          However a full name may not be unique and as such when used in log messages we get something that is less than helpful.

           

          {{toString}} is generally only used for for debugging and logging aids and as such we should print the user's Id so we can actually identify the user. 
          This also makes it easier to use in log statements as you can just use the code {{user}}  rather than {{user != null ? user.getId() : null}}  (which when coupled with logging that may not happen removes some code without having to utilize {{messageSuppliers}} or surround a one line block with {{if (Logger.isEnabled(Level.BLAH)) \{ ... } }}

           
          James Nord made changes -
          Remote Link New: This issue links to "PR #4803 (Web Link)" [ 25210 ]
          James Nord made changes -
          Status Original: In Progress [ 3 ] New: In Review [ 10005 ]
          James Nord made changes -
          Description Original: [{{User.toString}}|https://github.com/jenkinsci/jenkins/blob/jenkins-2.240/core/src/main/java/hudson/model/User.java] prints the users full name. 

          However a full name may not be unique and as such when used in log messages we get something that is less than helpful.

           

          {{toString}} is generally only used for for debugging and logging aids and as such we should print the user's Id so we can actually identify the user. 
          This also makes it easier to use in log statements as you can just use the code {{user}}  rather than {{user != null ? user.getId() : null}}  (which when coupled with logging that may not happen removes some code without having to utilize {{messageSuppliers}} or surround a one line block with {{if (Logger.isEnabled(Level.BLAH)) \{ ... } }}

           
          New: [{{User.toString}}|https://github.com/jenkinsci/jenkins/blob/jenkins-2.240/core/src/main/java/hudson/model/User.java] rturns the users full name. 

          However a full name may not be unique and as such when used in log messages we get something that is less than helpful.

           

          {{toString}} is generally only used for for debugging and logging aids and as such we should print the user's Id so we can actually identify the user. 
           This also makes it easier to use in log statements as you can just use the code {{user}}  rather than {{user != null ? user.getId() : null}}  (which when coupled with logging that may not happen removes some code without having to utilize {{messageSuppliers}} or surround a one line block with {{if (Logger.isEnabled(Level.BLAH)) \{ ... } }}

           
          Oleg Nenashev made changes -
          Released As New: Jenkins 2.243
          Resolution New: Fixed [ 1 ]
          Status Original: In Review [ 10005 ] New: Resolved [ 5 ]
          Daniel Beck made changes -
          Link New: This issue causes JENKINS-63712 [ JENKINS-63712 ]
          Mark Waite made changes -
          Link New: This issue causes JENKINS-63744 [ JENKINS-63744 ]

            Unassigned Unassigned
            teilo James Nord
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: