Elektron Logging library (#16)

switch to logrus for logging.

replaced old logging library with a wrapper around logrus.
We now just need to use the exported Log(...) and Logf(...) from the logging/
package that wraps around a set of loggers constituting a chain (following COR).
Loggers are configured using a YAML file that specifies the following.
1. enabled/disabled
2. whether the message should be logged on console.
3. filename extension.
4. minimum log level.

Retrofitted source code to now use the updated logging library.
Updated the documentation with information regarding the specification
of the log config file.

Currently, the log format in the config file is not adhered to. This is going to be
addressed in a future commit.
This commit is contained in:
Bhargavi Hanumant Alandikar 2019-12-09 20:15:33 -05:00 committed by PRADYUMNA KAUSHIK
parent 9977251c14
commit 3543960689
61 changed files with 1510 additions and 1067 deletions

View file

@ -20,24 +20,26 @@ package schedulers
import (
"fmt"
mesos "github.com/mesos/mesos-go/api/v0/mesosproto"
sched "github.com/mesos/mesos-go/api/v0/scheduler"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
"github.com/spdfg/elektron/constants"
"github.com/spdfg/elektron/def"
elekLogDef "github.com/spdfg/elektron/logging/def"
elekLog "github.com/spdfg/elektron/logging"
. "github.com/spdfg/elektron/logging/types"
"github.com/spdfg/elektron/utilities"
"github.com/spdfg/elektron/utilities/mesosUtils"
"log"
)
func coLocated(tasks map[string]bool, s BaseScheduler) {
for task := range tasks {
s.Log(elekLogDef.GENERAL, task)
for _, task := range tasks {
elekLog.WithField("Task", fmt.Sprintf("%v", task)).Log(CONSOLE, log.InfoLevel, "")
}
s.Log(elekLogDef.GENERAL, "---------------------")
elekLog.Log(CONSOLE, log.InfoLevel, "---------------------")
}
// Get the powerClass of the given hostname.
@ -129,14 +131,6 @@ func WithPCPLog(pcpLog chan struct{}) SchedulerOptions {
}
}
func WithLoggingChannels(lmt chan elekLogDef.LogMessageType, msg chan string) SchedulerOptions {
return func(s ElectronScheduler) error {
s.(*BaseScheduler).logMsgType = lmt
s.(*BaseScheduler).logMsg = msg
return nil
}
}
func WithSchedPolSwitchEnabled(enableSchedPolicySwitch bool, switchingCriteria string) SchedulerOptions {
return func(s ElectronScheduler) error {
s.(*BaseScheduler).schedPolSwitchEnabled = enableSchedPolicySwitch