Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Sytten committed Jan 26, 2021
1 parent 2480807 commit 0b3c786
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# logger-go
Golang logger interface and adapters

Golang logger interface and adapters.
This interface is used in the Golang libraries of GraphMetrics.
It also provides a few adapters for popular loggers.
27 changes: 27 additions & 0 deletions default.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package logger

import "log"

type defaultLogger struct {
}

func NewDefault() Logger {
return &defaultLogger{}
}

func (*defaultLogger) Debug(msg string, metadata map[string]interface{}) {
log.Printf("[DEBUG] %s %#v", msg, metadata)
}

func (*defaultLogger) Info(msg string, metadata map[string]interface{}) {
log.Printf("[INFO] %s %#v", msg, metadata)

}

func (*defaultLogger) Warn(msg string, metadata map[string]interface{}) {
log.Printf("[WARN] %s %#v", msg, metadata)
}

func (*defaultLogger) Error(msg string, metadata map[string]interface{}) {
log.Printf("[ERROR] %s %#v", msg, metadata)
}
3 changes: 3 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/graphmetrics/logger-go

go 1.15
8 changes: 8 additions & 0 deletions interface.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package logger

type Logger interface {
Debug(msg string, metadata map[string]interface{})
Info(msg string, metadata map[string]interface{})
Warn(msg string, metadata map[string]interface{})
Error(msg string, metadata map[string]interface{})
}

0 comments on commit 0b3c786

Please sign in to comment.