MCPcopy Create free account
hub / github.com/chainreactors/EvilProxy / ResolveLogDirectory

Function ResolveLogDirectory

internal/logging/global_logger.go:139–157  ·  view source on GitHub ↗

ResolveLogDirectory determines the directory used for application logs.

(cfg *config.Config)

Source from the content-addressed store, hash-verified

137
138// ResolveLogDirectory determines the directory used for application logs.
139func ResolveLogDirectory(cfg *config.Config) string {
140 logDir := "logs"
141 if base := util.WritablePath(); base != "" {
142 return filepath.Join(base, "logs")
143 }
144 if cfg == nil {
145 return logDir
146 }
147 if !isDirWritable(logDir) {
148 authDir, err := util.ResolveAuthDir(cfg.AuthDir)
149 if err != nil {
150 log.Warnf("Failed to resolve auth-dir %q for log directory: %v", cfg.AuthDir, err)
151 }
152 if authDir != "" {
153 logDir = filepath.Join(authDir, "logs")
154 }
155 }
156 return logDir
157}
158
159// ConfigureLogOutput switches the global log destination between rotating files and stdout.
160// When logsMaxTotalSizeMB > 0, a background cleaner removes the oldest log files in the logs directory

Callers 4

NewServerFunction · 0.92
logDirectoryMethod · 0.92
ConfigureLogOutputFunction · 0.85

Calls 3

WritablePathFunction · 0.92
ResolveAuthDirFunction · 0.92
isDirWritableFunction · 0.85

Tested by

no test coverage detected