1515package storage
1616
1717import (
18- "fmt"
19- "io"
2018 "os"
2119 "strings"
20+
21+ "go.uber.org/zap"
2222)
2323
2424const (
@@ -39,7 +39,7 @@ type FactoryConfig struct {
3939 SpanWriterTypes []string
4040 SpanReaderType string
4141 DependenciesStorageType string
42- log io. Writer
42+ logger * zap. Logger
4343}
4444
4545// FactoryConfigFromEnvAndCLI reads the desired types of storage backends from SPAN_STORAGE_TYPE,
@@ -52,11 +52,11 @@ type FactoryConfig struct {
5252//
5353// For backwards compatibility it also parses the args looking for deprecated --span-storage.type flag.
5454// If found, it writes a deprecation warning to the log.
55- func FactoryConfigFromEnvAndCLI (args []string , log io. Writer ) FactoryConfig {
55+ func FactoryConfigFromEnvAndCLI (args []string , logger * zap. Logger ) FactoryConfig {
5656 spanStorageType := os .Getenv (SpanStorageTypeEnvVar )
5757 if spanStorageType == "" {
5858 // for backwards compatibility check command line for --span-storage.type flag
59- spanStorageType = spanStorageTypeFromArgs (args , log )
59+ spanStorageType = spanStorageTypeFromArgs (args , logger )
6060 }
6161 if spanStorageType == "" {
6262 spanStorageType = cassandraStorageType
@@ -66,9 +66,8 @@ func FactoryConfigFromEnvAndCLI(args []string, log io.Writer) FactoryConfig {
6666 spanReaderType := os .Getenv (SpanReaderTypeEnvVar )
6767 if spanReaderType == "" {
6868 if len (spanWriterTypes ) > 1 {
69- fmt .Fprintf (log , "WARNING: The first span storage type listed (%s) will be used for reading. " +
70- "Please use environment variable %s to specify which storage type to read from\n " ,
71- spanWriterTypes [0 ], SpanReaderTypeEnvVar )
69+ logger .Warn ("the first span storage type listed (" + spanWriterTypes [0 ] + ") will be used for reading. " +
70+ "Please use environment variable " + SpanReaderTypeEnvVar + " to specify which storage type to read from" )
7271 }
7372 spanReaderType = spanWriterTypes [0 ]
7473 }
@@ -81,24 +80,20 @@ func FactoryConfigFromEnvAndCLI(args []string, log io.Writer) FactoryConfig {
8180 SpanWriterTypes : spanWriterTypes ,
8281 SpanReaderType : spanReaderType ,
8382 DependenciesStorageType : depStorageType ,
84- log : log ,
83+ logger : logger ,
8584 }
8685}
8786
88- func spanStorageTypeFromArgs (args []string , log io. Writer ) string {
87+ func spanStorageTypeFromArgs (args []string , logger * zap. Logger ) string {
8988 for i , token := range args {
9089 if i == 0 {
9190 continue // skip app name; easier than dealing with +-1 offset
9291 }
9392 if ! strings .HasPrefix (token , spanStorageFlag ) {
9493 continue
9594 }
96- fmt .Fprintf (
97- log ,
98- "WARNING: found deprecated command line option %s, please use environment variable %s instead\n " ,
99- token ,
100- SpanStorageTypeEnvVar ,
101- )
95+ logger .Warn ("found deprecated command line option " + token +
96+ ", please use environment variable " + SpanStorageTypeEnvVar + " instead" )
10297 if token == spanStorageFlag && i < len (args )- 1 {
10398 return args [i + 1 ]
10499 }
0 commit comments