Skip to content

Commit

Permalink
chore: Enshrine defra logger names (#1410)
Browse files Browse the repository at this point in the history
## Relevant issue(s)

Resolves #1148

## Description

Simple approach: just rename the loggers.

## How has this been tested?

CI & manual
  • Loading branch information
orpheuslummis authored May 15, 2023
1 parent 8f72069 commit db4b853
Show file tree
Hide file tree
Showing 22 changed files with 21 additions and 22 deletions.
2 changes: 1 addition & 1 deletion api/http/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func TestNewHandlerWithLogger(t *testing.T) {
t.Fatal(err)
}

assert.Equal(t, "defra.http", kv["logger"])
assert.Equal(t, "http", kv["logger"])
}

func TestGetJSON(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion api/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ package http

import "github.com/sourcenetwork/defradb/logging"

var log = logging.MustNewLogger("defra.http")
var log = logging.MustNewLogger("http")
2 changes: 1 addition & 1 deletion api/http/logger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ func TestLoggerKeyValueOutput(t *testing.T) {
// check that everything is as expected
assert.Equal(t, "{\"data\":{\"response\":\"pong\"}}", rec2.Body.String())
assert.Equal(t, "INFO", kv["level"])
assert.Equal(t, "defra.http", kv["logger"])
assert.Equal(t, "http", kv["logger"])
assert.Equal(t, "Request", kv["msg"])
assert.Equal(t, "GET", kv["Method"])
assert.Equal(t, "/ping", kv["Path"])
Expand Down
2 changes: 1 addition & 1 deletion cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (
"github.com/sourcenetwork/defradb/logging"
)

var log = logging.MustNewLogger("defra.cli")
var log = logging.MustNewLogger("cli")

const badgerDatastoreName = "badger"

Expand Down
2 changes: 1 addition & 1 deletion cmd/genclidocs/genclidocs.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/sourcenetwork/defradb/logging"
)

var log = logging.MustNewLogger("defra.genclidocs")
var log = logging.MustNewLogger("genclidocs")

func main() {
path := flag.String("o", "docs/cmd", "path to write the cmd docs to")
Expand Down
2 changes: 1 addition & 1 deletion cmd/genmanpages/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (

const defaultPerm os.FileMode = 0o777

var log = logging.MustNewLogger("defra.genmanpages")
var log = logging.MustNewLogger("genmanpages")

func main() {
dirFlag := flag.String("o", "build/man", "Directory in which to generate DefraDB man pages")
Expand Down
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ import (
"github.com/sourcenetwork/defradb/node"
)

var log = logging.MustNewLogger("defra.config")
var log = logging.MustNewLogger("config")

const (
DefaultAPIEmail = "[email protected]"
Expand Down
2 changes: 1 addition & 1 deletion datastore/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
)

var (
log = logging.MustNewLogger("defradb.store")
log = logging.MustNewLogger("store")
)

// RootStore wraps Batching and TxnDatastore requiring datastore to support both batching and transactions.
Expand Down
2 changes: 1 addition & 1 deletion db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import (
)

var (
log = logging.MustNewLogger("defra.db")
log = logging.MustNewLogger("db")
)

// make sure we match our client interface
Expand Down
2 changes: 1 addition & 1 deletion logging/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"context"
)

var log = MustNewLogger("defra.logging")
var log = MustNewLogger("logging")

// KV is a key-value pair used to pass structured data to loggers.
type KV struct {
Expand Down
2 changes: 1 addition & 1 deletion merkle/clock/clock.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
)

var (
log = logging.MustNewLogger("defra.merkleclock")
log = logging.MustNewLogger("merkleclock")
)

// MerkleClock is a MerkleCRDT clock that can be used to read/write events (deltas) to the clock.
Expand Down
2 changes: 1 addition & 1 deletion merkle/crdt/merklecrdt.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
)

var (
log = logging.MustNewLogger("defra.merklecrdt")
log = logging.MustNewLogger("merklecrdt")
)

// MerkleCRDT is the implementation of a Merkle Clock along with a
Expand Down
2 changes: 1 addition & 1 deletion net/api/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
)

var (
log = logging.MustNewLogger("defra.netapi")
log = logging.MustNewLogger("netapi")
)

type Service struct {
Expand Down
2 changes: 1 addition & 1 deletion net/net.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ import (
)

var (
log = logging.MustNewLogger("defra.net")
log = logging.MustNewLogger("net")
)
2 changes: 1 addition & 1 deletion node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import (
)

var (
log = logging.MustNewLogger("defra.node")
log = logging.MustNewLogger("node")
)

const evtWaitTimeout = 10 * time.Second
Expand Down
2 changes: 1 addition & 1 deletion planner/planner.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
)

var (
log = logging.MustNewLogger("defra.planner")
log = logging.MustNewLogger("planner")
)

// planNode is an interface all nodes in the plan tree need to implement.
Expand Down
2 changes: 1 addition & 1 deletion tests/bench/bench_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const (

var (
storage string = "memory"
log = logging.MustNewLogger("defra.tests.bench")
log = logging.MustNewLogger("tests.bench")
)

func init() {
Expand Down
2 changes: 1 addition & 1 deletion tests/bench/query/simple/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
)

var (
// log = logging.MustNewLogger("defra.bench")
// log = logging.MustNewLogger("bench")
)

func runQueryBenchGet(
Expand Down
1 change: 0 additions & 1 deletion tests/integration/cli/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ func TestExecVersionJSON(t *testing.T) {
assert.Contains(t, output, "go\":")
assert.Contains(t, output, "commit\":")
assert.Contains(t, output, "commitdate\":")

var data map[string]any
err := json.Unmarshal([]byte(output), &data)
assert.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/explain/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
)

var (
log = logging.MustNewLogger("defra.tests.integration.explain")
log = logging.MustNewLogger("tests.integration.explain")

allPlanNodeNames = map[string]struct{}{
// Not a planNode but need it here as this is root of the explain graph.
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/net/order/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
)

var (
log = logging.MustNewLogger("defra.test.net")
log = logging.MustNewLogger("test.net")
)

const (
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/utils2.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const (
)

var (
log = logging.MustNewLogger("defra.tests.integration")
log = logging.MustNewLogger("tests.integration")
badgerInMemory bool
badgerFile bool
inMemoryStore bool
Expand Down

0 comments on commit db4b853

Please sign in to comment.