mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-05 15:37:35 +08:00
change: PersistentPreRun log setting
This commit is contained in:
@@ -18,11 +18,6 @@ var boomCmd = &cobra.Command{
|
|||||||
$ hrp boom examples/ # run testcases in specified folder`,
|
$ hrp boom examples/ # run testcases in specified folder`,
|
||||||
Args: cobra.MinimumNArgs(1),
|
Args: cobra.MinimumNArgs(1),
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
hrp.SetLogLevel(logLevel)
|
|
||||||
if !logJSON {
|
|
||||||
hrp.SetLogPretty()
|
|
||||||
}
|
|
||||||
|
|
||||||
var paths []hrp.ITestCase
|
var paths []hrp.ITestCase
|
||||||
for _, arg := range args {
|
for _, arg := range args {
|
||||||
paths = append(paths, &hrp.TestCasePath{Path: arg})
|
paths = append(paths, &hrp.TestCasePath{Path: arg})
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import (
|
|||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
|
||||||
"github.com/httprunner/hrp"
|
|
||||||
"github.com/httprunner/hrp/har2case"
|
"github.com/httprunner/hrp/har2case"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -15,11 +14,6 @@ var har2caseCmd = &cobra.Command{
|
|||||||
Long: `Convert HAR to json/yaml testcase files`,
|
Long: `Convert HAR to json/yaml testcase files`,
|
||||||
Args: cobra.MinimumNArgs(1),
|
Args: cobra.MinimumNArgs(1),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
hrp.SetLogLevel(logLevel)
|
|
||||||
if !logJSON {
|
|
||||||
hrp.SetLogPretty()
|
|
||||||
}
|
|
||||||
|
|
||||||
var outputFiles []string
|
var outputFiles []string
|
||||||
for _, arg := range args {
|
for _, arg := range args {
|
||||||
var outputPath string
|
var outputPath string
|
||||||
|
|||||||
@@ -18,6 +18,12 @@ var RootCmd = &cobra.Command{
|
|||||||
License: Apache-2.0
|
License: Apache-2.0
|
||||||
Github: https://github.com/httprunner/hrp
|
Github: https://github.com/httprunner/hrp
|
||||||
Copyright 2021 debugtalk`,
|
Copyright 2021 debugtalk`,
|
||||||
|
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
||||||
|
if !logJSON {
|
||||||
|
hrp.SetLogPretty()
|
||||||
|
}
|
||||||
|
hrp.SetLogLevel(logLevel)
|
||||||
|
},
|
||||||
Version: hrp.VERSION,
|
Version: hrp.VERSION,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,11 +16,6 @@ var runCmd = &cobra.Command{
|
|||||||
$ hrp run examples/ # run testcases in specified folder`,
|
$ hrp run examples/ # run testcases in specified folder`,
|
||||||
Args: cobra.MinimumNArgs(1),
|
Args: cobra.MinimumNArgs(1),
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
RunE: func(cmd *cobra.Command, args []string) error {
|
||||||
hrp.SetLogLevel(logLevel)
|
|
||||||
if !logJSON {
|
|
||||||
hrp.SetLogPretty()
|
|
||||||
}
|
|
||||||
|
|
||||||
var paths []hrp.ITestCase
|
var paths []hrp.ITestCase
|
||||||
for _, arg := range args {
|
for _, arg := range args {
|
||||||
paths = append(paths, &hrp.TestCasePath{Path: arg})
|
paths = append(paths, &hrp.TestCasePath{Path: arg})
|
||||||
|
|||||||
@@ -30,8 +30,8 @@ func SetLogLevel(level string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func SetLogPretty() {
|
func SetLogPretty() {
|
||||||
log.Info().Msg("Set log to pretty console")
|
|
||||||
log = log.Output(zerolog.ConsoleWriter{Out: os.Stderr})
|
log = log.Output(zerolog.ConsoleWriter{Out: os.Stderr})
|
||||||
|
log.Info().Msg("Set log to pretty console")
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetLogger() zerolog.Logger {
|
func GetLogger() zerolog.Logger {
|
||||||
|
|||||||
Reference in New Issue
Block a user