-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdefaultloggerfactory.go
More file actions
33 lines (27 loc) · 856 Bytes
/
defaultloggerfactory.go
File metadata and controls
33 lines (27 loc) · 856 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package log
import (
"io"
"strings"
"github.com/oddengine/log/level"
)
// DefaultLoggerFactory creates new DefaultLogger.
type DefaultLoggerFactory struct {
out io.Writer
level level.Level
}
// Init this class.
func (me *DefaultLoggerFactory) Init(out io.Writer, n level.Level) *DefaultLoggerFactory {
me.out = out
me.level = n
return me
}
// NewLogger returns a configured ILogger for the given scope.
func (me *DefaultLoggerFactory) NewLogger(scope string) ILogger {
return NewDefaultLogger(me.out, me.level, strings.ToUpper(scope), DEFAULT_DEPTH)
}
// NewDefaultLoggerFactory creates a new DefaultLoggerFactory.
func NewDefaultLoggerFactory(constraints *DefaultWriterConstraints) *DefaultLoggerFactory {
w := new(DefaultWriter).Init(constraints)
n := level.Parse(constraints.Level, "|")
return new(DefaultLoggerFactory).Init(w, n)
}