-
Notifications
You must be signed in to change notification settings - Fork 0
/
lib.go
56 lines (48 loc) · 1.48 KB
/
lib.go
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package gostructor
import (
"os"
"github.com/goreflect/gostructor/infra"
"github.com/goreflect/gostructor/pipeline"
logrus "github.com/sirupsen/logrus"
)
func init() {
logrus.SetFormatter(&logrus.TextFormatter{})
logrus.SetOutput(os.Stdout)
logrus.SetLevel(logrus.ErrorLevel)
}
/*ChangeLogLevel - changing current loggin level*/
func ChangeLogLevel(logLevel logrus.Level) {
logrus.SetLevel(logLevel)
}
/*ChangeLogFormatter - changing current formatter*/
func ChangeLogFormatter(formatter logrus.Formatter) {
logrus.SetFormatter(formatter)
}
/*
ConfigureEasy - default pipeline setup for configure your structure
*/
func ConfigureEasy(
structure interface{}) (interface{}, error) {
return pipeline.Configure(structure, []infra.FuncType{
infra.FunctionSetupEnvironment,
infra.FunctionSetupHocon,
infra.FunctionSetupDefault,
}, pipeline.EmptyAdditionalPrefix, pipeline.DirtyConfiguring)
}
/*
ConfigureSetup - pipeline with your settings stages for your structure
*/
func ConfigureSetup(
structure interface{},
prefix string,
functions []infra.FuncType) (interface{}, error) {
return pipeline.Configure(structure, functions, prefix, pipeline.DirtyConfiguring)
}
/*
ConfigureSmart - configuring by analysing tags for add prefer strategy for configuring
*/
func ConfigureSmart(
structure interface{},
) (interface{}, error) {
return pipeline.Configure(structure, nil, pipeline.EmptyAdditionalPrefix, pipeline.SmartConfiguring)
}