File tree Expand file tree Collapse file tree 3 files changed +21
-8
lines changed
Expand file tree Collapse file tree 3 files changed +21
-8
lines changed Original file line number Diff line number Diff line change @@ -9,26 +9,31 @@ _log() {
99 shift 3
1010
1111 local line
12- line=" $( date ' +%Y-%m-%d %H:%M:%S' ) [${level} ] $* "
12+ local now
13+ now=" $( date ' +%Y-%m-%d %H:%M:%S' ) "
14+ line=" ${now} [${level} ] $* "
15+ local label
16+ label=" [${level} ]"
1317
1418 if [[ " $stream " == " stderr" ]]; then
1519 if [[ -t 2 ]]; then
16- printf ' \033[%sm%s\033[0m\n' " $color " " $line " >&2
20+ printf ' %s \033[%sm%s\033[0m %s \n' " $now " " $ color" " $label " " $* " >&2
1721 else
1822 printf ' %s\n' " $line " >&2
1923 fi
2024 return
2125 fi
2226
2327 if [[ -t 1 ]]; then
24- printf ' \033[%sm%s\033[0m\n' " $color " " $line "
28+ printf ' %s \033[%sm%s\033[0m %s \n' " $now " " $ color" " $label " " $* "
2529 return
2630 fi
2731
2832 printf ' %s\n' " $line "
2933}
3034
3135log_info () { _log " INFO" " 32" " stdout" " $@ " ; }
36+ log_warn () { _log " WARN" " 33" " stdout" " $@ " ; }
3237log_success () { log_info " $@ " ; }
3338log_error () { _log " ERROR" " 31" " stderr" " $@ " ; }
3439
Original file line number Diff line number Diff line change @@ -12,25 +12,28 @@ _log() {
1212 now=" $( date ' +%Y-%m-%d %H:%M:%S' ) "
1313 local line
1414 line=" ${now} [${level} ] $* "
15+ local label
16+ label=" [${level} ]"
1517
1618 if [[ " $stream " == " stderr" ]]; then
1719 if [[ -t 2 ]]; then
18- printf ' \033[%sm%s\033[0m\n' " $color " " $line " >&2
20+ printf ' %s \033[%sm%s\033[0m %s \n' " $now " " $ color" " $label " " $* " >&2
1921 else
2022 printf ' %s\n' " $line " >&2
2123 fi
2224 return
2325 fi
2426
2527 if [[ -t 1 ]]; then
26- printf ' \033[%sm%s\033[0m\n' " $color " " $line "
28+ printf ' %s \033[%sm%s\033[0m %s \n' " $now " " $ color" " $label " " $* "
2729 return
2830 fi
2931
3032 printf ' %s\n' " $line "
3133}
3234
3335log_info () { _log " INFO" " 32" " stdout" " $@ " ; }
36+ log_warn () { _log " WARN" " 33" " stdout" " $@ " ; }
3437log_success () { log_info " $@ " ; }
3538log_error () { _log " ERROR" " 31" " stderr" " $@ " ; }
3639
Original file line number Diff line number Diff line change @@ -9,26 +9,31 @@ _log() {
99 shift 3
1010
1111 local line
12- line=" $( date ' +%Y-%m-%d %H:%M:%S' ) [${level} ] $* "
12+ local now
13+ now=" $( date ' +%Y-%m-%d %H:%M:%S' ) "
14+ line=" ${now} [${level} ] $* "
15+ local label
16+ label=" [${level} ]"
1317
1418 if [[ " $stream " == " stderr" ]]; then
1519 if [[ -t 2 ]]; then
16- printf ' \033[%sm%s\033[0m\n' " $color " " $line " >&2
20+ printf ' %s \033[%sm%s\033[0m %s \n' " $now " " $ color" " $label " " $* " >&2
1721 else
1822 printf ' %s\n' " $line " >&2
1923 fi
2024 return
2125 fi
2226
2327 if [[ -t 1 ]]; then
24- printf ' \033[%sm%s\033[0m\n' " $color " " $line "
28+ printf ' %s \033[%sm%s\033[0m %s \n' " $now " " $ color" " $label " " $* "
2529 return
2630 fi
2731
2832 printf ' %s\n' " $line "
2933}
3034
3135log_info () { _log " INFO" " 32" " stdout" " $@ " ; }
36+ log_warn () { _log " WARN" " 33" " stdout" " $@ " ; }
3237log_success () { log_info " $@ " ; }
3338log_error () { _log " ERROR" " 31" " stderr" " $@ " ; }
3439
You can’t perform that action at this time.
0 commit comments