Skip to content

Commit

Permalink
bugfix: use right logger time format (#1907)
Browse files Browse the repository at this point in the history
  • Loading branch information
kakaZhou719 authored Dec 6, 2022
1 parent 04c7e71 commit db8e0c6
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 10 deletions.
14 changes: 5 additions & 9 deletions pkg/cluster-runtime/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,15 @@ import (
"strings"

"github.com/sealerio/sealer/common"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
k8syaml "k8s.io/apimachinery/pkg/util/yaml"

"github.com/sealerio/sealer/pkg/env"
"github.com/sealerio/sealer/pkg/infradriver"
v1 "github.com/sealerio/sealer/types/api/v1"
netUtils "github.com/sealerio/sealer/utils/net"
"github.com/sealerio/sealer/utils/yaml"

"github.com/sirupsen/logrus"

"github.com/sealerio/sealer/pkg/infradriver"
netUtils "github.com/sealerio/sealer/utils/net"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
k8syaml "k8s.io/apimachinery/pkg/util/yaml"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion pkg/logger/formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const (
)

const (
defaultTimestampFormat = "2006-01-02 15:03:04"
defaultTimestampFormat = "2006-01-02 15:04:05"
)

func getColorByLevel(level logrus.Level) int {
Expand Down
48 changes: 48 additions & 0 deletions pkg/logger/logger_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright © 2022 Alibaba Group Holding Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package logger

import (
"fmt"
"sync"
"testing"
"time"

"github.com/sirupsen/logrus"
)

func TestLogger_Print(t *testing.T) {
if err := Init(LogOptions{
LogToFile: false,
Verbose: true,
DisableColor: false,
}); err != nil {
panic(fmt.Sprintf("failed to init logger: %v\n", err))
}

wg := &sync.WaitGroup{}
for i := 0; i < 5; i++ {
logrus.Info("start to test log")
for j := 0; j < 5; j++ {
wg.Add(1)
go func(x int) {
time.Sleep(1 * time.Second)
logrus.Debugf("i am the true entry %d", x)
wg.Done()
}(j)
}
wg.Wait()
}
}

0 comments on commit db8e0c6

Please sign in to comment.