(logPath string)
| 57 | var LogFilePath string |
| 58 | |
| 59 | func CreateLog(logPath string) { |
| 60 | |
| 61 | if logPath == "" { |
| 62 | Debug("create default log") |
| 63 | createDefaultLog() |
| 64 | return |
| 65 | } |
| 66 | |
| 67 | os.MkdirAll(filepath.Dir(logPath), 0777) |
| 68 | if f, err := os.Create(logPath); err != nil { |
| 69 | Warnf("create log %s err: %s, create default log", logPath, err) |
| 70 | createDefaultLog() |
| 71 | } else { |
| 72 | Debugf("log file: %s", logPath) |
| 73 | LogFilePath = logPath |
| 74 | log.SetOutput(f) |
| 75 | } |
| 76 | |
| 77 | } |
| 78 | |
| 79 | func createDefaultLog() { |
| 80 |
no test coverage detected