diff --git a/def/taskUtils.go b/def/taskUtils.go index 33f19f2..ba019e2 100644 --- a/def/taskUtils.go +++ b/def/taskUtils.go @@ -21,11 +21,13 @@ package def import ( "errors" "fmt" - "log" "sort" "github.com/mash/gokmeans" "github.com/montanaflynn/stats" + "github.com/spdfg/elektron/elektronLogging" + elekLogT "github.com/spdfg/elektron/elektronLogging/types" + log "github.com/sirupsen/logrus" ) // Information about a cluster of tasks. @@ -50,7 +52,8 @@ func (tc TasksToClassify) taskObservationCalculator(task Task) []float64 { } else if task.Watts != 0.0 { return []float64{task.Watts} } else { - log.Fatal("Unable to classify tasks. Missing Watts or ClassToWatts attribute in workload.") + elektronLogging.ElektronLog.Log(elekLogT.ERROR, log.FatalLevel, + log.Fields {}, "Unable to classify tasks. Missing Watts or ClassToWatts attribute in workload") return []float64{0.0} // Won't reach here. } } @@ -105,7 +108,8 @@ func clusterSizeAvgMMMPU(tasks []Task, taskObservation func(task Task) []float64 } else { // skip this value // there is an error in the task config. - log.Println(err) + elektronLogging.ElektronLog.Log(elekLogT.ERROR, log.ErrorLevel, + log.Fields {}, fmt.Sprintf("%s",err)) } } else { // There is only one observation for the task. diff --git a/utilities/offerUtils/offerUtils.go b/utilities/offerUtils/offerUtils.go index 2d67af1..7f05411 100644 --- a/utilities/offerUtils/offerUtils.go +++ b/utilities/offerUtils/offerUtils.go @@ -19,11 +19,13 @@ package offerUtils import ( - "log" "strings" - + "fmt" mesos "github.com/mesos/mesos-go/api/v0/mesosproto" "github.com/spdfg/elektron/constants" + "github.com/spdfg/elektron/elektronLogging" + elekLogT "github.com/spdfg/elektron/elektronLogging/types" + log "github.com/sirupsen/logrus" ) func OfferAgg(offer *mesos.Offer) (float64, float64, float64) { @@ -88,12 +90,14 @@ func UpdateEnvironment(offer *mesos.Offer) { var host = offer.GetHostname() // If this host is not present in the set of hosts. if _, ok := constants.Hosts[host]; !ok { - log.Printf("New host detected. Adding host [%s]", host) + elektronLogging.ElektronLog.Log(elekLogT.GENERAL, log.InfoLevel, + log.Fields {"Adding host" : fmt.Sprintf("%s",host)}, "New host detected") // Add this host. constants.Hosts[host] = struct{}{} // Get the power class of this host. class := PowerClass(offer) - log.Printf("Registering the power class... Host [%s] --> PowerClass [%s]", host, class) + elektronLogging.ElektronLog.Log(elekLogT.GENERAL, log.InfoLevel, + log.Fields {"host" : fmt.Sprintf("%s",host), "PowerClass" : fmt.Sprintf("%s", class)}, "Registering the power class...") // If new power class, register the power class. if _, ok := constants.PowerClasses[class]; !ok { constants.PowerClasses[class] = make(map[string]struct{}) diff --git a/utilities/schedUtils/schedUtils.go b/utilities/schedUtils/schedUtils.go index e25437e..31eff56 100644 --- a/utilities/schedUtils/schedUtils.go +++ b/utilities/schedUtils/schedUtils.go @@ -19,10 +19,12 @@ package schedUtils import ( - "log" - + "fmt" "github.com/spdfg/elektron/def" "github.com/spdfg/elektron/utilities" + "github.com/spdfg/elektron/elektronLogging" + elekLogT "github.com/spdfg/elektron/elektronLogging/types" + log "github.com/sirupsen/logrus" ) // Criteria for resizing the scheduling window. @@ -77,8 +79,9 @@ func (s *fillNextOfferCycle) apply(taskQueue []def.Task) (int, int) { for _, task := range taskQueue { numberOfTasksTraversed++ for i := *task.Instances; i > 0; i-- { - log.Printf("Checking if Instance #%d of Task[%s] can be scheduled "+ - "during the next offer cycle...", i, task.Name) + elektronLogging.ElektronLog.Log(elekLogT.GENERAL, log.InfoLevel, + log.Fields {}, fmt.Sprintf("Checking if Instance #%d of Task[%s] can be scheduled "+ + "during the next offer cycle...", i, task.Name)) if canSchedule(task) { filledCPU += task.CPU filledRAM += task.RAM