mirror of
				https://github.com/Telecominfraproject/ols-nos.git
				synced 2025-11-04 03:57:57 +00:00 
			
		
		
		
	add timestamp in each job build log example: [01:39:21] dh clean --with autotools-dev [01:39:22] dh_auto_clean [01:39:27] make -j16 distclean Signed-off-by: Guohan Lu <lguohan@gmail.com>
		
			
				
	
	
		
			21 lines
		
	
	
		
			283 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			21 lines
		
	
	
		
			283 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
#!/bin/bash
 | 
						|
 | 
						|
add_timestamp=""
 | 
						|
 | 
						|
while getopts ":t" opt; do
 | 
						|
    case $opt in
 | 
						|
        t)
 | 
						|
            add_timestamp="y"
 | 
						|
            ;;
 | 
						|
    esac
 | 
						|
done
 | 
						|
 | 
						|
while IFS= read -r line; do
 | 
						|
    if [ $add_timestamp ]; then
 | 
						|
        printf '[%s] ' "$(date +%T)"
 | 
						|
    fi
 | 
						|
    printf '%s\n' "$line"
 | 
						|
done
 | 
						|
 | 
						|
 |