-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathfactory_model.go
More file actions
38 lines (33 loc) · 948 Bytes
/
Copy pathfactory_model.go
File metadata and controls
38 lines (33 loc) · 948 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
34
35
36
37
38
package kek
import (
"github.com/olehan/kek/config"
"github.com/olehan/kek/formatters"
"github.com/olehan/kek/formatters/sugared"
"io"
"os"
"strings"
)
type (
// Factory is an entity that holds the logger configurations
// and populates Loggers with an option of linking the config
// or only extending it.
Factory struct {
*LoggerConfig
namePrefix string
}
)
const (
nameSeparator = "."
factoryLoggerNameSeparator = "/"
)
var (
defaultFactory = NewFactory(os.Stdout, sugared.Formatter)
)
// NewFactory returns a new factory with a set of required configurations like
// writer and formatter.
func NewFactory(writer io.Writer, formatter formatters.Formatter, name ...string) *Factory {
return &Factory{
namePrefix: strings.Join(name, nameSeparator),
LoggerConfig: NewLoggerConfig(config.NewConfig().SetWriter(writer)).SetFormatter(formatter),
}
}