Skip to content

Commit ab3e11f

Browse files
committed
feat: re-introduce Logger as return type for new instances
1 parent 4e3b9e1 commit ab3e11f

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

debugo/debugo.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ type Options struct {
3131
}
3232

3333
// Returns a log-function and an instance of Logger configured using options
34-
func NewWithOptions(namespace string, options *Options) func(message ...any) {
34+
func NewWithOptions(namespace string, options *Options) (func(message ...any), *Logger) {
3535
logger := new(namespace)
3636
logger.applyOptions(options)
3737
return logFunc(logger)
3838
}
3939

4040
// Returns a log-function and an instance of Logger configured with default values
41-
func New(namespace string) func(message ...any) {
41+
func New(namespace string) (func(message ...any), *Logger) {
4242
logger := new(namespace)
4343
logger.applyOptions(&Options{
4444
ForceEnable: false,
@@ -55,8 +55,8 @@ func new(namespace string) *Logger {
5555
return &Logger{namespace: namespace, lastLog: time.Now(), forced: false, output: os.Stderr}
5656
}
5757

58-
var logFunc = func(logger *Logger) func(message ...any) {
58+
var logFunc = func(logger *Logger) (func(message ...any), *Logger) {
5959
return func(message ...any) {
6060
logger.write(message...)
61-
}
61+
}, logger
6262
}

debugo/namespace_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
)
88

99
func TestMatchNamespace(t *testing.T) {
10-
l := new("test:a")
10+
_, l := New("test:a")
1111

1212
// Empty debug string
1313
SetDebug("")
@@ -42,7 +42,7 @@ func TestMatchNamespace(t *testing.T) {
4242
assert.Equal(t, l.matchNamespace(), true, "they should be equal") // Assuming case-sensitive
4343

4444
// No namespace provided
45-
l = new("")
45+
_, l = New("")
4646
SetDebug("test:*")
4747
assert.Equal(t, l.matchNamespace(), false, "they should be equal")
4848

0 commit comments

Comments
 (0)