startNewLogFile returns a name for a new log file. It cleans up any old log files with the same baseNamePrefix.
(baseNamePrefix, baseNameSuffix string)
| 307 | // startNewLogFile returns a name for a new log file. |
| 308 | // It cleans up any old log files with the same baseNamePrefix. |
| 309 | func (up *Updater) startNewLogFile(baseNamePrefix, baseNameSuffix string) string { |
| 310 | baseName := fmt.Sprintf("%s-%s-%s.log", baseNamePrefix, |
| 311 | time.Now().Format("20060102T150405"), baseNameSuffix) |
| 312 | |
| 313 | dir := filepath.Join(os.Getenv("ProgramData"), "Tailscale", "Logs") |
| 314 | if err := os.MkdirAll(dir, 0700); err != nil { |
| 315 | up.Logf("failed to create log directory: %v", err) |
| 316 | return filepath.Join(os.TempDir(), baseName) |
| 317 | } |
| 318 | |
| 319 | // TODO(nickkhyl): preserve up to N old log files? |
| 320 | up.cleanupOldDownloads(filepath.Join(dir, baseNamePrefix+"-*.log")) |
| 321 | return filepath.Join(dir, baseName) |
| 322 | } |
no test coverage detected