Skip to content

Commit 27c0285

Browse files
authored
Merge pull request #7 from maximhq/fix/adds-maxim-log-repo-id-env-support
chore: adds MAXIM_LOG_REPO_ID support
2 parents fec29f7 + 95e75db commit 27c0285

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

logging/logger.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,14 @@ func NewLogger(baseUrl string, apiKey string, c *LoggerConfig) *Logger {
2828
}
2929
if c.Id == "" {
3030
// We will check if its present in the env
31-
c.Id = os.Getenv("MAXIM_LOG_ID")
31+
// First case is for backward compatibility
32+
if os.Getenv("MAXIM_LOG_ID") != "" {
33+
c.Id = os.Getenv("MAXIM_LOG_ID")
34+
} else if os.Getenv("MAXIM_LOG_REPO_ID") != "" {
35+
c.Id = os.Getenv("MAXIM_LOG_REPO_ID")
36+
} else {
37+
panic("MAXIM_LOG_REPO_ID environment variable is not set. Either set log repo id it in the LoggerConfig or set environment variable MAXIM_LOG_REPO_ID")
38+
}
3239
}
3340
return &Logger{
3441
config: *c,

0 commit comments

Comments
 (0)