-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
53 lines (41 loc) · 1.24 KB
/
main.go
File metadata and controls
53 lines (41 loc) · 1.24 KB
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
package main
import (
"os"
log "github.com/sirupsen/logrus"
)
func init() {
// Configure Logrus
log.SetFormatter(&log.JSONFormatter{})
log.SetOutput(os.Stdout)
// Set log level from environment variable or default to info
logLevel := getEnvWithDefault("LOG_LEVEL", "info")
if level, err := log.ParseLevel(logLevel); err == nil {
log.SetLevel(level)
} else {
log.SetLevel(log.InfoLevel)
}
log.Debug("Logrus initialized with JSON formatter")
}
func main() {
log.Debug("Starting application initialization")
// Log all environment variables in debug mode
for _, env := range os.Environ() {
log.WithField("env", env).Debug("Environment variable")
}
log.Info("Starting Superclass server")
// Get configuration from environment
log.Debug("Creating server instance from environment")
server := NewServerFromEnv()
// Get port from environment or use default
port := getEnvIntWithDefault("PORT", 8080)
log.WithFields(log.Fields{
"port": port,
"pid": os.Getpid(),
"working_dir": getEnvWithDefault("PWD", "unknown"),
}).Info("Server configuration loaded")
log.Debug("Initiating server start sequence")
// Start server
if err := server.Start(port); err != nil {
log.WithError(err).Fatal("Server failed to start")
}
}