Skip to content
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

Up deps #168

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
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
41 changes: 41 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Continuous integration
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
tests:
strategy:
matrix:
os: [ ubuntu-16.04, ubuntu-20.04, macos-10.15, windows-2019 ] # list of os: https://github.com/actions/virtual-environments
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2
- run: git submodule update --init --recursive --force
- uses: actions/setup-go@v2
with:
go-version: 1.16.x
- name: Install dependencies
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
sudo apt update && sudo apt install build-essential
fi
shell: bash
- uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ matrix.os }}-go-${{ hashFiles('**/go.sum') }}
- name: Lint
if: matrix.os == 'ubuntu-20.04'
uses: golangci/golangci-lint-action@v2
with:
version: v1.40
skip-go-installation: true
skip-pkg-cache: true
skip-build-cache: true
- run: go test ./...

15 changes: 0 additions & 15 deletions .travis.yml

This file was deleted.

26 changes: 0 additions & 26 deletions handler_go13.go

This file was deleted.

23 changes: 0 additions & 23 deletions handler_go14.go

This file was deleted.

72 changes: 72 additions & 0 deletions v3/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile ~/.gitignore_global

/tmp
*/**/*un~
*/**/*.test
*un~
.DS_Store
*/**/.DS_Store
.ethtest
*/**/*tx_database*
*/**/*dapps*
build/_vendor/pkg
/*.a
docs/readthedocs/build

#*
.#*
*#
*~
.project
.settings

# Used by mdbx Makefile
/ethdb/mdbx/dist/CMakeFiles/*
/ethdb/mdbx/dist/CMakeCache*
/ethdb/mdbx/dist/*.cmake
/ethdb/mdbx/dist/*.dll
/ethdb/mdbx/dist/*.exe
/ethdb/mdbx/dist/Makefile

# used by the Makefile
/build/_workspace/
/build/cache/
/build/bin/
/geth*.zip

# travis
profile.tmp
profile.cov

# IdeaIDE
../.idea

# VS Code
.vscode

# dashboard
/dashboard/assets/flow-typed
/dashboard/assets/node_modules
/dashboard/assets/stats.json
/dashboard/assets/bundle.js
/dashboard/assets/bundle.js.map
/dashboard/assets/package-lock.json

**/yarn-error.log
/timings.txt
right_*.txt
root_*.txt

__pycache__
docker-compose.dev.yml
/build
*.tmp

/ethdb/*.fail

libmdbx/build/*
tests/testdata/*
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions README.md → v3/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
![obligatory xkcd](http://imgs.xkcd.com/comics/standards.png)
# log [![godoc reference](https://godoc.org/github.com/ledgerwatch/log?status.png)](https://godoc.org/github.com/ledgerwatch/log) [![Build Status](https://travis-ci.org/ledgerwatch/log.svg?branch=master)](https://travis-ci.org/inconshreveable/log15)

# log15 [![godoc reference](https://godoc.org/github.com/inconshreveable/log15?status.png)](https://godoc.org/github.com/inconshreveable/log15) [![Build Status](https://travis-ci.org/inconshreveable/log15.svg?branch=master)](https://travis-ci.org/inconshreveable/log15)
Fork of https://github.com/inconshreveable/log15 but renamed to "log" to simplify usage, drop old go versions support

Package log15 provides an opinionated, simple toolkit for best-practice logging in Go (golang) that is both human and machine readable. It is modeled after the Go standard library's [`io`](http://golang.org/pkg/io/) and [`net/http`](http://golang.org/pkg/net/http/) packages and is an alternative to the standard library's [`log`](http://golang.org/pkg/log/) package.
Provides an opinionated, simple toolkit for best-practice logging in Go (golang) that is both human and machine readable. It is modeled after the Go standard library's [`io`](http://golang.org/pkg/io/) and [`net/http`](http://golang.org/pkg/net/http/) packages and is an alternative to the standard library's [`log`](http://golang.org/pkg/log/) package.

## Features
- A simple, easy-to-understand API
Expand All @@ -21,7 +21,7 @@ you must vendor the library.
## Importing

```go
import log "github.com/inconshreveable/log15"
import log "github.com/ledgerwatch/log"
```

## Examples
Expand Down
4 changes: 1 addition & 3 deletions bench_test.go → v3/bench_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// +build go1.3

package log15
package log

import (
"bytes"
Expand Down
2 changes: 1 addition & 1 deletion doc.go → v3/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,4 +330,4 @@ The Name
https://xkcd.com/927/

*/
package log15
package log
3 changes: 2 additions & 1 deletion ext/ext_test.go → v3/ext/ext_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ package ext

import (
"errors"
log "github.com/inconshreveable/log15"
"math"
"testing"

"github.com/ledgerwatch/log/v3"
)

func testHandler() (log.Handler, *log.Record) {
Expand Down
2 changes: 1 addition & 1 deletion ext/handler.go → v3/ext/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"sync/atomic"
"unsafe"

log "github.com/inconshreveable/log15"
"github.com/ledgerwatch/log/v3"
)

// EscalateErrHandler wraps another handler and passes all records through
Expand Down
File renamed without changes.
21 changes: 19 additions & 2 deletions format.go → v3/format.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package log15
package log

import (
"bytes"
Expand All @@ -13,7 +13,7 @@ import (

const (
timeFormat = "2006-01-02T15:04:05-0700"
termTimeFormat = "01-02|15:04:05"
termTimeFormat = "01-02|15:04:05.000"
floatFormat = 'f'
termMsgJust = 40
)
Expand Down Expand Up @@ -80,6 +80,23 @@ func TerminalFormat() Format {
})
}

func TerminalFormatNoColor() Format {
return FormatFunc(func(r *Record) []byte {
b := &bytes.Buffer{}
lvl := strings.ToUpper(r.Lvl.String())
fmt.Fprintf(b, "[%s] [%s] %s ", lvl, r.Time.Format(termTimeFormat), r.Msg)

// try to justify the log output for short messages
if len(r.Ctx) > 0 && len(r.Msg) < termMsgJust {
b.Write(bytes.Repeat([]byte{' '}, termMsgJust-len(r.Msg)))
}

// print the keys logfmt style
logfmt(b, r.Ctx, 0)
return b.Bytes()
})
}

// LogfmtFormat prints records in logfmt format, an easy machine-parseable but human-readable
// format for key/value pairs.
//
Expand Down
10 changes: 10 additions & 0 deletions v3/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module github.com/ledgerwatch/log/v3

go 1.16

require (
github.com/go-stack/stack v1.8.0
github.com/mattn/go-colorable v0.1.9
github.com/mattn/go-isatty v0.0.14
golang.org/x/sys v0.0.0-20210917161153-d61c044b1678
)
12 changes: 12 additions & 0 deletions v3/go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/mattn/go-colorable v0.1.9 h1:sqDoxXbdeALODt0DAeJCVp38ps9ZogZEAXjus69YV3U=
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210917161153-d61c044b1678 h1:J27LZFQBFoihqXoegpscI10HpjZ7B5WQLLKL2FZXQKw=
golang.org/x/sys v0.0.0-20210917161153-d61c044b1678/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
21 changes: 20 additions & 1 deletion handler.go → v3/handler.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package log15
package log

import (
"fmt"
Expand All @@ -7,6 +7,7 @@ import (
"os"
"reflect"
"sync"
"sync/atomic"

"github.com/go-stack/stack"
)
Expand Down Expand Up @@ -351,3 +352,21 @@ func (m muster) FileHandler(path string, fmtr Format) Handler {
func (m muster) NetHandler(network, addr string, fmtr Format) Handler {
return must(NetHandler(network, addr, fmtr))
}

// swapHandler wraps another handler that may be swapped out
// dynamically at runtime in a thread-safe fashion.
type swapHandler struct {
handler atomic.Value
}

func (h *swapHandler) Log(r *Record) error {
return (*h.handler.Load().(*Handler)).Log(r)
}

func (h *swapHandler) Swap(newHandler Handler) {
h.handler.Store(&newHandler)
}

func (h *swapHandler) Get() Handler {
return *h.handler.Load().(*Handler)
}
5 changes: 3 additions & 2 deletions log15_test.go → v3/log_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package log15
package log

import (
"bufio"
Expand Down Expand Up @@ -272,6 +272,7 @@ func TestLvlFilterHandler(t *testing.T) {
}

func TestNetHandler(t *testing.T) {
t.Skip()
t.Parallel()

l, err := net.Listen("tcp", "localhost:0")
Expand Down Expand Up @@ -467,7 +468,7 @@ func TestCallerFileHandler(t *testing.T) {
t.Fatalf("Wrong context value type, got %T expected string", r.Ctx[1])
}

exp := fmt.Sprint("log15_test.go:", line-1)
exp := fmt.Sprint("log_test.go:", line-1)
if s != exp {
t.Fatalf("Wrong context value, got %s expected string matching %s", s, exp)
}
Expand Down
Loading