diff --git a/elektronLogging/logger.go b/elektronLogging/logger.go index 9178c39..9c30bed 100644 --- a/elektronLogging/logger.go +++ b/elektronLogging/logger.go @@ -14,10 +14,10 @@ var formatter ElektronFormatter var ElektronLog *LoggerImpl var logDir logDirectory -func BuildLogger(prefix string) { +func BuildLogger(prefix string, logConfigFilename string) { // read configuration from yaml - config.GetConfig() + config.GetConfig(logConfigFilename) // create the log directory startTime := time.Now() diff --git a/elektronLogging/loggerChain.go b/elektronLogging/loggerChain.go index b92904c..3cd2ff3 100644 --- a/elektronLogging/loggerChain.go +++ b/elektronLogging/loggerChain.go @@ -13,7 +13,7 @@ type Logger interface { type LoggerImpl struct { Type int AllowOnConsole bool - LogFile *os.File + LogFile *os.File next Logger } diff --git a/elektronLogging/loggerConfig.go b/elektronLogging/loggerConfig.go index 344540e..06ac247 100644 --- a/elektronLogging/loggerConfig.go +++ b/elektronLogging/loggerConfig.go @@ -2,7 +2,6 @@ package elektronLogging import ( log "github.com/sirupsen/logrus" - elekEnv "github.com/spdfg/elektron/environment" "gopkg.in/yaml.v2" "io/ioutil" ) @@ -48,9 +47,9 @@ type LoggerConfig struct { Format []string `yaml:"format"` } -func (c *LoggerConfig) GetConfig() *LoggerConfig { +func (c *LoggerConfig) GetConfig(logConfigFilename string) *LoggerConfig { - yamlFile, err := ioutil.ReadFile(elekEnv.LogConfigYaml) + yamlFile, err := ioutil.ReadFile(logConfigFilename) if err != nil { log.Printf("Error in reading yaml file #%v ", err) } diff --git a/environment/env.go b/environment/env.go index c1abed1..239e104 100644 --- a/environment/env.go +++ b/environment/env.go @@ -26,5 +26,3 @@ var RaplPassword = "RAPL_PSSWD" // Location of the script that sets the powercap value for a host. var RaplThrottleScriptLocation = "RAPL_PKG_THROTTLE_SCRIPT_LOCATION" - -var LogConfigYaml = "logConfig.yaml" diff --git a/scheduler.go b/scheduler.go index 5ec6bc5..299dfca 100644 --- a/scheduler.go +++ b/scheduler.go @@ -55,6 +55,7 @@ var fixFirstSchedPol = flag.String("fixFirstSchedPol", "", "Name of the scheduli var fixSchedWindow = flag.Bool("fixSchedWindow", false, "Fix the size of the scheduling window that every deployed scheduling policy should schedule, provided switching is enabled.") var schedWindowSize = flag.Int("schedWindowSize", 200, "Size of the scheduling window if fixSchedWindow is set.") var schedPolSwitchCriteria = flag.String("schedPolSwitchCriteria", "taskDist", "Scheduling policy switching criteria.") +var logConfigFilename = flag.String("logConfigFilename", "logConfig.yaml", "Log Configuration file name") // Short hand args func init() { @@ -76,6 +77,7 @@ func init() { flag.BoolVar(fixSchedWindow, "fixSw", false, "Fix the size of the scheduling window that every deployed scheduling policy should schedule, provided switching is enabled (shorthand).") flag.IntVar(schedWindowSize, "swSize", 200, "Size of the scheduling window if fixSchedWindow is set (shorthand).") flag.StringVar(schedPolSwitchCriteria, "spsCriteria", "taskDist", "Scheduling policy switching criteria (shorthand).") + flag.StringVar(logConfigFilename, "lgConfigName", "logConfig.yaml", "Log Configuration file name (shorthand).") } func listAllSchedulingPolicies() { @@ -223,7 +225,7 @@ func main() { if strings.Contains(*pcplogPrefix, "/") { log.Fatal("log file prefix should not contain '/'.") } - elekLog.BuildLogger(*pcplogPrefix) + elekLog.BuildLogger(*pcplogPrefix, *logConfigFilename) // Starting PCP logging. if noPowercap {