From c8782375675b7430a879da9fed16fcaa576628bb Mon Sep 17 00:00:00 2001 From: Asim Aslam Date: Sat, 11 Apr 2020 11:22:02 +0100 Subject: [PATCH] fix log file creation --- runtime/default.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/runtime/default.go b/runtime/default.go index e8b567c5..2ef813ff 100644 --- a/runtime/default.go +++ b/runtime/default.go @@ -40,6 +40,10 @@ func NewRuntime(opts ...Option) Runtime { o(&options) } + // make the logs directory + path := filepath.Join(os.TempDir(), "micro", "logs") + _ = os.MkdirAll(path, 0755) + return &runtime{ options: options, closed: make(chan bool), @@ -177,8 +181,10 @@ func (r *runtime) run(events <-chan Event) { } func logFile(serviceName string) string { + // make the directory name := strings.Replace(serviceName, "/", "-", -1) - return filepath.Join(os.TempDir(), "micro", "logs", fmt.Sprintf("%v.log", name)) + path := filepath.Join(os.TempDir(), "micro", "logs") + return filepath.Join(path, fmt.Sprintf("%v.log", name)) } // Create creates a new service which is then started by runtime