Skip to content

test against the latest versions of go #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
language: go

script:
- curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.43.0
- curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.50.0
- golangci-lint run .
- go vet .
- go test .

go:
- 1.15.x
- 1.16.x
- 1.17.x
- 1.18.x
- 1.19.x
34 changes: 18 additions & 16 deletions format.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,18 @@ type stringFormatter struct {
// The verbs:
//
// General:
// %{id} Sequence number for log message (uint64).
// %{pid} Process id (int)
// %{time} Time when log occurred (time.Time)
// %{level} Log level (Level)
// %{module} Module (string)
// %{program} Basename of os.Args[0] (string)
// %{message} Message (string)
// %{longfile} Full file name and line number: /a/b/c/d.go:23
// %{shortfile} Final file name element and line number: d.go:23
// %{callpath} Callpath like main.a.b.c...c "..." meaning recursive call ~. meaning truncated path
// %{color} ANSI color based on log level
//
// %{id} Sequence number for log message (uint64).
// %{pid} Process id (int)
// %{time} Time when log occurred (time.Time)
// %{level} Log level (Level)
// %{module} Module (string)
// %{program} Basename of os.Args[0] (string)
// %{message} Message (string)
// %{longfile} Full file name and line number: /a/b/c/d.go:23
// %{shortfile} Final file name element and line number: d.go:23
// %{callpath} Callpath like main.a.b.c...c "..." meaning recursive call ~. meaning truncated path
// %{color} ANSI color based on log level
//
// For normal types, the output can be customized by using the 'verbs' defined
// in the fmt package, eg. '%{id:04d}' to make the id output be '%04d' as the
Expand All @@ -191,11 +192,12 @@ type stringFormatter struct {
// future.
//
// Experimental:
// %{longpkg} Full package path, eg. github.com/go-logging
// %{shortpkg} Base package path, eg. go-logging
// %{longfunc} Full function name, eg. littleEndian.PutUint32
// %{shortfunc} Base function name, eg. PutUint32
// %{callpath} Call function path, eg. main.a.b.c
//
// %{longpkg} Full package path, eg. github.com/go-logging
// %{shortpkg} Base package path, eg. go-logging
// %{longfunc} Full function name, eg. littleEndian.PutUint32
// %{shortfunc} Base function name, eg. PutUint32
// %{callpath} Call function path, eg. main.a.b.c
func NewStringFormatter(format string) (Formatter, error) {
var fmter = &stringFormatter{}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/keybase/go-logging

go 1.17
go 1.19
2 changes: 1 addition & 1 deletion log_nix.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build !windows
// +build !windows

// Copyright 2013, Örjan Persson. All rights reserved.
Expand Down Expand Up @@ -43,4 +44,3 @@ func (b *LogBackend) Log(level Level, calldepth int, rec *Record) error {

return b.Logger.Output(calldepth+2, rec.Formatted(calldepth+1))
}

16 changes: 8 additions & 8 deletions log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package logging

import (
"bytes"
"io/ioutil"
"io"
"log"
"strings"
"testing"
Expand Down Expand Up @@ -98,34 +98,34 @@ func BenchmarkLogChannelMemoryBackend(b *testing.B) {
}

func BenchmarkLogLeveled(b *testing.B) {
backend := SetBackend(NewLogBackend(ioutil.Discard, "", 0))
backend := SetBackend(NewLogBackend(io.Discard, "", 0))
backend.SetLevel(INFO, "")

RunLogBenchmark(b)
}

func BenchmarkLogLogBackend(b *testing.B) {
backend := SetBackend(NewLogBackend(ioutil.Discard, "", 0))
backend := SetBackend(NewLogBackend(io.Discard, "", 0))
backend.SetLevel(DEBUG, "")
RunLogBenchmark(b)
}

func BenchmarkLogLogBackendColor(b *testing.B) {
colorizer := NewLogBackend(ioutil.Discard, "", 0)
colorizer := NewLogBackend(io.Discard, "", 0)
colorizer.Color = true
backend := SetBackend(colorizer)
backend.SetLevel(DEBUG, "")
RunLogBenchmark(b)
}

func BenchmarkLogLogBackendStdFlags(b *testing.B) {
backend := SetBackend(NewLogBackend(ioutil.Discard, "", log.LstdFlags))
backend := SetBackend(NewLogBackend(io.Discard, "", log.LstdFlags))
backend.SetLevel(DEBUG, "")
RunLogBenchmark(b)
}

func BenchmarkLogLogBackendLongFileFlag(b *testing.B) {
backend := SetBackend(NewLogBackend(ioutil.Discard, "", log.Llongfile))
backend := SetBackend(NewLogBackend(io.Discard, "", log.Llongfile))
backend.SetLevel(DEBUG, "")
RunLogBenchmark(b)
}
Expand All @@ -141,14 +141,14 @@ func RunLogBenchmark(b *testing.B) {
}

func BenchmarkLogFixed(b *testing.B) {
backend := SetBackend(NewLogBackend(ioutil.Discard, "", 0))
backend := SetBackend(NewLogBackend(io.Discard, "", 0))
backend.SetLevel(DEBUG, "")

RunLogBenchmarkFixedString(b)
}

func BenchmarkLogFixedIgnored(b *testing.B) {
backend := SetBackend(NewLogBackend(ioutil.Discard, "", 0))
backend := SetBackend(NewLogBackend(io.Discard, "", 0))
backend.SetLevel(INFO, "")
RunLogBenchmarkFixedString(b)
}
Expand Down
6 changes: 5 additions & 1 deletion log_windows.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//go:build windows
// +build windows

// Copyright 2013, Örjan Persson. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
Expand All @@ -22,7 +24,9 @@ type WORD uint16
// Character attributes
// Note:
// -- The attributes are combined to produce various colors (e.g., Blue + Green will create Cyan).
// Clearing all foreground or background colors results in black; setting all creates white.
//
// Clearing all foreground or background colors results in black; setting all creates white.
//
// See https://msdn.microsoft.com/en-us/library/windows/desktop/ms682088(v=vs.85).aspx#_win32_character_attributes.
const (
fgBlack = 0x0000
Expand Down
1 change: 1 addition & 0 deletions memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build !appengine
// +build !appengine

package logging
Expand Down
3 changes: 2 additions & 1 deletion syslog.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//+build !windows,!plan9
//go:build !windows && !plan9
// +build !windows,!plan9

package logging

Expand Down
3 changes: 2 additions & 1 deletion syslog_fallback.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//+build windows plan9
//go:build windows || plan9
// +build windows plan9

package logging

Expand Down