MCPcopy Index your code
hub / github.com/tailscale/tailscale / startNewLogFile

Method startNewLogFile

clientupdate/clientupdate_windows.go:309–322  ·  view source on GitHub ↗

startNewLogFile returns a name for a new log file. It cleans up any old log files with the same baseNamePrefix.

(baseNamePrefix, baseNameSuffix string)

Source from the content-addressed store, hash-verified

307// startNewLogFile returns a name for a new log file.
308// It cleans up any old log files with the same baseNamePrefix.
309func (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}

Callers 2

installMSIMethod · 0.95
switchOutputToFileMethod · 0.95

Calls 5

cleanupOldDownloadsMethod · 0.95
NowMethod · 0.65
LogfMethod · 0.65
TempDirMethod · 0.65
FormatMethod · 0.45

Tested by

no test coverage detected