瀏覽代碼

Merge pull request #3 from mgansler/log_format

Shell script log format
Jan B 9 年之前
父節點
當前提交
400dba9355
共有 1 個文件被更改,包括 3 次插入3 次删除
  1. 3 3
      cert-renewal-haproxy.sh

+ 3 - 3
cert-renewal-haproxy.sh

@@ -35,7 +35,7 @@ function issueCert {
 function logger_error {
   if [ -n "${LOGFILE}" ]
   then
-    echo "[error] ${1}\n" >> ${LOGFILE}
+    echo "[error] [$(date +'%d.%m.%y - %H:%M')] ${1}" >> ${LOGFILE}
   fi
   >&2 echo "[error] ${1}"
 }
@@ -43,7 +43,7 @@ function logger_error {
 function logger_info {
   if [ -n "${LOGFILE}" ]
   then
-    echo "[info] ${1}\n" >> ${LOGFILE}
+    echo "[info] [$(date +'%d.%m.%y - %H:%M')] ${1}" >> ${LOGFILE}
   else
     echo "[info] ${1}"
   fi
@@ -106,4 +106,4 @@ if [ "${#renewed_certs[@]}" -gt 0 ]; then
   fi
 fi
 
-exit ${exitcode}
+exit ${exitcode}