feat: replace log with logrus

This commit is contained in:
debugtalk
2021-10-17 11:51:49 +08:00
parent ef535a6f6b
commit 2fd45a5d63
10 changed files with 59 additions and 59 deletions

View File

@@ -5,7 +5,6 @@ import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/url"
"os"
"path/filepath"
@@ -13,6 +12,7 @@ import (
"strings"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
"github.com/httprunner/hrp"
)
@@ -120,7 +120,7 @@ func (h *HAR) prepareTestSteps() ([]*hrp.TStep, error) {
}
func (h *HAR) prepareTestStep(entry *Entry) (*hrp.TStep, error) {
log.Printf("[prepareTestStep] %v %v", entry.Request.Method, entry.Request.URL)
log.Infof("[prepareTestStep] %v %v", entry.Request.Method, entry.Request.URL)
tStep := &TStep{
TStep: hrp.TStep{
Request: &hrp.TRequest{},
@@ -164,7 +164,7 @@ func (s *TStep) makeRequestURL(entry *Entry) error {
u, err := url.Parse(entry.Request.URL)
if err != nil {
log.Printf("makeRequestURL error: %v", err)
log.Errorf("makeRequestURL error: %v", err)
return err
}
s.Request.URL = fmt.Sprintf("%s://%s", u.Scheme, u.Hostname()+u.Path)
@@ -211,7 +211,7 @@ func (s *TStep) makeRequestBody(entry *Entry) error {
var body interface{}
err := json.Unmarshal([]byte(entry.Request.PostData.Text), &body)
if err != nil {
log.Printf("makeRequestBody error: %v", err)
log.Errorf("makeRequestBody error: %v", err)
return err
}
s.Request.Body = body

View File

@@ -1,7 +1,6 @@
package har2case
import (
"log"
"testing"
"github.com/stretchr/testify/assert"
@@ -14,7 +13,6 @@ var (
func TestGenJSON(t *testing.T) {
jsonPath, err := NewHAR(harPath).GenJSON()
log.Printf("jsonPath: %v, err: %v", jsonPath, err)
if !assert.NoError(t, err) {
t.Fail()
}
@@ -25,7 +23,6 @@ func TestGenJSON(t *testing.T) {
func TestGenYAML(t *testing.T) {
yamlPath, err := NewHAR(harPath2).GenYAML()
log.Printf("yamlPath: %v, err: %v", yamlPath, err)
if !assert.NoError(t, err) {
t.Fail()
}