removed unused consts from tracing
MODIFY
clients/go/gengo.go
clients/go/gengo.go
@@ -164,26 +164,39 @@ func (se exporterOption) apply(opts *options) {
//WagClientLogger provides a minimal interface for a Wag Client Logger
type WagClientLogger interface {
- Log(level string, message string, pairs map[string]interface{})
+ Log(level LogLevel, message string, pairs map[string]interface{})
}
//M is a convenience type to avoid having to type out map[string]interface{} everytime.
type M map[string]interface{}
+type LogLevel int
+
+// Constants used to define different LogLevels supported
+const (
+ Trace LogLevel = iota
+ Debug
+ Info
+ Warning
+ Error
+ Critical
+ FromEnv
+)
+
//NewLogger creates a logger for id that produces logs at and below the indicated level.
//Level indicated the level at and below which logs are created.
-func NewLogger(id string, level string) WagClientLogger {
+func NewLogger(id string, level LogLevel) WagClientLogger {
return PrintlnLogger{id: id, level: level}
}
type PrintlnLogger struct {
- level string
+ level LogLevel
id string
}
-func (w PrintlnLogger) Log(level string, message string, m map[string]interface{}) {
+func (w PrintlnLogger) Log(level LogLevel, message string, m map[string]interface{}) {
- if w.strLvlToInt(w.level) >= w.strLvlToInt(level) {
+ if level >= level {
m["id"] = w.id
jsonLog, err := json.Marshal(m)
if err != nil {
@@ -193,24 +206,6 @@ func (w PrintlnLogger) Log(level string, message string, m map[string]interface{
}
}
-func (w PrintlnLogger) strLvlToInt(s string) int {
- switch s {
- case "Critical":
- return 0
- case "Error":
- return 1
- case "Warning":
- return 2
- case "Info":
- return 3
- case "Debug":
- return 4
- case "Trace":
- return 5
- }
- return -1
-}
-
//----------------------END LOGGING RELATED FUNCTIONS------------------------
//----------------------BEGIN TRACING RELATED FUNCTIONS----------------------

MODIFY
samples/gen-go-blog/client/client.go
samples/gen-go-blog/client/client.go
@@ -126,26 +126,39 @@ func (se exporterOption) apply(opts *options) {
//WagClientLogger provides a minimal interface for a Wag Client Logger
type WagClientLogger interface {
- Log(level string, message string, pairs map[string]interface{})
+ Log(level LogLevel, message string, pairs map[string]interface{})
}
//M is a convenience type to avoid having to type out map[string]interface{} everytime.
type M map[string]interface{}
+type LogLevel int
+
+// Constants used to define different LogLevels supported
+const (
+ Trace LogLevel = iota
+ Debug
+ Info
+ Warning
+ Error
+ Critical
+ FromEnv
+)
+
//NewLogger creates a logger for id that produces logs at and below the indicated level.
//Level indicated the level at and below which logs are created.
-func NewLogger(id string, level string) WagClientLogger {
+func NewLogger(id string, level LogLevel) WagClientLogger {
return PrintlnLogger{id: id, level: level}
}
type PrintlnLogger struct {
- level string
+ level LogLevel
id string
}
-func (w PrintlnLogger) Log(level string, message string, m map[string]interface{}) {
+func (w PrintlnLogger) Log(level LogLevel, message string, m map[string]interface{}) {
- if w.strLvlToInt(w.level) >= w.strLvlToInt(level) {
+ if level >= level {
m["id"] = w.id
jsonLog, err := json.Marshal(m)
if err != nil {
@@ -155,24 +168,6 @@ func (w PrintlnLogger) Log(level string, message string, m map[string]interface{
}
}
-func (w PrintlnLogger) strLvlToInt(s string) int {
- switch s {
- case "Critical":
- return 0
- case "Error":
- return 1
- case "Warning":
- return 2
- case "Info":
- return 3
- case "Debug":
- return 4
- case "Trace":
- return 5
- }
- return -1
-}
-
//----------------------END LOGGING RELATED FUNCTIONS------------------------
//----------------------BEGIN TRACING RELATED FUNCTIONS----------------------

MODIFY
samples/gen-go-client-only/client/client.go
samples/gen-go-client-only/client/client.go
@@ -126,26 +126,39 @@ func (se exporterOption) apply(opts *options) {
//WagClientLogger provides a minimal interface for a Wag Client Logger
type WagClientLogger interface {
- Log(level string, message string, pairs map[string]interface{})
+ Log(level LogLevel, message string, pairs map[string]interface{})
}
//M is a convenience type to avoid having to type out map[string]interface{} everytime.
type M map[string]interface{}
+type LogLevel int
+
+// Constants used to define different LogLevels supported
+const (
+ Trace LogLevel = iota
+ Debug
+ Info
+ Warning
+ Error
+ Critical
+ FromEnv
+)
+
//NewLogger creates a logger for id that produces logs at and below the indicated level.
//Level indicated the level at and below which logs are created.
-func NewLogger(id string, level string) WagClientLogger {
+func NewLogger(id string, level LogLevel) WagClientLogger {
return PrintlnLogger{id: id, level: level}
}
type PrintlnLogger struct {
- level string
+ level LogLevel
id string
}
-func (w PrintlnLogger) Log(level string, message string, m map[string]interface{}) {
+func (w PrintlnLogger) Log(level LogLevel, message string, m map[string]interface{}) {
- if w.strLvlToInt(w.level) >= w.strLvlToInt(level) {
+ if level >= level {
m["id"] = w.id
jsonLog, err := json.Marshal(m)
if err != nil {
@@ -155,24 +168,6 @@ func (w PrintlnLogger) Log(level string, message string, m map[string]interface{
}
}
-func (w PrintlnLogger) strLvlToInt(s string) int {
- switch s {
- case "Critical":
- return 0
- case "Error":
- return 1
- case "Warning":
- return 2
- case "Info":
- return 3
- case "Debug":
- return 4
- case "Trace":
- return 5
- }
- return -1
-}
-
//----------------------END LOGGING RELATED FUNCTIONS------------------------
//----------------------BEGIN TRACING RELATED FUNCTIONS----------------------

MODIFY
samples/gen-go-db-custom-path/client/client.go
samples/gen-go-db-custom-path/client/client.go
@@ -126,26 +126,39 @@ func (se exporterOption) apply(opts *options) {
//WagClientLogger provides a minimal interface for a Wag Client Logger
type WagClientLogger interface {
- Log(level string, message string, pairs map[string]interface{})
+ Log(level LogLevel, message string, pairs map[string]interface{})
}
//M is a convenience type to avoid having to type out map[string]interface{} everytime.
type M map[string]interface{}
+type LogLevel int
+
+// Constants used to define different LogLevels supported
+const (
+ Trace LogLevel = iota
+ Debug
+ Info
+ Warning
+ Error
+ Critical
+ FromEnv
+)
+
//NewLogger creates a logger for id that produces logs at and below the indicated level.
//Level indicated the level at and below which logs are created.
-func NewLogger(id string, level string) WagClientLogger {
+func NewLogger(id string, level LogLevel) WagClientLogger {
return PrintlnLogger{id: id, level: level}
}
type PrintlnLogger struct {
- level string
+ level LogLevel
id string
}
-func (w PrintlnLogger) Log(level string, message string, m map[string]interface{}) {
+func (w PrintlnLogger) Log(level LogLevel, message string, m map[string]interface{}) {
- if w.strLvlToInt(w.level) >= w.strLvlToInt(level) {
+ if level >= level {
m["id"] = w.id
jsonLog, err := json.Marshal(m)
if err != nil {
@@ -155,24 +168,6 @@ func (w PrintlnLogger) Log(level string, message string, m map[string]interface{
}
}
-func (w PrintlnLogger) strLvlToInt(s string) int {
- switch s {
- case "Critical":
- return 0
- case "Error":
- return 1
- case "Warning":
- return 2
- case "Info":
- return 3
- case "Debug":
- return 4
- case "Trace":
- return 5
- }
- return -1
-}
-
//----------------------END LOGGING RELATED FUNCTIONS------------------------
//----------------------BEGIN TRACING RELATED FUNCTIONS----------------------

MODIFY
samples/gen-go-db/client/client.go
samples/gen-go-db/client/client.go
@@ -126,26 +126,39 @@ func (se exporterOption) apply(opts *options) {
//WagClientLogger provides a minimal interface for a Wag Client Logger
type WagClientLogger interface {
- Log(level string, message string, pairs map[string]interface{})
+ Log(level LogLevel, message string, pairs map[string]interface{})
}
//M is a convenience type to avoid having to type out map[string]interface{} everytime.
type M map[string]interface{}
+type LogLevel int
+
+// Constants used to define different LogLevels supported
+const (
+ Trace LogLevel = iota
+ Debug
+ Info
+ Warning
+ Error
+ Critical
+ FromEnv
+)
+
//NewLogger creates a logger for id that produces logs at and below the indicated level.
//Level indicated the level at and below which logs are created.
-func NewLogger(id string, level string) WagClientLogger {
+func NewLogger(id string, level LogLevel) WagClientLogger {
return PrintlnLogger{id: id, level: level}
}
type PrintlnLogger struct {
- level string
+ level LogLevel
id string
}
-func (w PrintlnLogger) Log(level string, message string, m map[string]interface{}) {
+func (w PrintlnLogger) Log(level LogLevel, message string, m map[string]interface{}) {
- if w.strLvlToInt(w.level) >= w.strLvlToInt(level) {
+ if level >= level {
m["id"] = w.id
jsonLog, err := json.Marshal(m)
if err != nil {
@@ -155,24 +168,6 @@ func (w PrintlnLogger) Log(level string, message string, m map[string]interface{
}
}
-func (w PrintlnLogger) strLvlToInt(s string) int {
- switch s {
- case "Critical":
- return 0
- case "Error":
- return 1
- case "Warning":
- return 2
- case "Info":
- return 3
- case "Debug":
- return 4
- case "Trace":
- return 5
- }
- return -1
-}
-
//----------------------END LOGGING RELATED FUNCTIONS------------------------
//----------------------BEGIN TRACING RELATED FUNCTIONS----------------------

MODIFY
samples/gen-go-deprecated/client/client.go
samples/gen-go-deprecated/client/client.go
@@ -126,26 +126,39 @@ func (se exporterOption) apply(opts *options) {
//WagClientLogger provides a minimal interface for a Wag Client Logger
type WagClientLogger interface {
- Log(level string, message string, pairs map[string]interface{})
+ Log(level LogLevel, message string, pairs map[string]interface{})
}
//M is a convenience type to avoid having to type out map[string]interface{} everytime.
type M map[string]interface{}
+type LogLevel int
+
+// Constants used to define different LogLevels supported
+const (
+ Trace LogLevel = iota
+ Debug
+ Info
+ Warning
+ Error
+ Critical
+ FromEnv
+)
+
//NewLogger creates a logger for id that produces logs at and below the indicated level.
//Level indicated the level at and below which logs are created.
-func NewLogger(id string, level string) WagClientLogger {
+func NewLogger(id string, level LogLevel) WagClientLogger {
return PrintlnLogger{id: id, level: level}
}
type PrintlnLogger struct {
- level string
+ level LogLevel
id string
}
-func (w PrintlnLogger) Log(level string, message string, m map[string]interface{}) {
+func (w PrintlnLogger) Log(level LogLevel, message string, m map[string]interface{}) {
- if w.strLvlToInt(w.level) >= w.strLvlToInt(level) {
+ if level >= level {
m["id"] = w.id
jsonLog, err := json.Marshal(m)
if err != nil {
@@ -155,24 +168,6 @@ func (w PrintlnLogger) Log(level string, message string, m map[string]interface{
}
}
-func (w PrintlnLogger) strLvlToInt(s string) int {
- switch s {
- case "Critical":
- return 0
- case "Error":
- return 1
- case "Warning":
- return 2
- case "Info":
- return 3
- case "Debug":
- return 4
- case "Trace":
- return 5
- }
- return -1
-}
-
//----------------------END LOGGING RELATED FUNCTIONS------------------------
//----------------------BEGIN TRACING RELATED FUNCTIONS----------------------

MODIFY
samples/gen-go-errors/client/client.go
samples/gen-go-errors/client/client.go
@@ -126,26 +126,39 @@ func (se exporterOption) apply(opts *options) {
//WagClientLogger provides a minimal interface for a Wag Client Logger
type WagClientLogger interface {
- Log(level string, message string, pairs map[string]interface{})
+ Log(level LogLevel, message string, pairs map[string]interface{})
}
//M is a convenience type to avoid having to type out map[string]interface{} everytime.
type M map[string]interface{}
+type LogLevel int
+
+// Constants used to define different LogLevels supported
+const (
+ Trace LogLevel = iota
+ Debug
+ Info
+ Warning
+ Error
+ Critical
+ FromEnv
+)
+
//NewLogger creates a logger for id that produces logs at and below the indicated level.
//Level indicated the level at and below which logs are created.
-func NewLogger(id string, level string) WagClientLogger {
+func NewLogger(id string, level LogLevel) WagClientLogger {
return PrintlnLogger{id: id, level: level}
}
type PrintlnLogger struct {
- level string
+ level LogLevel
id string
}
-func (w PrintlnLogger) Log(level string, message string, m map[string]interface{}) {
+func (w PrintlnLogger) Log(level LogLevel, message string, m map[string]interface{}) {
- if w.strLvlToInt(w.level) >= w.strLvlToInt(level) {
+ if level >= level {
m["id"] = w.id
jsonLog, err := json.Marshal(m)
if err != nil {
@@ -155,24 +168,6 @@ func (w PrintlnLogger) Log(level string, message string, m map[string]interface{
}
}
-func (w PrintlnLogger) strLvlToInt(s string) int {
- switch s {
- case "Critical":
- return 0
- case "Error":
- return 1
- case "Warning":
- return 2
- case "Info":
- return 3
- case "Debug":
- return 4
- case "Trace":
- return 5
- }
- return -1
-}
-
//----------------------END LOGGING RELATED FUNCTIONS------------------------
//----------------------BEGIN TRACING RELATED FUNCTIONS----------------------

MODIFY
samples/gen-go-nils/client/client.go
samples/gen-go-nils/client/client.go
@@ -126,26 +126,39 @@ func (se exporterOption) apply(opts *options) {
//WagClientLogger provides a minimal interface for a Wag Client Logger
type WagClientLogger interface {
- Log(level string, message string, pairs map[string]interface{})
+ Log(level LogLevel, message string, pairs map[string]interface{})
}
//M is a convenience type to avoid having to type out map[string]interface{} everytime.
type M map[string]interface{}
+type LogLevel int
+
+// Constants used to define different LogLevels supported
+const (
+ Trace LogLevel = iota
+ Debug
+ Info
+ Warning
+ Error
+ Critical
+ FromEnv
+)
+
//NewLogger creates a logger for id that produces logs at and below the indicated level.
//Level indicated the level at and below which logs are created.
-func NewLogger(id string, level string) WagClientLogger {
+func NewLogger(id string, level LogLevel) WagClientLogger {
return PrintlnLogger{id: id, level: level}
}
type PrintlnLogger struct {
- level string
+ level LogLevel
id string
}
-func (w PrintlnLogger) Log(level string, message string, m map[string]interface{}) {
+func (w PrintlnLogger) Log(level LogLevel, message string, m map[string]interface{}) {
- if w.strLvlToInt(w.level) >= w.strLvlToInt(level) {
+ if level >= level {
m["id"] = w.id
jsonLog, err := json.Marshal(m)
if err != nil {
@@ -155,24 +168,6 @@ func (w PrintlnLogger) Log(level string, message string, m map[string]interface{
}
}
-func (w PrintlnLogger) strLvlToInt(s string) int {
- switch s {
- case "Critical":
- return 0
- case "Error":
- return 1
- case "Warning":
- return 2
- case "Info":
- return 3
- case "Debug":
- return 4
- case "Trace":
- return 5
- }
- return -1
-}
-
//----------------------END LOGGING RELATED FUNCTIONS------------------------
//----------------------BEGIN TRACING RELATED FUNCTIONS----------------------

MODIFY
samples/gen-go/client/client.go
samples/gen-go/client/client.go
@@ -126,26 +126,39 @@ func (se exporterOption) apply(opts *options) {
//WagClientLogger provides a minimal interface for a Wag Client Logger
type WagClientLogger interface {
- Log(level string, message string, pairs map[string]interface{})
+ Log(level LogLevel, message string, pairs map[string]interface{})
}
//M is a convenience type to avoid having to type out map[string]interface{} everytime.
type M map[string]interface{}
+type LogLevel int
+
+// Constants used to define different LogLevels supported
+const (
+ Trace LogLevel = iota
+ Debug
+ Info
+ Warning
+ Error
+ Critical
+ FromEnv
+)
+
//NewLogger creates a logger for id that produces logs at and below the indicated level.
//Level indicated the level at and below which logs are created.
-func NewLogger(id string, level string) WagClientLogger {
+func NewLogger(id string, level LogLevel) WagClientLogger {
return PrintlnLogger{id: id, level: level}
}
type PrintlnLogger struct {
- level string
+ level LogLevel
id string
}
-func (w PrintlnLogger) Log(level string, message string, m map[string]interface{}) {
+func (w PrintlnLogger) Log(level LogLevel, message string, m map[string]interface{}) {
- if w.strLvlToInt(w.level) >= w.strLvlToInt(level) {
+ if level >= level {
m["id"] = w.id
jsonLog, err := json.Marshal(m)
if err != nil {
@@ -155,24 +168,6 @@ func (w PrintlnLogger) Log(level string, message string, m map[string]interface{
}
}
-func (w PrintlnLogger) strLvlToInt(s string) int {
- switch s {
- case "Critical":
- return 0
- case "Error":
- return 1
- case "Warning":
- return 2
- case "Info":
- return 3
- case "Debug":
- return 4
- case "Trace":
- return 5
- }
- return -1
-}
-
//----------------------END LOGGING RELATED FUNCTIONS------------------------
//----------------------BEGIN TRACING RELATED FUNCTIONS----------------------

MODIFY
tracing/tracing.go
tracing/tracing.go
@@ -18,11 +18,6 @@ import (
"go.opentelemetry.io/otel/trace"
)
-const (
- instrumentationName = "github.com/Clever/wag/instrumentation"
- instrumentationVersion = "v0.1.0"
-)
-
//propagator to use
var propagator propagation.TextMapPropagator = propagation.TraceContext{} // traceparent header
type Option interface {

MODIFY
wag
wag
Binary files a/wag and b/wag differ

removed unused consts from tracing