likyh commented on code in PR #2656: URL: https://github.com/apache/incubator-devlake/pull/2656#discussion_r948742053
########## models/logger.go: ########## @@ -0,0 +1,56 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package models + +import ( + "fmt" + "github.com/apache/incubator-devlake/plugins/core" + "os" + "path/filepath" +) + +func GetTaskLoggerPath(config *core.LoggerConfig, t *Task) string { Review Comment: Sorry, why these logger files are put in `models/`? ########## logger/stream.go: ########## @@ -0,0 +1,39 @@ +/* +Licensed to the Apache Software Foundation (ASF) under one or more +contributor license agreements. See the NOTICE file distributed with +this work for additional information regarding copyright ownership. +The ASF licenses this file to You under the Apache License, Version 2.0 +(the "License"); you may not use this file except in compliance with +the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package logger + +import ( + "io" + "os" + "path/filepath" +) + +func GetFileStream(path string) (io.Writer, error) { + if path == "" { + return os.Stdout, nil + } + err := os.MkdirAll(filepath.Dir(path), os.ModePerm) + if err != nil { + return nil, err + } + file, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0777) Review Comment: It seems cannot send error message in HTTP request when file not exist. ########## logger/init.go: ########## @@ -48,10 +49,28 @@ func init() { TimestampFormat: "2006-01-02 15:04:05", FullTimestamp: true, }) + basePath := cfg.GetString("LOGGING_DIR") Review Comment: Maybe we should add some error log or panic here if `LOGGING_DIR` is empty? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
