[ 
https://jira.codehaus.org/browse/MNG-519?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=281982#comment-281982
 ] 

Mark Michaelis commented on MNG-519:
------------------------------------

I am quite satisfied with the [shell script|https://gist.github.com/993139] I 
am using. Unfortunately it works only on Linux -- maybe with Cygwin, too:
{code}
#!/bin/bash
#
# Prepends a date string in front of the Maven output.
# A workaround for http://jira.codehaus.org/browse/MNG-519 "Timestamps on 
messages"

[ -z "${AWK}" ] && AWK="$(which gawk 2>/dev/null)" || AWK="$(which awk 
2>/dev/null)" || { echo "Error: Could not find AWK tool."; exit 1; }
"${AWK}" 'BEGIN { print strftime("%Y-%m-%d %H:%M:%S"); }' 2>&1 > /dev/null || { 
echo "Error: your AWK version does not support strftime() function." && exit 1; 
}

mvn "${@}" 2>&1 |"${AWK}" '{ print strftime("%Y-%m-%d %H:%M:%S"), $0; fflush(); 
}'
# see comp.unix.shell FAQ: (http://cfajohnson.com/shell/cus-faq-2.html)
# "How do I get the exit code of cmd1 in cmd1|cmd2"
exit ${PIPESTATUS[0]}
{code}

Follow the link to my [Gist|https://gist.github.com/993139] for the most recent 
version.

> Timestamps on messages
> ----------------------
>
>                 Key: MNG-519
>                 URL: https://jira.codehaus.org/browse/MNG-519
>             Project: Maven 2 & 3
>          Issue Type: New Feature
>          Components: Logging, Plugins and Lifecycle
>            Reporter: Jeff Jensen
>            Priority: Minor
>             Fix For: 3.x / Backlog
>
>
> With current and/or moving forward with M2, I would like an option for 
> timestamped messages.
> We have a somewhat long nightly process.  I regularly wish for timestamps on 
> the log messages from the Maven build.  The two primary reasons for this are 
> duration calculation - how long did something take, and an occasional 
> correlation with an outside event.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to