Skip to content

Commit f1f4643

Browse files
authored
Remove go1.17 support (#21)
1 parent ef67c62 commit f1f4643

File tree

11 files changed

+50
-50
lines changed

11 files changed

+50
-50
lines changed

.github/workflows/go.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
build:
1212
strategy:
1313
matrix:
14-
go: [ '1.17','1.18','1.19','1.20' ]
14+
go: [ '1.18','1.19','1.20' ]
1515
os: [ 'ubuntu-latest', 'windows-latest', 'macos-latest' ]
1616
runs-on: ${{ matrix.os }}
1717
steps:

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v0.2.3
1+
v0.3.0

base_logger.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,36 +20,36 @@ type baseLogger struct {
2020
optMu sync.RWMutex // protect Option
2121
}
2222

23-
func (l *baseLogger) Debug(format string, args ...interface{}) {
23+
func (l *baseLogger) Debug(format string, args ...any) {
2424
l.log(level.DebugLevel, format, args...)
2525
}
2626

27-
func (l *baseLogger) Info(format string, args ...interface{}) {
27+
func (l *baseLogger) Info(format string, args ...any) {
2828
l.log(level.InfoLevel, format, args...)
2929
}
3030

31-
func (l *baseLogger) Warn(format string, args ...interface{}) {
31+
func (l *baseLogger) Warn(format string, args ...any) {
3232
l.log(level.WarnLevel, format, args...)
3333
}
3434

35-
func (l *baseLogger) Error(err error, format string, args ...interface{}) {
35+
func (l *baseLogger) Error(err error, format string, args ...any) {
3636
l.logWithErr(err, level.ErrorLevel, format, args...)
3737
}
3838

3939
// Log write a format log
40-
func (l *baseLogger) Log(format string, args ...interface{}) {
40+
func (l *baseLogger) Log(format string, args ...any) {
4141
format = formatter.AppendRowTerminator(format)
4242
if len(args) > 0 {
4343
format = fmt.Sprintf(format, args...)
4444
}
4545
l.Write([]byte(format))
4646
}
4747

48-
func (l *baseLogger) log(lvl level.Level, format string, args ...interface{}) {
48+
func (l *baseLogger) log(lvl level.Level, format string, args ...any) {
4949
l.logWithErr(nil, lvl, format, args...)
5050
}
5151

52-
func (l *baseLogger) logWithErr(err error, lvl level.Level, format string, args ...interface{}) {
52+
func (l *baseLogger) logWithErr(err error, lvl level.Level, format string, args ...any) {
5353
if checkLogLevel(l.lvl, lvl) {
5454
l.optMu.RLock()
5555
c := content.NewContent(lvl, err, l.appendTime, l.timeFormat, format, args...)

content/content.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ import (
88

99
// Content the log content info
1010
type Content struct {
11-
Level level.Level `json:"level"`
12-
Time *Time `json:"time,omitempty"`
13-
Log string `json:"log"`
14-
Error error `json:"-"`
15-
AppendTime bool `json:"-"`
16-
Args []interface{} `json:"-"`
11+
Level level.Level `json:"level"`
12+
Time *Time `json:"time,omitempty"`
13+
Log string `json:"log"`
14+
Error error `json:"-"`
15+
AppendTime bool `json:"-"`
16+
Args []any `json:"-"`
1717
}
1818

1919
// NewContent return an instance of Content
20-
func NewContent(lvl level.Level, err error, appendTime bool, timeFormat string, log string, args ...interface{}) Content {
20+
func NewContent(lvl level.Level, err error, appendTime bool, timeFormat string, log string, args ...any) Content {
2121
var t *Time
2222
if appendTime {
2323
t = NewTimeWithFormat(time.Now(), timeFormat)
@@ -26,7 +26,7 @@ func NewContent(lvl level.Level, err error, appendTime bool, timeFormat string,
2626
}
2727

2828
// NewContentWithTime return an instance of Content with specified time
29-
func NewContentWithTime(lvl level.Level, err error, t *Time, log string, args ...interface{}) Content {
29+
func NewContentWithTime(lvl level.Level, err error, t *Time, log string, args ...any) Content {
3030
c := Content{
3131
Level: lvl,
3232
Log: log,

default_logger.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,63 +33,63 @@ func InitDefaultLoggerWithSample(logger Logger, sampleRate float64) {
3333
}
3434

3535
// Debug write the debug log
36-
func Debug(format string, args ...interface{}) {
36+
func Debug(format string, args ...any) {
3737
DefaultLogger().Debug(format, args...)
3838
}
3939

4040
// Info write the info log
41-
func Info(format string, args ...interface{}) {
41+
func Info(format string, args ...any) {
4242
DefaultLogger().Info(format, args...)
4343
}
4444

4545
// Warn write the warn log
46-
func Warn(format string, args ...interface{}) {
46+
func Warn(format string, args ...any) {
4747
DefaultLogger().Warn(format, args...)
4848
}
4949

5050
// Error write the error log
51-
func Error(err error, format string, args ...interface{}) {
51+
func Error(err error, format string, args ...any) {
5252
DefaultLogger().Error(err, format, args...)
5353
}
5454

5555
// ErrorIf write the error log if err is not nil
56-
func ErrorIf(err error, format string, args ...interface{}) error {
56+
func ErrorIf(err error, format string, args ...any) error {
5757
if err != nil {
5858
Error(err, format, args...)
5959
}
6060
return err
6161
}
6262

6363
// DebugSample write the debug log by random sampling
64-
func DebugSample(format string, args ...interface{}) {
64+
func DebugSample(format string, args ...any) {
6565
DefaultSampleLogger().Debug(format, args...)
6666
}
6767

6868
// InfoSample write the info log by random sampling
69-
func InfoSample(format string, args ...interface{}) {
69+
func InfoSample(format string, args ...any) {
7070
DefaultSampleLogger().Info(format, args...)
7171
}
7272

7373
// WarnSample write the warn log by random sampling
74-
func WarnSample(format string, args ...interface{}) {
74+
func WarnSample(format string, args ...any) {
7575
DefaultSampleLogger().Warn(format, args...)
7676
}
7777

7878
// ErrorSample write the error log by random sampling
79-
func ErrorSample(err error, format string, args ...interface{}) {
79+
func ErrorSample(err error, format string, args ...any) {
8080
DefaultSampleLogger().Error(err, format, args...)
8181
}
8282

8383
// ErrorIfSample write the error log by random sampling if err is not nil
84-
func ErrorIfSample(err error, format string, args ...interface{}) error {
84+
func ErrorIfSample(err error, format string, args ...any) error {
8585
if err != nil {
8686
ErrorSample(err, format, args...)
8787
}
8888
return err
8989
}
9090

9191
// Log write the log without level
92-
func Log(format string, args ...interface{}) {
92+
func Log(format string, args ...any) {
9393
DefaultLogger().Log(format, args...)
9494
}
9595

empty_logger.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,23 @@ func NewEmptyLogger() Logger {
1313
return logger
1414
}
1515

16-
func (l *emptyLogger) Debug(format string, args ...interface{}) {
16+
func (l *emptyLogger) Debug(format string, args ...any) {
1717

1818
}
1919

20-
func (l *emptyLogger) Info(format string, args ...interface{}) {
20+
func (l *emptyLogger) Info(format string, args ...any) {
2121

2222
}
2323

24-
func (l *emptyLogger) Warn(format string, args ...interface{}) {
24+
func (l *emptyLogger) Warn(format string, args ...any) {
2525

2626
}
2727

28-
func (l *emptyLogger) Error(err error, format string, args ...interface{}) {
28+
func (l *emptyLogger) Error(err error, format string, args ...any) {
2929

3030
}
3131

32-
func (l *emptyLogger) Log(format string, args ...interface{}) {
32+
func (l *emptyLogger) Log(format string, args ...any) {
3333

3434
}
3535

file_logger.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ func (l *fileLogger) write() {
187187
}
188188
}
189189

190-
func (l *fileLogger) innerLog(format string, args ...interface{}) {
190+
func (l *fileLogger) innerLog(format string, args ...any) {
191191
fmt.Printf(format+"\n", args...)
192192
}
193193

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module github.com/no-src/log
22

3-
go 1.17
3+
go 1.18

logger.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@ type Logger interface {
1313
Writer
1414
Option
1515

16-
Debug(format string, args ...interface{})
17-
Info(format string, args ...interface{})
18-
Warn(format string, args ...interface{})
19-
Error(err error, format string, args ...interface{})
16+
Debug(format string, args ...any)
17+
Info(format string, args ...any)
18+
Warn(format string, args ...any)
19+
Error(err error, format string, args ...any)
2020
}
2121

2222
// Writer implement write to log
2323
type Writer interface {
2424
io.Writer
2525

2626
// Log write log to output
27-
Log(format string, args ...interface{})
27+
Log(format string, args ...any)
2828
// Close to close log and release dependencies
2929
Close() error
3030
}

multi_logger.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,31 @@ func NewMultiLogger(loggers ...Logger) Logger {
1919
return logger
2020
}
2121

22-
func (l *multiLogger) Debug(format string, args ...interface{}) {
22+
func (l *multiLogger) Debug(format string, args ...any) {
2323
for _, logger := range l.loggers {
2424
logger.Debug(format, args...)
2525
}
2626
}
2727

28-
func (l *multiLogger) Info(format string, args ...interface{}) {
28+
func (l *multiLogger) Info(format string, args ...any) {
2929
for _, logger := range l.loggers {
3030
logger.Info(format, args...)
3131
}
3232
}
3333

34-
func (l *multiLogger) Warn(format string, args ...interface{}) {
34+
func (l *multiLogger) Warn(format string, args ...any) {
3535
for _, logger := range l.loggers {
3636
logger.Warn(format, args...)
3737
}
3838
}
3939

40-
func (l *multiLogger) Error(err error, format string, args ...interface{}) {
40+
func (l *multiLogger) Error(err error, format string, args ...any) {
4141
for _, logger := range l.loggers {
4242
logger.Error(err, format, args...)
4343
}
4444
}
4545

46-
func (l *multiLogger) Log(format string, args ...interface{}) {
46+
func (l *multiLogger) Log(format string, args ...any) {
4747
for _, logger := range l.loggers {
4848
logger.Log(format, args...)
4949
}

0 commit comments

Comments
 (0)