(chanLog chanLog, level string)
| 125 | } |
| 126 | |
| 127 | func (l *xLog) writeLog(chanLog chanLog, level string) { |
| 128 | filePath := l.logRootPath + chanLog.LogTarget |
| 129 | switch level { |
| 130 | case "custom": |
| 131 | filePath = filePath + "_" + time.Now().Format(defaultDateFormatForFileName) + ".log" |
| 132 | break |
| 133 | } |
| 134 | log := chanLog.Content |
| 135 | if !chanLog.isRaw { |
| 136 | log = fmt.Sprintf("%s [%s] [%s:%v] %s", time.Now().Format(defaultFullTimeLayout), chanLog.LogLevel, chanLog.logCtx.fileName, chanLog.logCtx.line, chanLog.Content) |
| 137 | } |
| 138 | if l.enabledConsole { |
| 139 | fmt.Println(log) |
| 140 | } |
| 141 | writeFile(filePath, log) |
| 142 | } |
| 143 | |
| 144 | func writeFile(logFile string, log string) { |
| 145 | pathDir := filepath.Dir(logFile) |
no test coverage detected