File tree Expand file tree Collapse file tree 4 files changed +44
-23
lines changed Expand file tree Collapse file tree 4 files changed +44
-23
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,8 @@ import (
10
10
"github.com/picostack/pico/executor"
11
11
"github.com/picostack/pico/secret/memory"
12
12
"github.com/picostack/pico/task"
13
+
14
+ _ "github.com/picostack/pico/logger"
13
15
)
14
16
15
17
func TestMain (m * testing.M ) {
Original file line number Diff line number Diff line change
1
+ package logger
2
+
3
+ import (
4
+ "os"
5
+ "strconv"
6
+ "strings"
7
+
8
+ "go.uber.org/zap"
9
+ "go.uber.org/zap/zapcore"
10
+ )
11
+
12
+ func init () {
13
+ // constructs a logger and replaces the default global logger
14
+ var config zap.Config
15
+ if d , e := strconv .ParseBool (os .Getenv ("DEVELOPMENT" )); d && e == nil || isInTests () {
16
+ config = zap .NewDevelopmentConfig ()
17
+ } else {
18
+ config = zap .NewProductionConfig ()
19
+ }
20
+ config .EncoderConfig .EncodeTime = zapcore .ISO8601TimeEncoder
21
+ config .DisableStacktrace = true
22
+ if d , e := strconv .ParseBool (os .Getenv ("DEBUG" )); d && e == nil || isInTests () {
23
+ config .Level = zap .NewAtomicLevelAt (zap .DebugLevel )
24
+ }
25
+ logger , err := config .Build ()
26
+ if err != nil {
27
+ panic (err )
28
+ }
29
+ zap .ReplaceGlobals (logger )
30
+ }
31
+
32
+ func isInTests () bool {
33
+ for _ , arg := range os .Args {
34
+ if strings .HasPrefix (arg , "-test.v=" ) {
35
+ return true
36
+ }
37
+ }
38
+ return false
39
+ }
Original file line number Diff line number Diff line change @@ -4,40 +4,19 @@ import (
4
4
"context"
5
5
"os"
6
6
"os/signal"
7
- "strconv"
8
7
"time"
9
8
10
9
_ "github.com/joho/godotenv/autoload"
11
10
"github.com/pkg/errors"
12
11
"github.com/urfave/cli"
13
12
"go.uber.org/zap"
14
- "go.uber.org/zap/zapcore"
15
13
14
+ _ "github.com/picostack/pico/logger"
16
15
"github.com/picostack/pico/service"
17
16
)
18
17
19
18
var version = "master"
20
19
21
- func init () {
22
- // constructs a logger and replaces the default global logger
23
- var config zap.Config
24
- if d , e := strconv .ParseBool (os .Getenv ("DEVELOPMENT" )); d && e == nil {
25
- config = zap .NewDevelopmentConfig ()
26
- } else {
27
- config = zap .NewProductionConfig ()
28
- }
29
- config .EncoderConfig .EncodeTime = zapcore .ISO8601TimeEncoder
30
- config .DisableStacktrace = true
31
- if d , e := strconv .ParseBool (os .Getenv ("DEBUG" )); d && e == nil {
32
- config .Level = zap .NewAtomicLevelAt (zap .DebugLevel )
33
- }
34
- logger , err := config .Build ()
35
- if err != nil {
36
- panic (err )
37
- }
38
- zap .ReplaceGlobals (logger )
39
- }
40
-
41
20
func main () {
42
21
app := cli .NewApp ()
43
22
Original file line number Diff line number Diff line change @@ -6,13 +6,14 @@ import (
6
6
"time"
7
7
8
8
"github.com/picostack/pico/task"
9
+
10
+ _ "github.com/picostack/pico/logger"
9
11
)
10
12
11
13
var w * GitWatcher
12
14
var bus chan task.ExecutionTask
13
15
14
16
func TestMain (m * testing.M ) {
15
- os .Setenv ("DEBUG" , "1" )
16
17
bus = make (chan task.ExecutionTask , 16 )
17
18
w = NewGitWatcher (".test" , bus , time .Second , nil )
18
19
You can’t perform that action at this time.
0 commit comments