We're currently using Log Parser and Timestamper, but the timestamps aren't included in the parsed console output. As a result, our team often has to switch back and forth between parsed and standard console outputs. It would be great if these could somehow work together, even if this meant needing to manually update our regex to account for the timestamps being included at the start of the line (although preferably that wouldn't be necessary).

          [JENKINS-70291] Support using Timestamper with Log Parser

          Marc added a comment -

          The biggest issue for me is that the users are confused due to the offset in the observed time in the LogParser and the console output with timestamper.
          The reason is that the LogParser shows the time from the Jenkins logfile which is in UTC format while the console shows the time corrected for your timezone.

           The timestamper plugin seems to provide a way to be used by other plugins:
          Other plugins can add a dependency on the Timestamper plugin and then use the TimestamperAPI#read method to retrieve the timestamps. 

          mreinhardt  I can have a look to to check if I can add the mentioned dependency. Are you open for such a patch?

          Marc added a comment - The biggest issue for me is that the users are confused due to the offset in the observed time in the LogParser and the console output with timestamper. The reason is that the LogParser shows the time from the Jenkins logfile which is in UTC format while the console shows the time corrected for your timezone.  The timestamper plugin seems to provide a way to be used by other plugins: Other plugins can add a  dependency  on the Timestamper plugin and then use the  TimestamperAPI#read  method to retrieve the timestamps.   mreinhardt   I can have a look to to check if I can add the mentioned dependency. Are you open for such a patch?

          sure, any PR is welcome

          Martin Reinhardt added a comment - sure, any PR is welcome

          Suman added a comment -

          Thank you for checking this.
          Two queries please, could the dependency to timestamper be an optional one?
          Also would the configuration of timestamp in the log parser output follow the timestamper plugin configuration or would that be a similar configuration entry for the logparser plugin?

          Suman added a comment - Thank you for checking this. Two queries please, could the dependency to timestamper be an optional one? Also would the configuration of timestamp in the log parser output follow the timestamper plugin configuration or would that be a similar configuration entry for the logparser plugin?

          Marc added a comment - - edited

          I did not consider to make the dependency optional as it makes it unnecessary complex. 

          For the format of the timestamp I now see 2 options.
           - a fixed timestamp "yyyy-MM-dd HH:MM:ss.SSS" which is most close to the current format (see the patch)
           - make a new configuration field for the logparser plugin where one can set the the format string. The user has to set it independently from the timestamper plugin. 
             I studied how the legacyFormatting configuration is implemented, seems doable for me to apply the same solution for the timestampFormat.

          Note: I am not a java programmer and do not have much experience with Jenkins plugins.

          mreinhardt Please have a look at the patch of the minimum version.  use-timestamper.patch

          Do we want  to make the timestamp format configurable? Is it ok to set it independent from the TimeStamper configuration ?

          Marc added a comment - - edited I did not consider to make the dependency optional as it makes it unnecessary complex.  For the format of the timestamp I now see 2 options.  - a fixed timestamp "yyyy-MM-dd HH:MM:ss.SSS" which is most close to the current format (see the patch)  - make a new configuration field for the logparser plugin where one can set the the format string. The user has to set it independently from the timestamper plugin.     I studied how the legacyFormatting configuration is implemented, seems doable for me to apply the same solution for the timestampFormat. Note: I am not a java programmer and do not have much experience with Jenkins plugins. mreinhardt Please have a look at the patch of the minimum version.   use-timestamper.patch Do we want  to make the timestamp format configurable? Is it ok to set it independent from the TimeStamper configuration ?

          I've added PR for that: https://github.com/jenkinsci/log-parser-plugin/pull/124

          Looks good so far. Anyone tried the changes? My time is currently limiited. If it helps I can provide a preview of the packing plugin as hpi file

          Martin Reinhardt added a comment - I've added PR for that: https://github.com/jenkinsci/log-parser-plugin/pull/124 Looks good so far. Anyone tried the changes? My time is currently limiited. If it helps I can provide a preview of the packing plugin as hpi file

          Marc added a comment - - edited

          Thanks.

          Today I spent some time figuring out how to make the timestamp format pattern configurable. To maintain backward compatibility, the default format pattern is set to an empty string (""). When the format pattern is empty, the timestamp is not formatted, and the files render as they did previously.

          I have prepared the following help text for the Timestamp Format field in the Global Configuration. Please review to ensure this aligns with the desired behavior.

          The system clock time format defines how timestamps will be rendered. The JDK SimpleDateFormat pattern is used.
          When this field is left empty, the default internal Jenkins timestamp format will be used. The Timestamper plugin must be installed if this field is not empty.

          Note: Any changes to the time format will only affect future builds. The Log Parser plugin applies the timestamp format during the build process.

          Please ensure that the format string is a valid SimpleDateFormat pattern.

          Examples of valid formats include:

          • HH:mm:ss - Displays hours, minutes, and seconds.
          • yyyy-MM-dd HH:mm:ss - Displays the date and time up to seconds.

          mreinhardt  Please let me know if am on the right track.

          Marc added a comment - - edited Thanks. Today I spent some time figuring out how to make the timestamp format pattern configurable. To maintain backward compatibility, the default format pattern is set to an empty string (""). When the format pattern is empty, the timestamp is not formatted, and the files render as they did previously. I have prepared the following help text for the Timestamp Format field in the Global Configuration. Please review to ensure this aligns with the desired behavior. The system clock time format defines how timestamps will be rendered. The JDK  SimpleDateFormat  pattern is used. When this field is left empty, the default internal Jenkins timestamp format will be used. The Timestamper plugin must be installed if this field is not empty. Note: Any changes to the time format will only affect future builds. The Log Parser plugin applies the timestamp format during the build process. Please ensure that the format string is a valid  SimpleDateFormat pattern. Examples of valid formats include: HH:mm:ss  - Displays hours, minutes, and seconds. yyyy-MM-dd HH:mm:ss  - Displays the date and time up to seconds. mreinhardt   Please let me know if am on the right track.

          Marc added a comment -

          mreinhardt  Please have a look at the following patch.

          configurable-timestamp-format.patch

          Add global Timestamp format configuration field.

          If this field is left blank or the Timestamper plugin is not installed, the default internal Jenkins timestamp format is used.
          The default value is empty, so the plugin behavior will remain the same unless the Timestamp format is specified.
          An error is shown in the configuration GUI in case the format string is not a valid SimpleDateFormat pattern.
          If a non-empty format string is provided and the Timestamper plugin is not installed, a warning message is shown.
          The dependency on the Timestamper plugin is optional, so the plugin can be used without it.

          Help documentation is available.

          Marc added a comment - mreinhardt   Please have a look at the following patch. configurable-timestamp-format.patch Add global Timestamp format configuration field. If this field is left blank or the Timestamper plugin is not installed, the default internal Jenkins timestamp format is used. The default value is empty, so the plugin behavior will remain the same unless the Timestamp format is specified. An error is shown in the configuration GUI in case the format string is not a valid SimpleDateFormat pattern. If a non-empty format string is provided and the Timestamper plugin is not installed, a warning message is shown. The dependency on the Timestamper plugin is optional, so the plugin can be used without it. Help documentation is available.

            mreinhardt Martin Reinhardt
            caseyjhol Casey Holzer
            Votes:
            2 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: