syslog writing works

This commit is contained in:
2026-01-12 17:43:06 +01:00
parent 306535c933
commit cdf6a6c44a
7 changed files with 269 additions and 127 deletions

View File

@@ -1,33 +1,41 @@
package config
import "encoding/json"
import "log"
import "os"
import (
"encoding/json"
"log"
"os"
)
type HandlerConfigT struct {
Attributes map[string]string `json:"attributes"`
Attributes map[string]string `json:"attributes"`
}
type ConfigT struct {
Mqtt struct {
Broker string `json:"broker"`
Username string `json:"username"`
Password string
TlsEnable string `json:"tlsEnable"`
} `json:"mqtt"`
IncludeTopics []string `json:"includeTopics"`
ExcludeTopics []string `json:"excludeTopics"`
Mqtt struct {
Broker string `json:"broker"`
Username string `json:"username"`
Password string
TlsEnable string `json:"tlsEnable"`
} `json:"mqtt"`
IncludeTopics []string `json:"includeTopics"`
ExcludeTopics []string `json:"excludeTopics"`
Syslog struct {
Enable string `json:"enable"`
Network string `json:"network"`
Server string `json:"server"`
Facility string `json:"facility"`
Severity string `json:"severity"`
Tag string `json:"tag"`
} `json:"syslog"`
}
var Config ConfigT
func LoadConfiguration() {
err := json.Unmarshal([]byte(os.Getenv("MA_CONF")), &Config)
if err != nil {
log.Fatalf("Unable to parse configuration: %s", err)
}
err := json.Unmarshal([]byte(os.Getenv("MA_CONF")), &Config)
if err != nil {
log.Fatalf("Unable to parse configuration: %s", err)
}
Config.Mqtt.Password = os.Getenv("MQTT_PASSWORD")
Config.Mqtt.Password = os.Getenv("MQTT_PASSWORD")
}