diff --git a/.gitignore b/.gitignore index 93fd3de..4d9c245 100644 --- a/.gitignore +++ b/.gitignore @@ -38,3 +38,4 @@ dist/ # env files that usually contain secrets or local config .env .envrc +.log diff --git a/crontab-go.log b/crontab-go.log deleted file mode 100644 index f48eb71..0000000 --- a/crontab-go.log +++ /dev/null @@ -1,12 +0,0 @@ -{"level":"debug","method":"post","msg":"sending get http request","retry":0,"section":"Crontab-GO","time":"2024-06-06T11:44:41.759Z","url":"http://127.0.0.1:9085/"} -{"level":"warning","method":"post","msg":"request failed","section":"Crontab-GO","time":"2024-06-06T11:44:41.759Z","url":"http://127.0.0.1:9085/"} -{"level":"debug","method":"post","msg":"waiting 2s before executing the next iteration after last fail","retry":1,"section":"Crontab-GO","time":"2024-06-06T11:44:41.760Z","url":"http://127.0.0.1:9085/"} -{"level":"debug","method":"post","msg":"sending get http request","retry":1,"section":"Crontab-GO","time":"2024-06-06T11:44:43.760Z","url":"http://127.0.0.1:9085/"} -{"level":"warning","method":"post","msg":"request failed","section":"Crontab-GO","time":"2024-06-06T11:44:43.760Z","url":"http://127.0.0.1:9085/"} -{"level":"debug","method":"post","msg":"waiting 2s before executing the next iteration after last fail","retry":2,"section":"Crontab-GO","time":"2024-06-06T11:44:43.760Z","url":"http://127.0.0.1:9085/"} -{"level":"debug","method":"post","msg":"sending get http request","retry":2,"section":"Crontab-GO","time":"2024-06-06T11:44:45.761Z","url":"http://127.0.0.1:9085/"} -{"level":"warning","method":"post","msg":"request failed","section":"Crontab-GO","time":"2024-06-06T11:44:45.761Z","url":"http://127.0.0.1:9085/"} -{"level":"debug","method":"post","msg":"waiting 2s before executing the next iteration after last fail","retry":3,"section":"Crontab-GO","time":"2024-06-06T11:44:45.761Z","url":"http://127.0.0.1:9085/"} -{"level":"debug","method":"post","msg":"sending get http request","retry":3,"section":"Crontab-GO","time":"2024-06-06T11:44:47.762Z","url":"http://127.0.0.1:9085/"} -{"level":"warning","method":"post","msg":"request failed","section":"Crontab-GO","time":"2024-06-06T11:44:47.763Z","url":"http://127.0.0.1:9085/"} -{"level":"debug","method":"post","msg":"waiting 2s before executing the next iteration after last fail","retry":4,"section":"Crontab-GO","time":"2024-06-06T11:44:47.763Z","url":"http://127.0.0.1:9085/"} diff --git a/logger/writer.go b/logger/writer.go index 6333979..e0bfaf9 100644 --- a/logger/writer.go +++ b/logger/writer.go @@ -26,9 +26,10 @@ func (w *writer) Write(b []byte) (n int, e error) { if w.file != nil { wf, er := w.file.Write(b) - if wf != n { + if wf != n && n != 0 { return n, fmt.Errorf("wrote two different amount of log into stdout(%d) and file(%d)", written, wf) } + n = wf if er != nil { err = er }