mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-11 18:11:21 +08:00
fix: optimize report command to avoid creating timestamp directories
- Implement lazy loading for directory creation in config.go - Add logFile parameter to InitLogger for better control - Use dynamic directory existence check instead of flags - Report command now uses console-only logging to prevent directory creation - Support both JSON and colorized console output formats - Maintain backward compatibility for all other commands Changes: - config.go: Convert directory paths to getter methods with lazy creation - logger.go: Add logFile parameter and improve logging control - cmd/root.go: Detect report command and disable file logging - uixt/*: Update all references to use new getter methods Fixes the issue where 'hrp report results/' would create unwanted timestamp directories
This commit is contained in:
@@ -46,7 +46,9 @@ GitHub: https://github.com/httprunner/httprunner
|
||||
|
||||
Copyright © 2017-present debugtalk. Apache-2.0 License.`,
|
||||
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
||||
hrp.InitLogger(logLevel, logJSON)
|
||||
// For report command, don't create log files to avoid creating directories
|
||||
enableLogFile := cmd.Name() != "report"
|
||||
hrp.InitLogger(logLevel, logJSON, enableLogFile)
|
||||
},
|
||||
Version: version.GetVersionInfo(),
|
||||
TraverseChildren: true, // parses flags on all parents before executing child command
|
||||
|
||||
Reference in New Issue
Block a user