WIP : Elektron Logging library #16
|
@ -52,7 +52,7 @@ func (tc TasksToClassify) taskObservationCalculator(task Task) []float64 {
|
|||
![]() Okay. Done Okay. Done
![]() I would alias this to elekLog as you seem to be using that prefix when aliasing imports of sub-packages. I would alias this to _elekLog_ as you seem to be using that prefix when aliasing imports of sub-packages.
![]() Okay. Done Okay. Done
|
||||
} else if task.Watts != 0.0 {
|
||||
return []float64{task.Watts}
|
||||
} else {
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE, log.FatalLevel,
|
||||
![]() I would alias this to elekLog as you seem to be using that prefix when aliasing imports of sub-packages. I would alias this to _elekLog_ as you seem to be using that prefix when aliasing imports of sub-packages.
![]() Okay. Done Okay. Done
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE, log.FatalLevel,
|
||||
![]() I would alias this to elekLog as you seem to be using that prefix when aliasing imports of sub-packages. I would alias this to _elekLog_ as you seem to be using that prefix when aliasing imports of sub-packages.
![]() Okay. Done Okay. Done
|
||||
log.Fields{}, "Unable to classify tasks. Missing Watts or ClassToWatts attribute in workload")
|
||||
return []float64{0.0} // Won't reach here.
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ func clusterSizeAvgMMMPU(tasks []Task, taskObservation func(task Task) []float64
|
|||
![]() I would alias this to elekLog as you seem to be using that prefix when aliasing imports of sub-packages. I would alias this to _elekLog_ as you seem to be using that prefix when aliasing imports of sub-packages.
![]() Okay. Done Okay. Done
![]() I would alias this to elekLog as you seem to be using that prefix when aliasing imports of sub-packages. I would alias this to _elekLog_ as you seem to be using that prefix when aliasing imports of sub-packages.
![]() Okay. Done Okay. Done
|
||||
} else {
|
||||
// skip this value
|
||||
// there is an error in the task config.
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE, log.ErrorLevel,
|
||||
![]() I would alias this to elekLog as you seem to be using that prefix when aliasing imports of sub-packages. I would alias this to _elekLog_ as you seem to be using that prefix when aliasing imports of sub-packages.
![]() Okay. Done Okay. Done
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE, log.ErrorLevel,
|
||||
![]() I would alias this to elekLog as you seem to be using that prefix when aliasing imports of sub-packages. I would alias this to _elekLog_ as you seem to be using that prefix when aliasing imports of sub-packages.
![]() Okay. Done Okay. Done
|
||||
log.Fields{}, err.Error())
|
||||
}
|
||||
} else {
|
||||
|
|
|||
![]() I would alias this to elekLog as you seem to be using that prefix when aliasing imports of sub-packages. I would alias this to _elekLog_ as you seem to be using that prefix when aliasing imports of sub-packages.
![]() Okay. Done Okay. Done
![]() I would alias this to elekLog as you seem to be using that prefix when aliasing imports of sub-packages. I would alias this to _elekLog_ as you seem to be using that prefix when aliasing imports of sub-packages.
![]() Okay. Done Okay. Done
|
|
@ -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) {
|
||||
|
|
|
@ -3,8 +3,9 @@ package elektronLogging
|
|||
![]() Formatting Formatting
![]() Formatting Formatting
![]() Use strings.join instead. You should create the slice and append the message if necessary. Use [strings.join](https://golang.org/pkg/strings/#Join) instead. You should create the slice and append the message if necessary.
![]() This seems really inefficient. Wouldn't value already have to be a string for this to succeed? In which case, I don't think we gain anything here by suing a sprintf. This seems really inefficient. Wouldn't value already have to be a string for this to succeed? In which case, I don't think we gain anything here by suing a sprintf.
![]() Okay. Sure Okay. Sure
![]() value is not a string here, it is of type interface{}. But to avoid using sprintf, would it be fine to use type assertion? For eg : value is not a string here, it is of type interface{}. But to avoid using sprintf, would it be fine to use type assertion? For eg : `value.(string) `
![]() Done Done
![]() Done Done
![]() Line 43 and 44 can fit in one line. We currently do not have any style linting setup. Line 43 and 44 can fit in one line. We currently do not have any style linting setup.
![]() Peeked at how logrus serializes values and seems like fmt.Sprint is used if type assertion fails. Peeked at how [logrus](https://github.com/sirupsen/logrus/blob/67a7fdcf741f4d5cee82cb9800994ccfd4393ad0/text_formatter.go#L315) serializes values and seems like fmt.Sprint is used if type assertion fails.
![]() ahh alright, I thought it was a string coming in. Alright, if it's been sanity checked then i'm good with it. ahh alright, I thought it was a string coming in. Alright, if it's been sanity checked then i'm good with it.
![]() Okay Okay
![]() Formatting Formatting
![]() Formatting Formatting
![]() Use strings.join instead. You should create the slice and append the message if necessary. Use [strings.join](https://golang.org/pkg/strings/#Join) instead. You should create the slice and append the message if necessary.
![]() This seems really inefficient. Wouldn't value already have to be a string for this to succeed? In which case, I don't think we gain anything here by suing a sprintf. This seems really inefficient. Wouldn't value already have to be a string for this to succeed? In which case, I don't think we gain anything here by suing a sprintf.
![]() Okay. Sure Okay. Sure
![]() value is not a string here, it is of type interface{}. But to avoid using sprintf, would it be fine to use type assertion? For eg : value is not a string here, it is of type interface{}. But to avoid using sprintf, would it be fine to use type assertion? For eg : `value.(string) `
![]() Done Done
![]() Done Done
![]() Line 43 and 44 can fit in one line. We currently do not have any style linting setup. Line 43 and 44 can fit in one line. We currently do not have any style linting setup.
![]() Peeked at how logrus serializes values and seems like fmt.Sprint is used if type assertion fails. Peeked at how [logrus](https://github.com/sirupsen/logrus/blob/67a7fdcf741f4d5cee82cb9800994ccfd4393ad0/text_formatter.go#L315) serializes values and seems like fmt.Sprint is used if type assertion fails.
![]() ahh alright, I thought it was a string coming in. Alright, if it's been sanity checked then i'm good with it. ahh alright, I thought it was a string coming in. Alright, if it's been sanity checked then i'm good with it.
![]() Okay Okay
|
||||
import (
|
||||
"bytes"
|
||||
"github.com/fatih/color"
|
||||
log "github.com/sirupsen/logrus"
|
||||
![]() Formatting Formatting
![]() Formatting Formatting
![]() Use strings.join instead. You should create the slice and append the message if necessary. Use [strings.join](https://golang.org/pkg/strings/#Join) instead. You should create the slice and append the message if necessary.
![]() This seems really inefficient. Wouldn't value already have to be a string for this to succeed? In which case, I don't think we gain anything here by suing a sprintf. This seems really inefficient. Wouldn't value already have to be a string for this to succeed? In which case, I don't think we gain anything here by suing a sprintf.
![]() Okay. Sure Okay. Sure
![]() value is not a string here, it is of type interface{}. But to avoid using sprintf, would it be fine to use type assertion? For eg : value is not a string here, it is of type interface{}. But to avoid using sprintf, would it be fine to use type assertion? For eg : `value.(string) `
![]() Done Done
![]() Done Done
![]() Line 43 and 44 can fit in one line. We currently do not have any style linting setup. Line 43 and 44 can fit in one line. We currently do not have any style linting setup.
![]() Peeked at how logrus serializes values and seems like fmt.Sprint is used if type assertion fails. Peeked at how [logrus](https://github.com/sirupsen/logrus/blob/67a7fdcf741f4d5cee82cb9800994ccfd4393ad0/text_formatter.go#L315) serializes values and seems like fmt.Sprint is used if type assertion fails.
![]() ahh alright, I thought it was a string coming in. Alright, if it's been sanity checked then i'm good with it. ahh alright, I thought it was a string coming in. Alright, if it's been sanity checked then i'm good with it.
![]() Okay Okay
|
||||
"strings"
|
||||
|
||||
![]() Formatting Formatting
![]() Formatting Formatting
![]() Use strings.join instead. You should create the slice and append the message if necessary. Use [strings.join](https://golang.org/pkg/strings/#Join) instead. You should create the slice and append the message if necessary.
![]() This seems really inefficient. Wouldn't value already have to be a string for this to succeed? In which case, I don't think we gain anything here by suing a sprintf. This seems really inefficient. Wouldn't value already have to be a string for this to succeed? In which case, I don't think we gain anything here by suing a sprintf.
![]() Okay. Sure Okay. Sure
![]() value is not a string here, it is of type interface{}. But to avoid using sprintf, would it be fine to use type assertion? For eg : value is not a string here, it is of type interface{}. But to avoid using sprintf, would it be fine to use type assertion? For eg : `value.(string) `
![]() Done Done
![]() Done Done
![]() Line 43 and 44 can fit in one line. We currently do not have any style linting setup. Line 43 and 44 can fit in one line. We currently do not have any style linting setup.
![]() Peeked at how logrus serializes values and seems like fmt.Sprint is used if type assertion fails. Peeked at how [logrus](https://github.com/sirupsen/logrus/blob/67a7fdcf741f4d5cee82cb9800994ccfd4393ad0/text_formatter.go#L315) serializes values and seems like fmt.Sprint is used if type assertion fails.
![]() ahh alright, I thought it was a string coming in. Alright, if it's been sanity checked then i'm good with it. ahh alright, I thought it was a string coming in. Alright, if it's been sanity checked then i'm good with it.
![]() Okay Okay
|
||||
log "github.com/sirupsen/logrus"
|
||||
![]() Formatting Formatting
![]() Formatting Formatting
![]() Use strings.join instead. You should create the slice and append the message if necessary. Use [strings.join](https://golang.org/pkg/strings/#Join) instead. You should create the slice and append the message if necessary.
![]() This seems really inefficient. Wouldn't value already have to be a string for this to succeed? In which case, I don't think we gain anything here by suing a sprintf. This seems really inefficient. Wouldn't value already have to be a string for this to succeed? In which case, I don't think we gain anything here by suing a sprintf.
![]() Okay. Sure Okay. Sure
![]() value is not a string here, it is of type interface{}. But to avoid using sprintf, would it be fine to use type assertion? For eg : value is not a string here, it is of type interface{}. But to avoid using sprintf, would it be fine to use type assertion? For eg : `value.(string) `
![]() Done Done
![]() Done Done
![]() Line 43 and 44 can fit in one line. We currently do not have any style linting setup. Line 43 and 44 can fit in one line. We currently do not have any style linting setup.
![]() Peeked at how logrus serializes values and seems like fmt.Sprint is used if type assertion fails. Peeked at how [logrus](https://github.com/sirupsen/logrus/blob/67a7fdcf741f4d5cee82cb9800994ccfd4393ad0/text_formatter.go#L315) serializes values and seems like fmt.Sprint is used if type assertion fails.
![]() ahh alright, I thought it was a string coming in. Alright, if it's been sanity checked then i'm good with it. ahh alright, I thought it was a string coming in. Alright, if it's been sanity checked then i'm good with it.
![]() Okay Okay
|
||||
)
|
||||
|
||||
type ElektronFormatter struct {
|
||||
|
|
|||
![]() Formatting Formatting
![]() Formatting Formatting
![]() Use strings.join instead. You should create the slice and append the message if necessary. Use [strings.join](https://golang.org/pkg/strings/#Join) instead. You should create the slice and append the message if necessary.
![]() This seems really inefficient. Wouldn't value already have to be a string for this to succeed? In which case, I don't think we gain anything here by suing a sprintf. This seems really inefficient. Wouldn't value already have to be a string for this to succeed? In which case, I don't think we gain anything here by suing a sprintf.
![]() Okay. Sure Okay. Sure
![]() value is not a string here, it is of type interface{}. But to avoid using sprintf, would it be fine to use type assertion? For eg : value is not a string here, it is of type interface{}. But to avoid using sprintf, would it be fine to use type assertion? For eg : `value.(string) `
![]() Done Done
![]() Done Done
![]() Line 43 and 44 can fit in one line. We currently do not have any style linting setup. Line 43 and 44 can fit in one line. We currently do not have any style linting setup.
![]() Peeked at how logrus serializes values and seems like fmt.Sprint is used if type assertion fails. Peeked at how [logrus](https://github.com/sirupsen/logrus/blob/67a7fdcf741f4d5cee82cb9800994ccfd4393ad0/text_formatter.go#L315) serializes values and seems like fmt.Sprint is used if type assertion fails.
![]() ahh alright, I thought it was a string coming in. Alright, if it's been sanity checked then i'm good with it. ahh alright, I thought it was a string coming in. Alright, if it's been sanity checked then i'm good with it.
![]() Okay Okay
![]() Formatting Formatting
![]() Formatting Formatting
![]() Use strings.join instead. You should create the slice and append the message if necessary. Use [strings.join](https://golang.org/pkg/strings/#Join) instead. You should create the slice and append the message if necessary.
![]() This seems really inefficient. Wouldn't value already have to be a string for this to succeed? In which case, I don't think we gain anything here by suing a sprintf. This seems really inefficient. Wouldn't value already have to be a string for this to succeed? In which case, I don't think we gain anything here by suing a sprintf.
![]() Okay. Sure Okay. Sure
![]() value is not a string here, it is of type interface{}. But to avoid using sprintf, would it be fine to use type assertion? For eg : value is not a string here, it is of type interface{}. But to avoid using sprintf, would it be fine to use type assertion? For eg : `value.(string) `
![]() Done Done
![]() Done Done
![]() Line 43 and 44 can fit in one line. We currently do not have any style linting setup. Line 43 and 44 can fit in one line. We currently do not have any style linting setup.
![]() Peeked at how logrus serializes values and seems like fmt.Sprint is used if type assertion fails. Peeked at how [logrus](https://github.com/sirupsen/logrus/blob/67a7fdcf741f4d5cee82cb9800994ccfd4393ad0/text_formatter.go#L315) serializes values and seems like fmt.Sprint is used if type assertion fails.
![]() ahh alright, I thought it was a string coming in. Alright, if it's been sanity checked then i'm good with it. ahh alright, I thought it was a string coming in. Alright, if it's been sanity checked then i'm good with it.
![]() Okay Okay
|
|
@ -1,10 +1,11 @@
|
|||
![]() Use struct literals instead of new as it's more descriptive: Use struct literals instead of new as it's more descriptive:
`&ClsfnTaskDistOverheadLogger{}`
![]() Where is log dir coming from? Shouldn't be a global Where is log dir coming from? Shouldn't be a global
![]() Okay, will do the changes Okay, will do the changes
![]() It is defined in It is defined in `createLogDir.go`. Since all these files belong to same package, I accessed it in this way.
![]() I think it will be better if it is encapsulated.
I think it will be better if it is encapsulated.
Something like
```go
type logDir struct {
name string
// other fields if necessary.
}
```
![]() Maybe refactor to Maybe refactor to `ClsfnTaskDistrOverheadLogger` so that it is clear that we are intending "Distribution" and now "Distance"?
![]() You should use filepath.Join(...) to keep it generic. You should use [filepath.Join(...)](https://golang.org/src/path/filepath/path.go?s=5893:5925#L199) to keep it generic.
![]() You can possible rewrite this function to something like the one shown below.
You can possible rewrite this function to something like the one shown below.
```go
func (cLog *ClsfnTaskDistOverheadLogger) SetLogFile(prefix string) {
filename := prefix + config.TaskDistConfig.FilenameExtension
if logDir != "" {
if logFile, err := os.Create(filepath.Join(logDir, filename)); err != nil {
log.Fatal("Unable to create logFile: ", err)
} else {
cLog.LogFileName = logFile
cLog.AllowOnConsole = config.TaskDistConfig.AllowOnConsole
}
}
}
```
![]() Done Done
![]() Done Done
![]() Okay. Sure Okay. Sure
![]() Done Done
![]() looks good now thanks! looks good now thanks!
![]() Use struct literals instead of new as it's more descriptive: Use struct literals instead of new as it's more descriptive:
`&ClsfnTaskDistOverheadLogger{}`
![]() Where is log dir coming from? Shouldn't be a global Where is log dir coming from? Shouldn't be a global
![]() Okay, will do the changes Okay, will do the changes
![]() It is defined in It is defined in `createLogDir.go`. Since all these files belong to same package, I accessed it in this way.
![]() I think it will be better if it is encapsulated.
I think it will be better if it is encapsulated.
Something like
```go
type logDir struct {
name string
// other fields if necessary.
}
```
![]() Maybe refactor to Maybe refactor to `ClsfnTaskDistrOverheadLogger` so that it is clear that we are intending "Distribution" and now "Distance"?
![]() You should use filepath.Join(...) to keep it generic. You should use [filepath.Join(...)](https://golang.org/src/path/filepath/path.go?s=5893:5925#L199) to keep it generic.
![]() You can possible rewrite this function to something like the one shown below.
You can possible rewrite this function to something like the one shown below.
```go
func (cLog *ClsfnTaskDistOverheadLogger) SetLogFile(prefix string) {
filename := prefix + config.TaskDistConfig.FilenameExtension
if logDir != "" {
if logFile, err := os.Create(filepath.Join(logDir, filename)); err != nil {
log.Fatal("Unable to create logFile: ", err)
} else {
cLog.LogFileName = logFile
cLog.AllowOnConsole = config.TaskDistConfig.AllowOnConsole
}
}
}
```
![]() Done Done
![]() Done Done
![]() Okay. Sure Okay. Sure
![]() Done Done
![]() looks good now thanks! looks good now thanks!
|
||||
package elektronLogging
|
||||
|
||||
import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
![]() Use struct literals instead of new as it's more descriptive: Use struct literals instead of new as it's more descriptive:
`&ClsfnTaskDistOverheadLogger{}`
![]() Where is log dir coming from? Shouldn't be a global Where is log dir coming from? Shouldn't be a global
![]() Okay, will do the changes Okay, will do the changes
![]() It is defined in It is defined in `createLogDir.go`. Since all these files belong to same package, I accessed it in this way.
![]() I think it will be better if it is encapsulated.
I think it will be better if it is encapsulated.
Something like
```go
type logDir struct {
name string
// other fields if necessary.
}
```
![]() Maybe refactor to Maybe refactor to `ClsfnTaskDistrOverheadLogger` so that it is clear that we are intending "Distribution" and now "Distance"?
![]() You should use filepath.Join(...) to keep it generic. You should use [filepath.Join(...)](https://golang.org/src/path/filepath/path.go?s=5893:5925#L199) to keep it generic.
![]() You can possible rewrite this function to something like the one shown below.
You can possible rewrite this function to something like the one shown below.
```go
func (cLog *ClsfnTaskDistOverheadLogger) SetLogFile(prefix string) {
filename := prefix + config.TaskDistConfig.FilenameExtension
if logDir != "" {
if logFile, err := os.Create(filepath.Join(logDir, filename)); err != nil {
log.Fatal("Unable to create logFile: ", err)
} else {
cLog.LogFileName = logFile
cLog.AllowOnConsole = config.TaskDistConfig.AllowOnConsole
}
}
}
```
![]() Done Done
![]() Done Done
![]() Okay. Sure Okay. Sure
![]() Done Done
![]() looks good now thanks! looks good now thanks!
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
![]() Use struct literals instead of new as it's more descriptive: Use struct literals instead of new as it's more descriptive:
`&ClsfnTaskDistOverheadLogger{}`
![]() Where is log dir coming from? Shouldn't be a global Where is log dir coming from? Shouldn't be a global
![]() Okay, will do the changes Okay, will do the changes
![]() It is defined in It is defined in `createLogDir.go`. Since all these files belong to same package, I accessed it in this way.
![]() I think it will be better if it is encapsulated.
I think it will be better if it is encapsulated.
Something like
```go
type logDir struct {
name string
// other fields if necessary.
}
```
![]() Maybe refactor to Maybe refactor to `ClsfnTaskDistrOverheadLogger` so that it is clear that we are intending "Distribution" and now "Distance"?
![]() You should use filepath.Join(...) to keep it generic. You should use [filepath.Join(...)](https://golang.org/src/path/filepath/path.go?s=5893:5925#L199) to keep it generic.
![]() You can possible rewrite this function to something like the one shown below.
You can possible rewrite this function to something like the one shown below.
```go
func (cLog *ClsfnTaskDistOverheadLogger) SetLogFile(prefix string) {
filename := prefix + config.TaskDistConfig.FilenameExtension
if logDir != "" {
if logFile, err := os.Create(filepath.Join(logDir, filename)); err != nil {
log.Fatal("Unable to create logFile: ", err)
} else {
cLog.LogFileName = logFile
cLog.AllowOnConsole = config.TaskDistConfig.AllowOnConsole
}
}
}
```
![]() Done Done
![]() Done Done
![]() Okay. Sure Okay. Sure
![]() Done Done
![]() looks good now thanks! looks good now thanks!
|
||||
log "github.com/sirupsen/logrus"
|
||||
![]() Use struct literals instead of new as it's more descriptive: Use struct literals instead of new as it's more descriptive:
`&ClsfnTaskDistOverheadLogger{}`
![]() Where is log dir coming from? Shouldn't be a global Where is log dir coming from? Shouldn't be a global
![]() Okay, will do the changes Okay, will do the changes
![]() It is defined in It is defined in `createLogDir.go`. Since all these files belong to same package, I accessed it in this way.
![]() I think it will be better if it is encapsulated.
I think it will be better if it is encapsulated.
Something like
```go
type logDir struct {
name string
// other fields if necessary.
}
```
![]() Maybe refactor to Maybe refactor to `ClsfnTaskDistrOverheadLogger` so that it is clear that we are intending "Distribution" and now "Distance"?
![]() You should use filepath.Join(...) to keep it generic. You should use [filepath.Join(...)](https://golang.org/src/path/filepath/path.go?s=5893:5925#L199) to keep it generic.
![]() You can possible rewrite this function to something like the one shown below.
You can possible rewrite this function to something like the one shown below.
```go
func (cLog *ClsfnTaskDistOverheadLogger) SetLogFile(prefix string) {
filename := prefix + config.TaskDistConfig.FilenameExtension
if logDir != "" {
if logFile, err := os.Create(filepath.Join(logDir, filename)); err != nil {
log.Fatal("Unable to create logFile: ", err)
} else {
cLog.LogFileName = logFile
cLog.AllowOnConsole = config.TaskDistConfig.AllowOnConsole
}
}
}
```
![]() Done Done
![]() Done Done
![]() Okay. Sure Okay. Sure
![]() Done Done
![]() looks good now thanks! looks good now thanks!
|
||||
)
|
||||
|
||||
type ClsfnTaskDistrOverheadLogger struct {
|
||||
|
|
|||
![]() Use struct literals instead of new as it's more descriptive: Use struct literals instead of new as it's more descriptive:
`&ClsfnTaskDistOverheadLogger{}`
![]() Where is log dir coming from? Shouldn't be a global Where is log dir coming from? Shouldn't be a global
![]() Okay, will do the changes Okay, will do the changes
![]() It is defined in It is defined in `createLogDir.go`. Since all these files belong to same package, I accessed it in this way.
![]() I think it will be better if it is encapsulated.
I think it will be better if it is encapsulated.
Something like
```go
type logDir struct {
name string
// other fields if necessary.
}
```
![]() Maybe refactor to Maybe refactor to `ClsfnTaskDistrOverheadLogger` so that it is clear that we are intending "Distribution" and now "Distance"?
![]() You should use filepath.Join(...) to keep it generic. You should use [filepath.Join(...)](https://golang.org/src/path/filepath/path.go?s=5893:5925#L199) to keep it generic.
![]() You can possible rewrite this function to something like the one shown below.
You can possible rewrite this function to something like the one shown below.
```go
func (cLog *ClsfnTaskDistOverheadLogger) SetLogFile(prefix string) {
filename := prefix + config.TaskDistConfig.FilenameExtension
if logDir != "" {
if logFile, err := os.Create(filepath.Join(logDir, filename)); err != nil {
log.Fatal("Unable to create logFile: ", err)
} else {
cLog.LogFileName = logFile
cLog.AllowOnConsole = config.TaskDistConfig.AllowOnConsole
}
}
}
```
![]() Done Done
![]() Done Done
![]() Okay. Sure Okay. Sure
![]() Done Done
![]() looks good now thanks! looks good now thanks!
![]() Use struct literals instead of new as it's more descriptive: Use struct literals instead of new as it's more descriptive:
`&ClsfnTaskDistOverheadLogger{}`
![]() Where is log dir coming from? Shouldn't be a global Where is log dir coming from? Shouldn't be a global
![]() Okay, will do the changes Okay, will do the changes
![]() It is defined in It is defined in `createLogDir.go`. Since all these files belong to same package, I accessed it in this way.
![]() I think it will be better if it is encapsulated.
I think it will be better if it is encapsulated.
Something like
```go
type logDir struct {
name string
// other fields if necessary.
}
```
![]() Maybe refactor to Maybe refactor to `ClsfnTaskDistrOverheadLogger` so that it is clear that we are intending "Distribution" and now "Distance"?
![]() You should use filepath.Join(...) to keep it generic. You should use [filepath.Join(...)](https://golang.org/src/path/filepath/path.go?s=5893:5925#L199) to keep it generic.
![]() You can possible rewrite this function to something like the one shown below.
You can possible rewrite this function to something like the one shown below.
```go
func (cLog *ClsfnTaskDistOverheadLogger) SetLogFile(prefix string) {
filename := prefix + config.TaskDistConfig.FilenameExtension
if logDir != "" {
if logFile, err := os.Create(filepath.Join(logDir, filename)); err != nil {
log.Fatal("Unable to create logFile: ", err)
} else {
cLog.LogFileName = logFile
cLog.AllowOnConsole = config.TaskDistConfig.AllowOnConsole
}
}
}
```
![]() Done Done
![]() Done Done
![]() Okay. Sure Okay. Sure
![]() Done Done
![]() looks good now thanks! looks good now thanks!
|
|
@ -1,10 +1,11 @@
|
|||
![]() I see why you are directly assigning I see why you are directly assigning `true`. However, to allow disabling console logs to stdout retrofit this to `cLog.AllowOnConsole = config.ConsoleConfig.AllowOnConsole`.
![]() Why the pointer receiver? Technically, this function should not lead to change of state. Why the pointer receiver? Technically, this function should not lead to change of state.
![]() Sure Sure
![]() Yeah, thats right. I will change it Yeah, thats right. I will change it
![]() I see why you are directly assigning I see why you are directly assigning `true`. However, to allow disabling console logs to stdout retrofit this to `cLog.AllowOnConsole = config.ConsoleConfig.AllowOnConsole`.
![]() Why the pointer receiver? Technically, this function should not lead to change of state. Why the pointer receiver? Technically, this function should not lead to change of state.
![]() Sure Sure
![]() Yeah, thats right. I will change it Yeah, thats right. I will change it
|
||||
package elektronLogging
|
||||
|
||||
import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
![]() I see why you are directly assigning I see why you are directly assigning `true`. However, to allow disabling console logs to stdout retrofit this to `cLog.AllowOnConsole = config.ConsoleConfig.AllowOnConsole`.
![]() Why the pointer receiver? Technically, this function should not lead to change of state. Why the pointer receiver? Technically, this function should not lead to change of state.
![]() Sure Sure
![]() Yeah, thats right. I will change it Yeah, thats right. I will change it
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
![]() I see why you are directly assigning I see why you are directly assigning `true`. However, to allow disabling console logs to stdout retrofit this to `cLog.AllowOnConsole = config.ConsoleConfig.AllowOnConsole`.
![]() Why the pointer receiver? Technically, this function should not lead to change of state. Why the pointer receiver? Technically, this function should not lead to change of state.
![]() Sure Sure
![]() Yeah, thats right. I will change it Yeah, thats right. I will change it
|
||||
log "github.com/sirupsen/logrus"
|
||||
![]() I see why you are directly assigning I see why you are directly assigning `true`. However, to allow disabling console logs to stdout retrofit this to `cLog.AllowOnConsole = config.ConsoleConfig.AllowOnConsole`.
![]() Why the pointer receiver? Technically, this function should not lead to change of state. Why the pointer receiver? Technically, this function should not lead to change of state.
![]() Sure Sure
![]() Yeah, thats right. I will change it Yeah, thats right. I will change it
|
||||
)
|
||||
|
||||
type ConsoleLogger struct {
|
||||
|
|
|||
![]() I see why you are directly assigning I see why you are directly assigning `true`. However, to allow disabling console logs to stdout retrofit this to `cLog.AllowOnConsole = config.ConsoleConfig.AllowOnConsole`.
![]() Why the pointer receiver? Technically, this function should not lead to change of state. Why the pointer receiver? Technically, this function should not lead to change of state.
![]() Sure Sure
![]() Yeah, thats right. I will change it Yeah, thats right. I will change it
![]() I see why you are directly assigning I see why you are directly assigning `true`. However, to allow disabling console logs to stdout retrofit this to `cLog.AllowOnConsole = config.ConsoleConfig.AllowOnConsole`.
![]() Why the pointer receiver? Technically, this function should not lead to change of state. Why the pointer receiver? Technically, this function should not lead to change of state.
![]() Sure Sure
![]() Yeah, thats right. I will change it Yeah, thats right. I will change it
|
|
@ -1,11 +1,12 @@
|
|||
![]() Why not use Why not use `string.join([]string{...}, "")` ?
![]() Yeah, thats right Yeah, thats right
![]() Extend the comment to show how the format of the log directory name is going to look. Extend the comment to show how the format of the log directory name is going to look.
![]() Keep the alias for logrus import consistent. So, refactor this to "log". Keep the alias for logrus import consistent. So, refactor this to "log".
![]() Done Done
![]() Done Done
![]() Why not use Why not use `string.join([]string{...}, "")` ?
![]() Yeah, thats right Yeah, thats right
![]() Extend the comment to show how the format of the log directory name is going to look. Extend the comment to show how the format of the log directory name is going to look.
![]() Keep the alias for logrus import consistent. So, refactor this to "log". Keep the alias for logrus import consistent. So, refactor this to "log".
![]() Done Done
![]() Done Done
|
||||
package elektronLogging
|
||||
|
||||
import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
![]() Why not use Why not use `string.join([]string{...}, "")` ?
![]() Yeah, thats right Yeah, thats right
![]() Extend the comment to show how the format of the log directory name is going to look. Extend the comment to show how the format of the log directory name is going to look.
![]() Keep the alias for logrus import consistent. So, refactor this to "log". Keep the alias for logrus import consistent. So, refactor this to "log".
![]() Done Done
![]() Done Done
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
![]() Why not use Why not use `string.join([]string{...}, "")` ?
![]() Yeah, thats right Yeah, thats right
![]() Extend the comment to show how the format of the log directory name is going to look. Extend the comment to show how the format of the log directory name is going to look.
![]() Keep the alias for logrus import consistent. So, refactor this to "log". Keep the alias for logrus import consistent. So, refactor this to "log".
![]() Done Done
![]() Done Done
|
||||
log "github.com/sirupsen/logrus"
|
||||
![]() Why not use Why not use `string.join([]string{...}, "")` ?
![]() Yeah, thats right Yeah, thats right
![]() Extend the comment to show how the format of the log directory name is going to look. Extend the comment to show how the format of the log directory name is going to look.
![]() Keep the alias for logrus import consistent. So, refactor this to "log". Keep the alias for logrus import consistent. So, refactor this to "log".
![]() Done Done
![]() Done Done
|
||||
)
|
||||
|
||||
type logDirectory struct {
|
||||
|
@ -19,8 +20,7 @@ func (logD *logDirectory) getDirName() string {
|
|||
![]() Why not use Why not use `string.join([]string{...}, "")` ?
![]() Yeah, thats right Yeah, thats right
![]() Extend the comment to show how the format of the log directory name is going to look. Extend the comment to show how the format of the log directory name is going to look.
![]() Keep the alias for logrus import consistent. So, refactor this to "log". Keep the alias for logrus import consistent. So, refactor this to "log".
![]() Done Done
![]() Done Done
![]() Why not use Why not use `string.join([]string{...}, "")` ?
![]() Yeah, thats right Yeah, thats right
![]() Extend the comment to show how the format of the log directory name is going to look. Extend the comment to show how the format of the log directory name is going to look.
![]() Keep the alias for logrus import consistent. So, refactor this to "log". Keep the alias for logrus import consistent. So, refactor this to "log".
![]() Done Done
![]() Done Done
|
||||
func (logD *logDirectory) createLogDir(prefix string, startTime time.Time) {
|
||||
|
||||
if logD.name == "" {
|
||||
// Creating directory to store all logs for this run
|
||||
![]() Why not use Why not use `string.join([]string{...}, "")` ?
![]() Yeah, thats right Yeah, thats right
![]() Extend the comment to show how the format of the log directory name is going to look. Extend the comment to show how the format of the log directory name is going to look.
![]() Keep the alias for logrus import consistent. So, refactor this to "log". Keep the alias for logrus import consistent. So, refactor this to "log".
![]() Done Done
![]() Done Done
|
||||
// directory name format - 2019-November-21_14-33-0
|
||||
![]() Why not use Why not use `string.join([]string{...}, "")` ?
![]() Yeah, thats right Yeah, thats right
![]() Extend the comment to show how the format of the log directory name is going to look. Extend the comment to show how the format of the log directory name is going to look.
![]() Keep the alias for logrus import consistent. So, refactor this to "log". Keep the alias for logrus import consistent. So, refactor this to "log".
![]() Done Done
![]() Done Done
|
||||
// Creating directory to store all logs for this run. Directory name format - 2019-November-21_14-33-0.
|
||||
![]() Why not use Why not use `string.join([]string{...}, "")` ?
![]() Yeah, thats right Yeah, thats right
![]() Extend the comment to show how the format of the log directory name is going to look. Extend the comment to show how the format of the log directory name is going to look.
![]() Keep the alias for logrus import consistent. So, refactor this to "log". Keep the alias for logrus import consistent. So, refactor this to "log".
![]() Done Done
![]() Done Done
|
||||
logDirName := strings.Join([]string{"./", prefix, strconv.Itoa(startTime.Year())}, "")
|
||||
logDirName = strings.Join([]string{logDirName, startTime.Month().String(), strconv.Itoa(startTime.Day())}, "-")
|
||||
logDirName = strings.Join([]string{logDirName, strconv.Itoa(startTime.Hour())}, "_")
|
||||
|
|
|||
![]() Why not use Why not use `string.join([]string{...}, "")` ?
![]() Yeah, thats right Yeah, thats right
![]() Extend the comment to show how the format of the log directory name is going to look. Extend the comment to show how the format of the log directory name is going to look.
![]() Keep the alias for logrus import consistent. So, refactor this to "log". Keep the alias for logrus import consistent. So, refactor this to "log".
![]() Done Done
![]() Done Done
![]() Why not use Why not use `string.join([]string{...}, "")` ?
![]() Yeah, thats right Yeah, thats right
![]() Extend the comment to show how the format of the log directory name is going to look. Extend the comment to show how the format of the log directory name is going to look.
![]() Keep the alias for logrus import consistent. So, refactor this to "log". Keep the alias for logrus import consistent. So, refactor this to "log".
![]() Done Done
![]() Done Done
|
|
@ -1,30 +1,32 @@
|
|||
![]() Logger and Log are synonyms and therefore should not be used interchangeably. Logger and Log are synonyms and therefore should not be used interchangeably.
![]() Comments should start with capital letters and should end with a full stop. Comments should start with capital letters and should end with a full stop.
![]() The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the `-logPrefix` flag.
![]() What is the rationale behind having a dummy node as the head of the chain? What is the rationale behind having a dummy node as the head of the chain?
![]() Done Done
![]() Nothing specific. I had kept Nothing specific. I had kept `ElektronLog` as `LoggerImpl` type. But I have changed to `ConsoleLogger` rather. Works fine now
![]() Done Done
![]() Changed Changed `ElektronLog` to `ElektronLogger`
![]() Logger and Log are synonyms and therefore should not be used interchangeably. Logger and Log are synonyms and therefore should not be used interchangeably.
![]() Comments should start with capital letters and should end with a full stop. Comments should start with capital letters and should end with a full stop.
![]() The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the `-logPrefix` flag.
![]() What is the rationale behind having a dummy node as the head of the chain? What is the rationale behind having a dummy node as the head of the chain?
![]() Done Done
![]() Nothing specific. I had kept Nothing specific. I had kept `ElektronLog` as `LoggerImpl` type. But I have changed to `ConsoleLogger` rather. Works fine now
![]() Done Done
![]() Changed Changed `ElektronLog` to `ElektronLogger`
|
||||
package elektronLogging
|
||||
|
||||
import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
![]() Logger and Log are synonyms and therefore should not be used interchangeably. Logger and Log are synonyms and therefore should not be used interchangeably.
![]() Comments should start with capital letters and should end with a full stop. Comments should start with capital letters and should end with a full stop.
![]() The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the `-logPrefix` flag.
![]() What is the rationale behind having a dummy node as the head of the chain? What is the rationale behind having a dummy node as the head of the chain?
![]() Done Done
![]() Nothing specific. I had kept Nothing specific. I had kept `ElektronLog` as `LoggerImpl` type. But I have changed to `ConsoleLogger` rather. Works fine now
![]() Done Done
![]() Changed Changed `ElektronLog` to `ElektronLogger`
|
||||
. "github.com/spdfg/elektron/elektronLogging/types"
|
||||
![]() Logger and Log are synonyms and therefore should not be used interchangeably. Logger and Log are synonyms and therefore should not be used interchangeably.
![]() Comments should start with capital letters and should end with a full stop. Comments should start with capital letters and should end with a full stop.
![]() The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the `-logPrefix` flag.
![]() What is the rationale behind having a dummy node as the head of the chain? What is the rationale behind having a dummy node as the head of the chain?
![]() Done Done
![]() Nothing specific. I had kept Nothing specific. I had kept `ElektronLog` as `LoggerImpl` type. But I have changed to `ConsoleLogger` rather. Works fine now
![]() Done Done
![]() Changed Changed `ElektronLog` to `ElektronLogger`
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
![]() Logger and Log are synonyms and therefore should not be used interchangeably. Logger and Log are synonyms and therefore should not be used interchangeably.
![]() Comments should start with capital letters and should end with a full stop. Comments should start with capital letters and should end with a full stop.
![]() The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the `-logPrefix` flag.
![]() What is the rationale behind having a dummy node as the head of the chain? What is the rationale behind having a dummy node as the head of the chain?
![]() Done Done
![]() Nothing specific. I had kept Nothing specific. I had kept `ElektronLog` as `LoggerImpl` type. But I have changed to `ConsoleLogger` rather. Works fine now
![]() Done Done
![]() Changed Changed `ElektronLog` to `ElektronLogger`
|
||||
log "github.com/sirupsen/logrus"
|
||||
![]() Logger and Log are synonyms and therefore should not be used interchangeably. Logger and Log are synonyms and therefore should not be used interchangeably.
![]() Comments should start with capital letters and should end with a full stop. Comments should start with capital letters and should end with a full stop.
![]() The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the `-logPrefix` flag.
![]() What is the rationale behind having a dummy node as the head of the chain? What is the rationale behind having a dummy node as the head of the chain?
![]() Done Done
![]() Nothing specific. I had kept Nothing specific. I had kept `ElektronLog` as `LoggerImpl` type. But I have changed to `ConsoleLogger` rather. Works fine now
![]() Done Done
![]() Changed Changed `ElektronLog` to `ElektronLogger`
|
||||
. "github.com/spdfg/elektron/elektronLogging/types"
|
||||
![]() Logger and Log are synonyms and therefore should not be used interchangeably. Logger and Log are synonyms and therefore should not be used interchangeably.
![]() Comments should start with capital letters and should end with a full stop. Comments should start with capital letters and should end with a full stop.
![]() The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the `-logPrefix` flag.
![]() What is the rationale behind having a dummy node as the head of the chain? What is the rationale behind having a dummy node as the head of the chain?
![]() Done Done
![]() Nothing specific. I had kept Nothing specific. I had kept `ElektronLog` as `LoggerImpl` type. But I have changed to `ConsoleLogger` rather. Works fine now
![]() Done Done
![]() Changed Changed `ElektronLog` to `ElektronLogger`
|
||||
)
|
||||
|
||||
var config LoggerConfig
|
||||
var logger *log.Logger
|
||||
var formatter ElektronFormatter
|
||||
var ElektronLog *ConsoleLogger
|
||||
![]() Logger and Log are synonyms and therefore should not be used interchangeably. Logger and Log are synonyms and therefore should not be used interchangeably.
![]() Comments should start with capital letters and should end with a full stop. Comments should start with capital letters and should end with a full stop.
![]() The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the `-logPrefix` flag.
![]() What is the rationale behind having a dummy node as the head of the chain? What is the rationale behind having a dummy node as the head of the chain?
![]() Done Done
![]() Nothing specific. I had kept Nothing specific. I had kept `ElektronLog` as `LoggerImpl` type. But I have changed to `ConsoleLogger` rather. Works fine now
![]() Done Done
![]() Changed Changed `ElektronLog` to `ElektronLogger`
|
||||
var ElektronLogger *ConsoleLogger
|
||||
![]() Logger and Log are synonyms and therefore should not be used interchangeably. Logger and Log are synonyms and therefore should not be used interchangeably.
![]() Comments should start with capital letters and should end with a full stop. Comments should start with capital letters and should end with a full stop.
![]() The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the `-logPrefix` flag.
![]() What is the rationale behind having a dummy node as the head of the chain? What is the rationale behind having a dummy node as the head of the chain?
![]() Done Done
![]() Nothing specific. I had kept Nothing specific. I had kept `ElektronLog` as `LoggerImpl` type. But I have changed to `ConsoleLogger` rather. Works fine now
![]() Done Done
![]() Changed Changed `ElektronLog` to `ElektronLogger`
|
||||
var logDir logDirectory
|
||||
|
||||
func BuildLogger(prefix string, logConfigFilename string) {
|
||||
|
||||
// read configuration from yaml
|
||||
![]() Logger and Log are synonyms and therefore should not be used interchangeably. Logger and Log are synonyms and therefore should not be used interchangeably.
![]() Comments should start with capital letters and should end with a full stop. Comments should start with capital letters and should end with a full stop.
![]() The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the `-logPrefix` flag.
![]() What is the rationale behind having a dummy node as the head of the chain? What is the rationale behind having a dummy node as the head of the chain?
![]() Done Done
![]() Nothing specific. I had kept Nothing specific. I had kept `ElektronLog` as `LoggerImpl` type. But I have changed to `ConsoleLogger` rather. Works fine now
![]() Done Done
![]() Changed Changed `ElektronLog` to `ElektronLogger`
|
||||
// Read configuration from yaml.
|
||||
![]() Logger and Log are synonyms and therefore should not be used interchangeably. Logger and Log are synonyms and therefore should not be used interchangeably.
![]() Comments should start with capital letters and should end with a full stop. Comments should start with capital letters and should end with a full stop.
![]() The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the `-logPrefix` flag.
![]() What is the rationale behind having a dummy node as the head of the chain? What is the rationale behind having a dummy node as the head of the chain?
![]() Done Done
![]() Nothing specific. I had kept Nothing specific. I had kept `ElektronLog` as `LoggerImpl` type. But I have changed to `ConsoleLogger` rather. Works fine now
![]() Done Done
![]() Changed Changed `ElektronLog` to `ElektronLogger`
|
||||
config.GetConfig(logConfigFilename)
|
||||
|
||||
// create the log directory
|
||||
![]() Logger and Log are synonyms and therefore should not be used interchangeably. Logger and Log are synonyms and therefore should not be used interchangeably.
![]() Comments should start with capital letters and should end with a full stop. Comments should start with capital letters and should end with a full stop.
![]() The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the `-logPrefix` flag.
![]() What is the rationale behind having a dummy node as the head of the chain? What is the rationale behind having a dummy node as the head of the chain?
![]() Done Done
![]() Nothing specific. I had kept Nothing specific. I had kept `ElektronLog` as `LoggerImpl` type. But I have changed to `ConsoleLogger` rather. Works fine now
![]() Done Done
![]() Changed Changed `ElektronLog` to `ElektronLogger`
|
||||
// Create the log directory.
|
||||
![]() Logger and Log are synonyms and therefore should not be used interchangeably. Logger and Log are synonyms and therefore should not be used interchangeably.
![]() Comments should start with capital letters and should end with a full stop. Comments should start with capital letters and should end with a full stop.
![]() The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the `-logPrefix` flag.
![]() What is the rationale behind having a dummy node as the head of the chain? What is the rationale behind having a dummy node as the head of the chain?
![]() Done Done
![]() Nothing specific. I had kept Nothing specific. I had kept `ElektronLog` as `LoggerImpl` type. But I have changed to `ConsoleLogger` rather. Works fine now
![]() Done Done
![]() Changed Changed `ElektronLog` to `ElektronLogger`
|
||||
startTime := time.Now()
|
||||
formatter.TimestampFormat = "2006-01-02 15:04:05"
|
||||
formattedStartTime := startTime.Format("20060102150405")
|
||||
|
||||
![]() Logger and Log are synonyms and therefore should not be used interchangeably. Logger and Log are synonyms and therefore should not be used interchangeably.
![]() Comments should start with capital letters and should end with a full stop. Comments should start with capital letters and should end with a full stop.
![]() The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the `-logPrefix` flag.
![]() What is the rationale behind having a dummy node as the head of the chain? What is the rationale behind having a dummy node as the head of the chain?
![]() Done Done
![]() Nothing specific. I had kept Nothing specific. I had kept `ElektronLog` as `LoggerImpl` type. But I have changed to `ConsoleLogger` rather. Works fine now
![]() Done Done
![]() Changed Changed `ElektronLog` to `ElektronLogger`
|
||||
logDir.createLogDir(prefix, startTime)
|
||||
|
||||
![]() Logger and Log are synonyms and therefore should not be used interchangeably. Logger and Log are synonyms and therefore should not be used interchangeably.
![]() Comments should start with capital letters and should end with a full stop. Comments should start with capital letters and should end with a full stop.
![]() The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the `-logPrefix` flag.
![]() What is the rationale behind having a dummy node as the head of the chain? What is the rationale behind having a dummy node as the head of the chain?
![]() Done Done
![]() Nothing specific. I had kept Nothing specific. I had kept `ElektronLog` as `LoggerImpl` type. But I have changed to `ConsoleLogger` rather. Works fine now
![]() Done Done
![]() Changed Changed `ElektronLog` to `ElektronLogger`
|
||||
// Instantiate the logrus instance.
|
||||
![]() Logger and Log are synonyms and therefore should not be used interchangeably. Logger and Log are synonyms and therefore should not be used interchangeably.
![]() Comments should start with capital letters and should end with a full stop. Comments should start with capital letters and should end with a full stop.
![]() The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the `-logPrefix` flag.
![]() What is the rationale behind having a dummy node as the head of the chain? What is the rationale behind having a dummy node as the head of the chain?
![]() Done Done
![]() Nothing specific. I had kept Nothing specific. I had kept `ElektronLog` as `LoggerImpl` type. But I have changed to `ConsoleLogger` rather. Works fine now
![]() Done Done
![]() Changed Changed `ElektronLog` to `ElektronLogger`
|
||||
prefix = strings.Join([]string{prefix, formattedStartTime}, "_")
|
||||
logger = &log.Logger{
|
||||
Out: os.Stderr,
|
||||
|
@ -32,8 +34,7 @@ func BuildLogger(prefix string, logConfigFilename string) {
|
|||
![]() Logger and Log are synonyms and therefore should not be used interchangeably. Logger and Log are synonyms and therefore should not be used interchangeably.
![]() Comments should start with capital letters and should end with a full stop. Comments should start with capital letters and should end with a full stop.
![]() The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the `-logPrefix` flag.
![]() What is the rationale behind having a dummy node as the head of the chain? What is the rationale behind having a dummy node as the head of the chain?
![]() Done Done
![]() Nothing specific. I had kept Nothing specific. I had kept `ElektronLog` as `LoggerImpl` type. But I have changed to `ConsoleLogger` rather. Works fine now
![]() Done Done
![]() Changed Changed `ElektronLog` to `ElektronLogger`
![]() Logger and Log are synonyms and therefore should not be used interchangeably. Logger and Log are synonyms and therefore should not be used interchangeably.
![]() Comments should start with capital letters and should end with a full stop. Comments should start with capital letters and should end with a full stop.
![]() The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the `-logPrefix` flag.
![]() What is the rationale behind having a dummy node as the head of the chain? What is the rationale behind having a dummy node as the head of the chain?
![]() Done Done
![]() Nothing specific. I had kept Nothing specific. I had kept `ElektronLog` as `LoggerImpl` type. But I have changed to `ConsoleLogger` rather. Works fine now
![]() Done Done
![]() Changed Changed `ElektronLog` to `ElektronLogger`
|
||||
Formatter: &formatter,
|
||||
}
|
||||
|
||||
// create a chain of loggers
|
||||
![]() Logger and Log are synonyms and therefore should not be used interchangeably. Logger and Log are synonyms and therefore should not be used interchangeably.
![]() Comments should start with capital letters and should end with a full stop. Comments should start with capital letters and should end with a full stop.
![]() The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the `-logPrefix` flag.
![]() What is the rationale behind having a dummy node as the head of the chain? What is the rationale behind having a dummy node as the head of the chain?
![]() Done Done
![]() Nothing specific. I had kept Nothing specific. I had kept `ElektronLog` as `LoggerImpl` type. But I have changed to `ConsoleLogger` rather. Works fine now
![]() Done Done
![]() Changed Changed `ElektronLog` to `ElektronLogger`
|
||||
//head := &LoggerImpl{}
|
||||
![]() Logger and Log are synonyms and therefore should not be used interchangeably. Logger and Log are synonyms and therefore should not be used interchangeably.
![]() Comments should start with capital letters and should end with a full stop. Comments should start with capital letters and should end with a full stop.
![]() The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the `-logPrefix` flag.
![]() What is the rationale behind having a dummy node as the head of the chain? What is the rationale behind having a dummy node as the head of the chain?
![]() Done Done
![]() Nothing specific. I had kept Nothing specific. I had kept `ElektronLog` as `LoggerImpl` type. But I have changed to `ConsoleLogger` rather. Works fine now
![]() Done Done
![]() Changed Changed `ElektronLog` to `ElektronLogger`
|
||||
// Create a chain of loggers.
|
||||
![]() Logger and Log are synonyms and therefore should not be used interchangeably. Logger and Log are synonyms and therefore should not be used interchangeably.
![]() Comments should start with capital letters and should end with a full stop. Comments should start with capital letters and should end with a full stop.
![]() The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the `-logPrefix` flag.
![]() What is the rationale behind having a dummy node as the head of the chain? What is the rationale behind having a dummy node as the head of the chain?
![]() Done Done
![]() Nothing specific. I had kept Nothing specific. I had kept `ElektronLog` as `LoggerImpl` type. But I have changed to `ConsoleLogger` rather. Works fine now
![]() Done Done
![]() Changed Changed `ElektronLog` to `ElektronLogger`
|
||||
cLog := NewConsoleLogger(CONSOLE, prefix)
|
||||
pLog := NewPCPLogger(PCP, prefix)
|
||||
schedTraceLog := NewSchedTraceLogger(SCHED_TRACE, prefix)
|
||||
|
@ -41,12 +42,11 @@ func BuildLogger(prefix string, logConfigFilename string) {
|
|||
![]() Logger and Log are synonyms and therefore should not be used interchangeably. Logger and Log are synonyms and therefore should not be used interchangeably.
![]() Comments should start with capital letters and should end with a full stop. Comments should start with capital letters and should end with a full stop.
![]() The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the `-logPrefix` flag.
![]() What is the rationale behind having a dummy node as the head of the chain? What is the rationale behind having a dummy node as the head of the chain?
![]() Done Done
![]() Nothing specific. I had kept Nothing specific. I had kept `ElektronLog` as `LoggerImpl` type. But I have changed to `ConsoleLogger` rather. Works fine now
![]() Done Done
![]() Changed Changed `ElektronLog` to `ElektronLogger`
![]() Logger and Log are synonyms and therefore should not be used interchangeably. Logger and Log are synonyms and therefore should not be used interchangeably.
![]() Comments should start with capital letters and should end with a full stop. Comments should start with capital letters and should end with a full stop.
![]() The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the `-logPrefix` flag.
![]() What is the rationale behind having a dummy node as the head of the chain? What is the rationale behind having a dummy node as the head of the chain?
![]() Done Done
![]() Nothing specific. I had kept Nothing specific. I had kept `ElektronLog` as `LoggerImpl` type. But I have changed to `ConsoleLogger` rather. Works fine now
![]() Done Done
![]() Changed Changed `ElektronLog` to `ElektronLogger`
|
||||
schedWindowLog := NewSchedWindowLogger(SCHED_WINDOW, prefix)
|
||||
tskDistLog := NewClsfnTaskDistrOverheadLogger(CLSFN_TASKDIST_OVERHEAD, prefix)
|
||||
|
||||
//head.SetNext(cLog)
|
||||
![]() Logger and Log are synonyms and therefore should not be used interchangeably. Logger and Log are synonyms and therefore should not be used interchangeably.
![]() Comments should start with capital letters and should end with a full stop. Comments should start with capital letters and should end with a full stop.
![]() The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the `-logPrefix` flag.
![]() What is the rationale behind having a dummy node as the head of the chain? What is the rationale behind having a dummy node as the head of the chain?
![]() Done Done
![]() Nothing specific. I had kept Nothing specific. I had kept `ElektronLog` as `LoggerImpl` type. But I have changed to `ConsoleLogger` rather. Works fine now
![]() Done Done
![]() Changed Changed `ElektronLog` to `ElektronLogger`
|
||||
cLog.SetNext(pLog)
|
||||
pLog.SetNext(schedTraceLog)
|
||||
schedTraceLog.SetNext(spsLog)
|
||||
spsLog.SetNext(schedWindowLog)
|
||||
schedWindowLog.SetNext(tskDistLog)
|
||||
|
||||
ElektronLog = cLog
|
||||
![]() Logger and Log are synonyms and therefore should not be used interchangeably. Logger and Log are synonyms and therefore should not be used interchangeably.
![]() Comments should start with capital letters and should end with a full stop. Comments should start with capital letters and should end with a full stop.
![]() The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the `-logPrefix` flag.
![]() What is the rationale behind having a dummy node as the head of the chain? What is the rationale behind having a dummy node as the head of the chain?
![]() Done Done
![]() Nothing specific. I had kept Nothing specific. I had kept `ElektronLog` as `LoggerImpl` type. But I have changed to `ConsoleLogger` rather. Works fine now
![]() Done Done
![]() Changed Changed `ElektronLog` to `ElektronLogger`
|
||||
ElektronLogger = cLog
|
||||
![]() Logger and Log are synonyms and therefore should not be used interchangeably. Logger and Log are synonyms and therefore should not be used interchangeably.
![]() Comments should start with capital letters and should end with a full stop. Comments should start with capital letters and should end with a full stop.
![]() The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the `-logPrefix` flag.
![]() What is the rationale behind having a dummy node as the head of the chain? What is the rationale behind having a dummy node as the head of the chain?
![]() Done Done
![]() Nothing specific. I had kept Nothing specific. I had kept `ElektronLog` as `LoggerImpl` type. But I have changed to `ConsoleLogger` rather. Works fine now
![]() Done Done
![]() Changed Changed `ElektronLog` to `ElektronLogger`
|
||||
}
|
||||
|
|
|||
![]() Logger and Log are synonyms and therefore should not be used interchangeably. Logger and Log are synonyms and therefore should not be used interchangeably.
![]() Comments should start with capital letters and should end with a full stop. Comments should start with capital letters and should end with a full stop.
![]() The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the `-logPrefix` flag.
![]() What is the rationale behind having a dummy node as the head of the chain? What is the rationale behind having a dummy node as the head of the chain?
![]() Done Done
![]() Nothing specific. I had kept Nothing specific. I had kept `ElektronLog` as `LoggerImpl` type. But I have changed to `ConsoleLogger` rather. Works fine now
![]() Done Done
![]() Changed Changed `ElektronLog` to `ElektronLogger`
![]() Logger and Log are synonyms and therefore should not be used interchangeably. Logger and Log are synonyms and therefore should not be used interchangeably.
![]() Comments should start with capital letters and should end with a full stop. Comments should start with capital letters and should end with a full stop.
![]() The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the The second argument to GetLogDir() is a prefix. How is "_" a prefix? This is probably why the log directory name is not ending up prefixed with the one specified with the `-logPrefix` flag.
![]() What is the rationale behind having a dummy node as the head of the chain? What is the rationale behind having a dummy node as the head of the chain?
![]() Done Done
![]() Nothing specific. I had kept Nothing specific. I had kept `ElektronLog` as `LoggerImpl` type. But I have changed to `ConsoleLogger` rather. Works fine now
![]() Done Done
![]() Changed Changed `ElektronLog` to `ElektronLogger`
|
|
@ -1,10 +1,11 @@
|
|||
![]() Refactor to Refactor to `PCPLogger`.
![]() Why not just do this?
Where Why not just do this?
```go
return &PCPLogger{
LoggerIml{
Type: logType
LogFile: CreateLogFile(prefix),
}
}
```
Where `func CreateLogFile(prefix string) string` replaces `func SetLogFile(prefix string)`.
![]() Done Done
![]() Refactor to Refactor to `PCPLogger`.
![]() Why not just do this?
Where Why not just do this?
```go
return &PCPLogger{
LoggerIml{
Type: logType
LogFile: CreateLogFile(prefix),
}
}
```
Where `func CreateLogFile(prefix string) string` replaces `func SetLogFile(prefix string)`.
![]() Done Done
|
||||
package elektronLogging
|
||||
|
||||
import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
![]() Refactor to Refactor to `PCPLogger`.
![]() Why not just do this?
Where Why not just do this?
```go
return &PCPLogger{
LoggerIml{
Type: logType
LogFile: CreateLogFile(prefix),
}
}
```
Where `func CreateLogFile(prefix string) string` replaces `func SetLogFile(prefix string)`.
![]() Done Done
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
![]() Refactor to Refactor to `PCPLogger`.
![]() Why not just do this?
Where Why not just do this?
```go
return &PCPLogger{
LoggerIml{
Type: logType
LogFile: CreateLogFile(prefix),
}
}
```
Where `func CreateLogFile(prefix string) string` replaces `func SetLogFile(prefix string)`.
![]() Done Done
|
||||
log "github.com/sirupsen/logrus"
|
||||
![]() Refactor to Refactor to `PCPLogger`.
![]() Why not just do this?
Where Why not just do this?
```go
return &PCPLogger{
LoggerIml{
Type: logType
LogFile: CreateLogFile(prefix),
}
}
```
Where `func CreateLogFile(prefix string) string` replaces `func SetLogFile(prefix string)`.
![]() Done Done
|
||||
)
|
||||
|
||||
type PCPLogger struct {
|
||||
|
|
|||
![]() Refactor to Refactor to `PCPLogger`.
![]() Why not just do this?
Where Why not just do this?
```go
return &PCPLogger{
LoggerIml{
Type: logType
LogFile: CreateLogFile(prefix),
}
}
```
Where `func CreateLogFile(prefix string) string` replaces `func SetLogFile(prefix string)`.
![]() Done Done
![]() Refactor to Refactor to `PCPLogger`.
![]() Why not just do this?
Where Why not just do this?
```go
return &PCPLogger{
LoggerIml{
Type: logType
LogFile: CreateLogFile(prefix),
}
}
```
Where `func CreateLogFile(prefix string) string` replaces `func SetLogFile(prefix string)`.
![]() Done Done
|
|
@ -1,10 +1,11 @@
|
|||
package elektronLogging
|
||||
|
||||
import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
type SchedPolicySwitchLogger struct {
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
package elektronLogging
|
||||
|
||||
import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
type SchedTraceLogger struct {
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
package elektronLogging
|
||||
|
||||
import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
type SchedWindowLogger struct {
|
||||
|
|
|
@ -47,7 +47,7 @@ func Start(quit chan struct{}, logging *bool, pcpConfigFile string) {
|
|||
scanner.Scan()
|
||||
|
||||
// Write to logfile
|
||||
elekLog.ElektronLog.Log(elekLogTypes.PCP,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.PCP,
|
||||
log.InfoLevel,
|
||||
log.Fields{}, scanner.Text())
|
||||
|
||||
|
@ -60,7 +60,7 @@ func Start(quit chan struct{}, logging *bool, pcpConfigFile string) {
|
|||
text := scanner.Text()
|
||||
|
||||
if *logging {
|
||||
elekLog.ElektronLog.Log(elekLogTypes.PCP,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.PCP,
|
||||
log.InfoLevel,
|
||||
log.Fields{}, text)
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ func Start(quit chan struct{}, logging *bool, pcpConfigFile string) {
|
|||
}
|
||||
}(logging)
|
||||
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
log.InfoLevel,
|
||||
log.Fields{}, "PCP logging started")
|
||||
|
||||
|
@ -81,7 +81,7 @@ func Start(quit chan struct{}, logging *bool, pcpConfigFile string) {
|
|||
|
||||
select {
|
||||
case <-quit:
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
log.InfoLevel,
|
||||
log.Fields{}, "Stopping PCP logging in 5 seconds")
|
||||
time.Sleep(5 * time.Second)
|
||||
|
|
|
@ -43,7 +43,7 @@ func StartPCPLogAndExtremaDynamicCap(quit chan struct{}, logging *bool, hiThresh
|
|||
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
|
||||
|
||||
if hiThreshold < loThreshold {
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
log.InfoLevel,
|
||||
log.Fields{}, "High threshold is lower than low threshold!")
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ func StartPCPLogAndExtremaDynamicCap(quit chan struct{}, logging *bool, hiThresh
|
|||
scanner.Scan()
|
||||
|
||||
// Write to logfile
|
||||
elekLog.ElektronLog.Log(elekLogTypes.PCP,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.PCP,
|
||||
log.InfoLevel,
|
||||
log.Fields{}, scanner.Text())
|
||||
|
||||
|
@ -99,14 +99,14 @@ func StartPCPLogAndExtremaDynamicCap(quit chan struct{}, logging *bool, hiThresh
|
|||
|
||||
if *logging {
|
||||
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
log.InfoLevel,
|
||||
log.Fields{}, "Logging PCP...")
|
||||
|
||||
text := scanner.Text()
|
||||
split := strings.Split(text, ",")
|
||||
|
||||
elekLog.ElektronLog.Log(elekLogTypes.PCP,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.PCP,
|
||||
log.InfoLevel,
|
||||
log.Fields{}, text)
|
||||
|
||||
|
@ -119,7 +119,7 @@ func StartPCPLogAndExtremaDynamicCap(quit chan struct{}, logging *bool, hiThresh
|
|||
powerHistories[host].Value = power
|
||||
powerHistories[host] = powerHistories[host].Next()
|
||||
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
log.InfoLevel,
|
||||
log.Fields{"Host": fmt.Sprintf("%s", indexToHost[powerIndex]), "Power": fmt.Sprintf("%f", (power * pcp.RAPLUnits))},
|
||||
"")
|
||||
|
@ -133,14 +133,14 @@ func StartPCPLogAndExtremaDynamicCap(quit chan struct{}, logging *bool, hiThresh
|
|||
|
||||
clusterMean := pcp.AverageClusterPowerHistory(clusterPowerHist)
|
||||
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
log.InfoLevel,
|
||||
log.Fields{"Total power": fmt.Sprintf("%f %d", clusterPower, clusterPowerHist.Len()),
|
||||
"Sec Avg": fmt.Sprintf("%f", clusterMean)},
|
||||
"")
|
||||
|
||||
if clusterMean > hiThreshold {
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
log.InfoLevel,
|
||||
log.Fields{}, "Need to cap a node")
|
||||
// Create statics for all victims and choose one to cap
|
||||
|
@ -163,12 +163,12 @@ func StartPCPLogAndExtremaDynamicCap(quit chan struct{}, logging *bool, hiThresh
|
|||
if !cappedHosts[victim.Host] {
|
||||
cappedHosts[victim.Host] = true
|
||||
orderCapped = append(orderCapped, victim.Host)
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
log.InfoLevel,
|
||||
log.Fields{"Capping Victim": fmt.Sprintf("%s", victim.Host),
|
||||
"Avg. Wattage": fmt.Sprintf("%f", victim.Watts*pcp.RAPLUnits)}, "")
|
||||
if err := rapl.Cap(victim.Host, "rapl", 50); err != nil {
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
log.ErrorLevel,
|
||||
log.Fields{}, "Error capping host")
|
||||
}
|
||||
|
@ -184,11 +184,11 @@ func StartPCPLogAndExtremaDynamicCap(quit chan struct{}, logging *bool, hiThresh
|
|||
cappedHosts[host] = false
|
||||
// User RAPL package to send uncap.
|
||||
log.Printf("Uncapping host %s", host)
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
log.InfoLevel,
|
||||
log.Fields{"Uncapped host": host}, "")
|
||||
if err := rapl.Cap(host, "rapl", 100); err != nil {
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
log.ErrorLevel,
|
||||
log.Fields{}, "Error capping host")
|
||||
}
|
||||
|
@ -200,7 +200,7 @@ func StartPCPLogAndExtremaDynamicCap(quit chan struct{}, logging *bool, hiThresh
|
|||
}
|
||||
}(logging, hiThreshold, loThreshold)
|
||||
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
log.InfoLevel,
|
||||
log.Fields{}, "PCP logging started")
|
||||
|
||||
|
@ -212,7 +212,7 @@ func StartPCPLogAndExtremaDynamicCap(quit chan struct{}, logging *bool, hiThresh
|
|||
|
||||
select {
|
||||
case <-quit:
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
log.InfoLevel,
|
||||
log.Fields{}, "Stopping PCP logging in 5 seconds")
|
||||
time.Sleep(5 * time.Second)
|
||||
|
|
|
@ -56,7 +56,7 @@ func StartPCPLogAndProgressiveExtremaCap(quit chan struct{}, logging *bool, hiTh
|
|||
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
|
||||
|
||||
if hiThreshold < loThreshold {
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
log.InfoLevel,
|
||||
log.Fields{}, "High threshold is lower than low threshold!")
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ func StartPCPLogAndProgressiveExtremaCap(quit chan struct{}, logging *bool, hiTh
|
|||
scanner.Scan()
|
||||
|
||||
// Write to logfile
|
||||
elekLog.ElektronLog.Log(elekLogTypes.PCP,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.PCP,
|
||||
log.InfoLevel,
|
||||
log.Fields{}, scanner.Text())
|
||||
|
||||
|
@ -115,13 +115,13 @@ func StartPCPLogAndProgressiveExtremaCap(quit chan struct{}, logging *bool, hiTh
|
|||
|
||||
for scanner.Scan() {
|
||||
if *logging {
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
log.InfoLevel,
|
||||
log.Fields{}, "Logging PCP...")
|
||||
split := strings.Split(scanner.Text(), ",")
|
||||
|
||||
text := scanner.Text()
|
||||
elekLog.ElektronLog.Log(elekLogTypes.PCP,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.PCP,
|
||||
log.InfoLevel,
|
||||
log.Fields{}, text)
|
||||
|
||||
|
@ -134,7 +134,7 @@ func StartPCPLogAndProgressiveExtremaCap(quit chan struct{}, logging *bool, hiTh
|
|||
powerHistories[host].Value = power
|
||||
powerHistories[host] = powerHistories[host].Next()
|
||||
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
log.InfoLevel,
|
||||
log.Fields{"Host": fmt.Sprintf("%s", indexToHost[powerIndex]), "Power": fmt.Sprintf("%f", (power * pcp.RAPLUnits))},
|
||||
"")
|
||||
|
@ -147,22 +147,22 @@ func StartPCPLogAndProgressiveExtremaCap(quit chan struct{}, logging *bool, hiTh
|
|||
|
||||
clusterMean := pcp.AverageClusterPowerHistory(clusterPowerHist)
|
||||
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
log.InfoLevel,
|
||||
log.Fields{"Total power": fmt.Sprintf("%f %d", clusterPower, clusterPowerHist.Len()),
|
||||
"Sec Avg": fmt.Sprintf("%f", clusterMean)},
|
||||
"")
|
||||
|
||||
if clusterMean >= hiThreshold {
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
log.InfoLevel,
|
||||
log.Fields{}, "Need to cap a node")
|
||||
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
log.InfoLevel,
|
||||
log.Fields{"Cap values of capped victims": fmt.Sprintf("%v", cappedVictims)}, "")
|
||||
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
log.InfoLevel,
|
||||
log.Fields{"Cap values of victims to uncap": fmt.Sprintf("%v", orderCappedVictims)}, "")
|
||||
// Create statics for all victims and choose one to cap
|
||||
|
@ -192,12 +192,12 @@ func StartPCPLogAndProgressiveExtremaCap(quit chan struct{}, logging *bool, hiTh
|
|||
// Need to cap this victim.
|
||||
if err := rapl.Cap(victims[i].Host, "rapl", 50.0); err != nil {
|
||||
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
log.ErrorLevel,
|
||||
log.Fields{"Error capping host": fmt.Sprintf("%s", victims[i].Host)}, "")
|
||||
} else {
|
||||
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
log.InfoLevel,
|
||||
log.Fields{}, fmt.Sprintf("Capped host[%s] at %f", victims[i].Host, 50.0))
|
||||
// Keeping track of this victim and it's cap value
|
||||
|
@ -223,12 +223,12 @@ func StartPCPLogAndProgressiveExtremaCap(quit chan struct{}, logging *bool, hiTh
|
|||
newCapValue := getNextCapValue(capValue, 2)
|
||||
if err := rapl.Cap(alreadyCappedHosts[i], "rapl", newCapValue); err != nil {
|
||||
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
log.ErrorLevel,
|
||||
log.Fields{"Error capping host": fmt.Sprintf("%s", alreadyCappedHosts[i])}, "")
|
||||
} else {
|
||||
// Successful cap
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
log.InfoLevel,
|
||||
log.Fields{}, fmt.Sprintf("Capped host[%s] at %f", alreadyCappedHosts[i], newCapValue))
|
||||
// Checking whether this victim can be capped further
|
||||
|
@ -253,7 +253,7 @@ func StartPCPLogAndProgressiveExtremaCap(quit chan struct{}, logging *bool, hiTh
|
|||
}
|
||||
}
|
||||
if !canCapAlreadyCappedVictim {
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
log.InfoLevel,
|
||||
log.Fields{}, "No Victim left to cap")
|
||||
}
|
||||
|
@ -261,13 +261,13 @@ func StartPCPLogAndProgressiveExtremaCap(quit chan struct{}, logging *bool, hiTh
|
|||
|
||||
} else if clusterMean < loThreshold {
|
||||
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
log.InfoLevel,
|
||||
log.Fields{}, "Need to uncap a node")
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
log.InfoLevel,
|
||||
log.Fields{"Cap values of capped victims": fmt.Sprintf("%v", cappedVictims)}, "")
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
log.InfoLevel,
|
||||
log.Fields{"Cap values of victims to uncap": fmt.Sprintf("%v", orderCappedVictims)}, "")
|
||||
if len(orderCapped) > 0 {
|
||||
|
@ -280,12 +280,12 @@ func StartPCPLogAndProgressiveExtremaCap(quit chan struct{}, logging *bool, hiTh
|
|||
newUncapValue := orderCappedVictims[hostToUncap] * 2.0
|
||||
if err := rapl.Cap(hostToUncap, "rapl", newUncapValue); err != nil {
|
||||
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
log.ErrorLevel,
|
||||
log.Fields{"Error uncapping host": fmt.Sprintf("%s", hostToUncap)}, "")
|
||||
} else {
|
||||
// Successful uncap
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
log.InfoLevel,
|
||||
log.Fields{}, fmt.Sprintf("Uncapped host[%s] to %f", hostToUncap, newUncapValue))
|
||||
// Can we uncap this host further. If not, then we remove its entry from orderCapped
|
||||
|
@ -308,7 +308,7 @@ func StartPCPLogAndProgressiveExtremaCap(quit chan struct{}, logging *bool, hiTh
|
|||
}
|
||||
}
|
||||
} else {
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
log.InfoLevel,
|
||||
log.Fields{}, "No host staged for Uncapped")
|
||||
}
|
||||
|
@ -319,7 +319,7 @@ func StartPCPLogAndProgressiveExtremaCap(quit chan struct{}, logging *bool, hiTh
|
|||
|
||||
}(logging, hiThreshold, loThreshold)
|
||||
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
log.InfoLevel,
|
||||
log.Fields{}, "PCP logging started")
|
||||
if err := cmd.Start(); err != nil {
|
||||
|
@ -330,7 +330,7 @@ func StartPCPLogAndProgressiveExtremaCap(quit chan struct{}, logging *bool, hiTh
|
|||
|
||||
select {
|
||||
case <-quit:
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
log.InfoLevel,
|
||||
log.Fields{}, "Stopping PCP logging in 5 seconds")
|
||||
time.Sleep(5 * time.Second)
|
||||
|
|
|
@ -21,11 +21,11 @@ package rapl
|
|||
import (
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
elekEnv "github.com/spdfg/elektron/environment"
|
||||
"golang.org/x/crypto/ssh"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func Cap(host, username string, percentage float64) error {
|
||||
|
|
14
scheduler.go
|
@ -21,6 +21,11 @@ package main // import github.com/spdfg/elektron
|
|||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/golang/protobuf/proto"
|
||||
mesos "github.com/mesos/mesos-go/api/v0/mesosproto"
|
||||
sched "github.com/mesos/mesos-go/api/v0/scheduler"
|
||||
|
@ -31,10 +36,6 @@ import (
|
|||
"github.com/spdfg/elektron/pcp"
|
||||
"github.com/spdfg/elektron/powerCap"
|
||||
"github.com/spdfg/elektron/schedulers"
|
||||
"os"
|
||||
"os/signal"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
var master = flag.String("master", "", "Location of leading Mesos master -- <mesos-master>:<port>")
|
||||
|
@ -225,6 +226,7 @@ func main() {
|
|||
if strings.Contains(*pcplogPrefix, "/") {
|
||||
log.Fatal("log file prefix should not contain '/'.")
|
||||
}
|
||||
// Build Logger for elektron.
|
||||
elekLog.BuildLogger(*pcplogPrefix, *logConfigFilename)
|
||||
|
||||
// Starting PCP logging.
|
||||
|
@ -280,11 +282,11 @@ func main() {
|
|||
|
||||
// Starting the scheduler driver.
|
||||
if status, err := driver.Run(); err != nil {
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
log.ErrorLevel,
|
||||
log.Fields{"status": status.String(), "error": err.Error()}, "Framework stopped ")
|
||||
}
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
log.InfoLevel,
|
||||
log.Fields{}, "Exiting...")
|
||||
}
|
||||
|
|
|
@ -19,10 +19,9 @@
|
|||
package schedulers
|
||||
|
||||
import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
mesos "github.com/mesos/mesos-go/api/v0/mesosproto"
|
||||
sched "github.com/mesos/mesos-go/api/v0/scheduler"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/spdfg/elektron/def"
|
||||
"github.com/spdfg/elektron/utilities/mesosUtils"
|
||||
"github.com/spdfg/elektron/utilities/offerUtils"
|
||||
|
|
|
@ -19,10 +19,9 @@
|
|||
package schedulers
|
||||
|
||||
import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
mesos "github.com/mesos/mesos-go/api/v0/mesosproto"
|
||||
sched "github.com/mesos/mesos-go/api/v0/scheduler"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/spdfg/elektron/def"
|
||||
"github.com/spdfg/elektron/utilities/mesosUtils"
|
||||
"github.com/spdfg/elektron/utilities/offerUtils"
|
||||
|
|
|
@ -250,10 +250,10 @@ func (s *BaseScheduler) StatusUpdate(driver sched.SchedulerDriver, status *mesos
|
|||
|
||||
func (s *BaseScheduler) LogTaskStarting(ts *def.Task, offer *mesos.Offer) {
|
||||
if ts == nil {
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE, log.InfoLevel,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE, log.InfoLevel,
|
||||
log.Fields{"host": fmt.Sprintf("%s", offer.GetHostname())}, "TASKS STARTING...")
|
||||
} else {
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
log.InfoLevel,
|
||||
log.Fields{"task": fmt.Sprintf("%s", ts.Name),
|
||||
"Instance": fmt.Sprintf("%d", *ts.Instances), "host": fmt.Sprintf("%s", offer.GetHostname())},
|
||||
|
@ -262,25 +262,25 @@ func (s *BaseScheduler) LogTaskStarting(ts *def.Task, offer *mesos.Offer) {
|
|||
}
|
||||
|
||||
func (s *BaseScheduler) LogTaskWattsConsideration(ts def.Task, host string, wattsToConsider float64) {
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
log.InfoLevel,
|
||||
log.Fields{"task": ts.Name, "host": host, "Watts": fmt.Sprintf("%f", wattsToConsider)}, "Watts considered for ")
|
||||
}
|
||||
|
||||
func (s *BaseScheduler) LogOffersReceived(offers []*mesos.Offer) {
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
log.InfoLevel,
|
||||
log.Fields{"Resource offers received": fmt.Sprintf("%d", len(offers))}, "")
|
||||
}
|
||||
|
||||
func (s *BaseScheduler) LogNoPendingTasksDeclineOffers(offer *mesos.Offer) {
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
log.WarnLevel,
|
||||
log.Fields{"DECLINING OFFER for host": fmt.Sprintf("%s", offer.GetHostname())}, "No tasks left to schedule ")
|
||||
}
|
||||
|
||||
func (s *BaseScheduler) LogNumberOfRunningTasks() {
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
log.InfoLevel,
|
||||
log.Fields{"Number of tasks still Running": fmt.Sprintf("%d", s.tasksRunning)}, "")
|
||||
}
|
||||
|
@ -292,81 +292,81 @@ func (s *BaseScheduler) LogCoLocatedTasks(slaveID string) {
|
|||
buffer.WriteString(fmt.Sprintln(taskName))
|
||||
}
|
||||
s.TasksRunningMutex.Unlock()
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
log.InfoLevel,
|
||||
log.Fields{"Colocated with": fmt.Sprintf("%s", buffer.String())}, "")
|
||||
}
|
||||
|
||||
func (s *BaseScheduler) LogSchedTrace(taskToSchedule *mesos.TaskInfo, offer *mesos.Offer) {
|
||||
elekLog.ElektronLog.Log(elekLogTypes.SCHED_TRACE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.SCHED_TRACE,
|
||||
log.InfoLevel,
|
||||
log.Fields{offer.GetHostname(): fmt.Sprintf("%s", taskToSchedule.GetTaskId().GetValue())}, "")
|
||||
}
|
||||
|
||||
func (s *BaseScheduler) LogTerminateScheduler() {
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE, log.InfoLevel, log.Fields{}, "Done scheduling all tasks!")
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE, log.InfoLevel, log.Fields{}, "Done scheduling all tasks!")
|
||||
}
|
||||
|
||||
func (s *BaseScheduler) LogInsufficientResourcesDeclineOffer(offer *mesos.Offer,
|
||||
offerResources ...interface{}) {
|
||||
buffer := bytes.Buffer{}
|
||||
buffer.WriteString(fmt.Sprintf("<CPU: %f, RAM: %f, Watts: %f>", offerResources...))
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
log.WarnLevel,
|
||||
log.Fields{"Offer Resources": fmt.Sprintf("%s", buffer.String())}, "DECLINING OFFER... Offer has insufficient resources to launch a task")
|
||||
}
|
||||
|
||||
func (s *BaseScheduler) LogOfferRescinded(offerID *mesos.OfferID) {
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
log.ErrorLevel,
|
||||
log.Fields{"OfferID": fmt.Sprintf("%s", offerID)}, "OFFER RESCINDED")
|
||||
}
|
||||
|
||||
func (s *BaseScheduler) LogSlaveLost(slaveID *mesos.SlaveID) {
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
log.ErrorLevel,
|
||||
log.Fields{"SlaveID": fmt.Sprintf("%s", slaveID)}, "SLAVE LOST")
|
||||
}
|
||||
|
||||
func (s *BaseScheduler) LogExecutorLost(executorID *mesos.ExecutorID, slaveID *mesos.SlaveID) {
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
log.ErrorLevel,
|
||||
log.Fields{"ExecutorID": fmt.Sprintf("%s", executorID), "SlaveID": fmt.Sprintf("%s", slaveID)}, "EXECUTOR LOST")
|
||||
}
|
||||
|
||||
func (s *BaseScheduler) LogFrameworkMessage(executorID *mesos.ExecutorID,
|
||||
slaveID *mesos.SlaveID, message string) {
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
log.InfoLevel,
|
||||
log.Fields{"Received Framework message from executor": executorID}, message)
|
||||
}
|
||||
|
||||
func (s *BaseScheduler) LogMesosError(err string) {
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
log.ErrorLevel,
|
||||
log.Fields{"MESOS CONSOLE": fmt.Sprintf("%v", err)}, "")
|
||||
}
|
||||
|
||||
func (s *BaseScheduler) LogElectronError(err error) {
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
log.ErrorLevel, log.Fields{"ELECTRON CONSOLE": fmt.Sprintf("%v", err)}, "")
|
||||
}
|
||||
|
||||
func (s *BaseScheduler) LogFrameworkRegistered(frameworkID *mesos.FrameworkID,
|
||||
masterInfo *mesos.MasterInfo) {
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
log.InfoLevel,
|
||||
log.Fields{"frameworkID": fmt.Sprintf("%s", frameworkID), "master": fmt.Sprintf("%v", masterInfo)}, "FRAMEWORK REGISTERED!")
|
||||
}
|
||||
|
||||
func (s *BaseScheduler) LogFrameworkReregistered(masterInfo *mesos.MasterInfo) {
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
log.InfoLevel,
|
||||
log.Fields{"master": fmt.Sprintf("%v", masterInfo)}, "Framework re-registered")
|
||||
}
|
||||
|
||||
func (s *BaseScheduler) LogDisconnected() {
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE, log.WarnLevel, log.Fields{}, "Framework disconnected with master")
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE, log.WarnLevel, log.Fields{}, "Framework disconnected with master")
|
||||
}
|
||||
|
||||
func (s *BaseScheduler) LogTaskStatusUpdate(status *mesos.TaskStatus) {
|
||||
|
@ -378,13 +378,13 @@ func (s *BaseScheduler) LogTaskStatusUpdate(status *mesos.TaskStatus) {
|
|||
default:
|
||||
level = log.InfoLevel
|
||||
}
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
level, log.Fields{"task": fmt.Sprintf("%s", *status.TaskId.Value), "state": NameFor(status.State)}, "Task Status received")
|
||||
}
|
||||
|
||||
func (s *BaseScheduler) LogSchedPolicySwitch(name string, nextPolicy SchedPolicyState) {
|
||||
logSPS := func() {
|
||||
elekLog.ElektronLog.Log(elekLogTypes.SPS, log.InfoLevel, log.Fields{"Name": name}, "")
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.SPS, log.InfoLevel, log.Fields{"Name": name}, "")
|
||||
}
|
||||
if s.hasReceivedResourceOffers && (s.curSchedPolicy != nextPolicy) {
|
||||
logSPS()
|
||||
|
@ -393,14 +393,14 @@ func (s *BaseScheduler) LogSchedPolicySwitch(name string, nextPolicy SchedPolicy
|
|||
}
|
||||
// Logging the size of the scheduling window and the scheduling policy
|
||||
// that is going to schedule the tasks in the scheduling window.
|
||||
elekLog.ElektronLog.Log(elekLogTypes.SCHED_WINDOW,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.SCHED_WINDOW,
|
||||
log.InfoLevel,
|
||||
log.Fields{"Window size": fmt.Sprintf("%d", s.schedWindowSize), "Name": name}, "")
|
||||
}
|
||||
|
||||
func (s *BaseScheduler) LogClsfnAndTaskDistOverhead(overhead time.Duration) {
|
||||
// Logging the overhead in microseconds.
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CLSFN_TASKDIST_OVERHEAD,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CLSFN_TASKDIST_OVERHEAD,
|
||||
log.InfoLevel,
|
||||
log.Fields{"Overhead in microseconds": fmt.Sprintf("%f", float64(overhead.Nanoseconds())/1000.0)}, "")
|
||||
}
|
||||
|
|
|
@ -19,10 +19,9 @@
|
|||
package schedulers
|
||||
|
||||
import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
mesos "github.com/mesos/mesos-go/api/v0/mesosproto"
|
||||
sched "github.com/mesos/mesos-go/api/v0/scheduler"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/spdfg/elektron/def"
|
||||
"github.com/spdfg/elektron/utilities/mesosUtils"
|
||||
"github.com/spdfg/elektron/utilities/offerUtils"
|
||||
|
|
|
@ -20,6 +20,7 @@ package schedulers
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
![]() Here,
Here, `task` would be the index.
```go
for _, task := range tasks {
// rest of the code.
}
```
![]() Okay Okay
|
||||
|
||||
mesos "github.com/mesos/mesos-go/api/v0/mesosproto"
|
||||
sched "github.com/mesos/mesos-go/api/v0/scheduler"
|
||||
"github.com/pkg/errors"
|
||||
|
@ -35,10 +36,10 @@ import (
|
|||
func coLocated(tasks map[string]bool, s BaseScheduler) {
|
||||
|
||||
for _, task := range tasks {
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE, log.InfoLevel, log.Fields{"Task": task}, "")
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE, log.InfoLevel, log.Fields{"Task": task}, "")
|
||||
}
|
||||
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE, log.InfoLevel, log.Fields{}, "---------------------")
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE, log.InfoLevel, log.Fields{}, "---------------------")
|
||||
}
|
||||
|
||||
// Get the powerClass of the given hostname.
|
||||
|
|
|
@ -90,7 +90,7 @@ func switchTaskDistBased(baseSchedRef *BaseScheduler) string {
|
|||
// Determine the distribution of tasks in the new scheduling window.
|
||||
taskDist, err := def.GetTaskDistributionInWindow(baseSchedRef.schedWindowSize, baseSchedRef.tasks)
|
||||
baseSchedRef.LogClsfnAndTaskDistOverhead(time.Now().Sub(startTime))
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE,
|
||||
log.InfoLevel,
|
||||
log.Fields{"Task Distribution": fmt.Sprintf("%f", taskDist)}, "Switching... ")
|
||||
if err != nil {
|
||||
|
|
|
@ -90,13 +90,13 @@ 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 {
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE, log.InfoLevel,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE, log.InfoLevel,
|
||||
log.Fields{"Adding host": host}, "New host detected")
|
||||
// Add this host.
|
||||
constants.Hosts[host] = struct{}{}
|
||||
// Get the power class of this host.
|
||||
class := PowerClass(offer)
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE, log.InfoLevel,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE, log.InfoLevel,
|
||||
log.Fields{"host": host, "PowerClass": class}, "Registering the power class...")
|
||||
// If new power class, register the power class.
|
||||
if _, ok := constants.PowerClasses[class]; !ok {
|
||||
|
|
|
@ -20,6 +20,7 @@ package schedUtils
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/spdfg/elektron/def"
|
||||
elekLog "github.com/spdfg/elektron/elektronLogging"
|
||||
|
@ -79,7 +80,7 @@ func (s *fillNextOfferCycle) apply(taskQueue []def.Task) (int, int) {
|
|||
for _, task := range taskQueue {
|
||||
numberOfTasksTraversed++
|
||||
for i := *task.Instances; i > 0; i-- {
|
||||
elekLog.ElektronLog.Log(elekLogTypes.CONSOLE, log.InfoLevel,
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE, 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) {
|
||||
|
|
I would alias this to elekLog as you seem to be using that prefix when aliasing imports of sub-packages.