| 53 | } |
| 54 | |
| 55 | func (l *Logger) SetLogFile(accessPath, errorPath string) error { |
| 56 | l.mu.Lock() |
| 57 | defer l.mu.Unlock() |
| 58 | |
| 59 | var err error |
| 60 | |
| 61 | if l.accessLogFile, err = openLogFile(accessPath); err != nil { |
| 62 | return fmt.Errorf("failed to open access log: %w", err) |
| 63 | } |
| 64 | if l.accessLogFile != nil { |
| 65 | l.accessLogger = log.New(l.accessLogFile, "", 0) |
| 66 | } |
| 67 | |
| 68 | if l.errorLogFile, err = openLogFile(errorPath); err != nil { |
| 69 | return fmt.Errorf("failed to open error log: %w", err) |
| 70 | } |
| 71 | if l.errorLogFile != nil { |
| 72 | l.errorLogger = log.New(l.errorLogFile, "", 0) |
| 73 | } |
| 74 | |
| 75 | return nil |
| 76 | } |
| 77 | |
| 78 | func (l *Logger) Log(level LogLevel, message string) { |
| 79 | l.mu.RLock() |