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:
parent
9977251c14
commit
3543960689
61 changed files with 1510 additions and 1067 deletions
|
@ -1,20 +1,20 @@
|
|||
// Copyright (C) 2018 spdfg
|
||||
//
|
||||
//
|
||||
// This file is part of Elektron.
|
||||
//
|
||||
//
|
||||
// Elektron is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// Elektron is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Elektron. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
//
|
||||
|
||||
package def
|
||||
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
// Copyright (C) 2018 spdfg
|
||||
//
|
||||
//
|
||||
// This file is part of Elektron.
|
||||
//
|
||||
//
|
||||
// Elektron is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// Elektron is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Elektron. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
//
|
||||
|
||||
package def
|
||||
|
||||
|
|
10
def/task.go
10
def/task.go
|
@ -1,20 +1,20 @@
|
|||
// Copyright (C) 2018 spdfg
|
||||
//
|
||||
//
|
||||
// This file is part of Elektron.
|
||||
//
|
||||
//
|
||||
// Elektron is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// Elektron is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Elektron. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
//
|
||||
|
||||
package def
|
||||
|
||||
|
|
|
@ -1,31 +1,33 @@
|
|||
// Copyright (C) 2018 spdfg
|
||||
//
|
||||
//
|
||||
// This file is part of Elektron.
|
||||
//
|
||||
//
|
||||
// Elektron is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
//
|
||||
// Elektron is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Elektron. If not, see <http://www.gnu.org/licenses/>.
|
||||
//
|
||||
//
|
||||
|
||||
package def
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"sort"
|
||||
|
||||
"github.com/mash/gokmeans"
|
||||
"github.com/montanaflynn/stats"
|
||||
log "github.com/sirupsen/logrus"
|
||||
elekLog "github.com/spdfg/elektron/logging"
|
||||
. "github.com/spdfg/elektron/logging/types"
|
||||
)
|
||||
|
||||
// Information about a cluster of tasks.
|
||||
|
@ -50,7 +52,7 @@ 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.")
|
||||
elekLog.Log(CONSOLE, log.FatalLevel, "Unable to classify tasks. Missing Watts or ClassToWatts attribute in workload")
|
||||
return []float64{0.0} // Won't reach here.
|
||||
}
|
||||
}
|
||||
|
@ -105,7 +107,7 @@ func clusterSizeAvgMMMPU(tasks []Task, taskObservation func(task Task) []float64
|
|||
} else {
|
||||
// skip this value
|
||||
// there is an error in the task config.
|
||||
log.Println(err)
|
||||
elekLog.Log(CONSOLE, log.ErrorLevel, err.Error())
|
||||
}
|
||||
} else {
|
||||
// There is only one observation for the task.
|
||||
|
|
|
@ -20,11 +20,12 @@ package def
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
mesos "github.com/mesos/mesos-go/api/v0/mesosproto"
|
||||
"github.com/spdfg/elektron/constants"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestTasksFromJSON(t *testing.T) {
|
||||
|
|
Reference in a new issue