hook := newBtmHook(logPath)
logrus.AddHook(hook)
- logrus.SetOutput(ioutil.Discard)//控制台不输出
+ logrus.SetOutput(ioutil.Discard) //控制台不输出
fmt.Printf("all logs are output in the %s directory\n", logPath)
return nil
}
func clearLockFiles(logPath string) error {
files, err := ioutil.ReadDir(logPath)
- if err != nil {
+ if os.IsNotExist(err) {
+ return nil
+ }else if err != nil {
return err
}
for _, file := range files {
if ok := strings.HasSuffix(file.Name(), "_lock"); ok {
- if err := os.Remove(filepath.Join(logPath, file.Name()));err!=nil{
+ if err := os.Remove(filepath.Join(logPath, file.Name())); err != nil {
return err
}
}