@@ -23,6 +23,7 @@ const (
23
23
githubTokenEnvVar = "GITHUB_TOKEN"
24
24
githubClientIDEnvVar = "GITHUB_CLIENT_ID"
25
25
githubClientSecretEnvVar = "GITHUB_CLIENT_SECRET"
26
+ logLevelEnvVar = "LOG_LEVEL"
26
27
)
27
28
28
29
const (
@@ -68,6 +69,9 @@ const (
68
69
69
70
// Pub/Sub Config
70
71
ConfigCrawlPubSubTopic = "crawl-events"
72
+
73
+ // Log Config
74
+ ConfigLogLevel = "log-level"
71
75
)
72
76
73
77
func loadConfig (ctx context.Context , args []string ) (* viper.Viper , error ) {
@@ -111,6 +115,7 @@ func loadConfig(ctx context.Context, args []string) (*viper.Viper, error) {
111
115
v .BindEnv (ConfigGithubToken , githubTokenEnvVar )
112
116
v .BindEnv (ConfigGithubClientID , githubClientIDEnvVar )
113
117
v .BindEnv (ConfigGithubClientSecret , githubClientSecretEnvVar )
118
+ v .BindEnv (ConfigLogLevel , logLevelEnvVar )
114
119
115
120
// Read from config.
116
121
if err := readViperConfig (ctx , v ); err != nil {
@@ -120,6 +125,8 @@ func loadConfig(ctx context.Context, args []string) (*viper.Viper, error) {
120
125
// Set defaults based on other configs
121
126
setDefaults (v )
122
127
128
+ log .SetLevel (v .GetString (ConfigLogLevel ))
129
+
123
130
log .Debug (ctx , "config values loaded" , "values" , v .AllSettings ())
124
131
return v , nil
125
132
}
@@ -173,6 +180,7 @@ func buildFlags() *pflag.FlagSet {
173
180
flags .String (ConfigGAERemoteAPI , "" , "Remoteapi endpoint for App Engine Search. Defaults to serviceproxy-dot-${project}.appspot.com." )
174
181
flags .Float64 (ConfigTraceSamplerFraction , 0.1 , "Fraction of the requests sampled by the trace API." )
175
182
flags .Float64 (ConfigTraceSamplerMaxQPS , 5 , "Max number of requests sampled every second by the trace API." )
183
+ flags .String (ConfigLogLevel , "info" , "Determine which level of logs to print." )
176
184
177
185
return flags
178
186
}
0 commit comments