WIP : Elektron Logging library #16
|
@ -14,7 +14,7 @@ type ClsfnTaskDistrOverheadLogger struct {
|
|||
![]() 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!
|
||||
func NewClsfnTaskDistrOverheadLogger(logType int, prefix string) *ClsfnTaskDistrOverheadLogger {
|
||||
cLog := &ClsfnTaskDistrOverheadLogger{}
|
||||
cLog.Type = logType
|
||||
cLog.SetLogFile(prefix)
|
||||
![]() 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!
|
||||
cLog.CreateLogFile(prefix)
|
||||
![]() 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!
|
||||
return cLog
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ func (cLog ClsfnTaskDistrOverheadLogger) Log(logType int, level log.Level, logDa
|
|||
![]() 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!
|
||||
logger.WithFields(logData).Println(message)
|
||||
}
|
||||
|
||||
logger.SetOutput(cLog.LogFileName)
|
||||
![]() 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!
|
||||
logger.SetOutput(cLog.LogFile)
|
||||
![]() 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!
|
||||
logger.WithFields(logData).Println(message)
|
||||
}
|
||||
if cLog.next != nil {
|
||||
|
@ -36,7 +36,7 @@ func (cLog ClsfnTaskDistrOverheadLogger) Log(logType int, level log.Level, logDa
|
|||
![]() 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!
|
||||
}
|
||||
}
|
||||
|
||||
func (cLog *ClsfnTaskDistrOverheadLogger) SetLogFile(prefix string) {
|
||||
![]() 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!
|
||||
func (cLog *ClsfnTaskDistrOverheadLogger) CreateLogFile(prefix string) {
|
||||
![]() 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!
|
||||
|
||||
filename := strings.Join([]string{prefix, config.TaskDistrConfig.FilenameExtension}, "")
|
||||
dirName := logDir.getDirName()
|
||||
|
@ -44,7 +44,7 @@ func (cLog *ClsfnTaskDistrOverheadLogger) SetLogFile(prefix string) {
|
|||
![]() 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!
|
||||
if logFile, err := os.Create(filepath.Join(dirName, filename)); err != nil {
|
||||
log.Fatal("Unable to create logFile: ", err)
|
||||
} else {
|
||||
cLog.LogFileName = logFile
|
||||
![]() 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!
|
||||
cLog.LogFile = logFile
|
||||
![]() 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!
|
||||
cLog.AllowOnConsole = config.TaskDistrConfig.AllowOnConsole
|
||||
}
|
||||
}
|
||||
|
|
|||
![]() 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!
|
|
@ -14,7 +14,7 @@ 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
|
||||
func NewConsoleLogger(logType int, prefix string) *ConsoleLogger {
|
||||
cLog := &ConsoleLogger{}
|
||||
cLog.Type = logType
|
||||
cLog.SetLogFile(prefix)
|
||||
![]() 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
|
||||
cLog.CreateLogFile(prefix)
|
||||
![]() 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
|
||||
return cLog
|
||||
}
|
||||
func (cLog ConsoleLogger) Log(logType int, level log.Level, logData log.Fields, message string) {
|
||||
|
@ -25,7 +25,7 @@ func (cLog ConsoleLogger) Log(logType int, level log.Level, logData log.Fields,
|
|||
![]() 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
|
||||
logger.SetOutput(os.Stdout)
|
||||
logger.WithFields(logData).Println(message)
|
||||
|
||||
logger.SetOutput(cLog.LogFileName)
|
||||
![]() 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
|
||||
logger.SetOutput(cLog.LogFile)
|
||||
![]() 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
|
||||
logger.WithFields(logData).Println(message)
|
||||
}
|
||||
if cLog.next != nil {
|
||||
|
@ -33,7 +33,7 @@ func (cLog ConsoleLogger) Log(logType int, level log.Level, logData log.Fields,
|
|||
![]() 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
|
||||
}
|
||||
}
|
||||
|
||||
func (cLog *ConsoleLogger) SetLogFile(prefix string) {
|
||||
![]() 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
|
||||
func (cLog *ConsoleLogger) CreateLogFile(prefix string) {
|
||||
![]() 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
|
||||
|
||||
filename := strings.Join([]string{prefix, config.ConsoleConfig.FilenameExtension}, "")
|
||||
dirName := logDir.getDirName()
|
||||
|
@ -41,7 +41,7 @@ func (cLog *ConsoleLogger) SetLogFile(prefix string) {
|
|||
![]() 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
|
||||
if logFile, err := os.Create(filepath.Join(dirName, filename)); err != nil {
|
||||
log.Fatal("Unable to create logFile: ", err)
|
||||
} else {
|
||||
cLog.LogFileName = logFile
|
||||
![]() 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
|
||||
cLog.LogFile = logFile
|
||||
![]() 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
|
||||
cLog.AllowOnConsole = config.ConsoleConfig.AllowOnConsole
|
||||
}
|
||||
}
|
||||
|
|
|||
![]() 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
|
|
@ -35,7 +35,7 @@ func BuildLogger(prefix 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`
|
||||
// create a chain of loggers
|
||||
head := &LoggerImpl{}
|
||||
cLog := NewConsoleLogger(CONSOLE, prefix)
|
||||
pLog := NewPcpLogger(PCP, prefix)
|
||||
![]() 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`
|
||||
pLog := NewPCPLogger(PCP, prefix)
|
||||
![]() 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`
|
||||
schedTraceLog := NewSchedTraceLogger(SCHED_TRACE, prefix)
|
||||
spsLog := NewSchedPolicySwitchLogger(SPS, prefix)
|
||||
schedWindowLog := NewSchedWindowLogger(SCHED_WINDOW, prefix)
|
||||
|
|
|||
![]() 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`
|
|
@ -8,12 +8,12 @@ import (
|
|||
![]() If the code isn't needed it shouldn't be left here. If the commented out code is still needed there should be some justification for it still being here. If the code isn't needed it shouldn't be left here. If the commented out code is still needed there should be some justification for it still being here.
![]() Okay. Will remove the unnecessary code Okay. Will remove the unnecessary code
![]() As fields are optional, it is better to either have them as the last argument or not have them in the argument list at all. As fields are optional, it is better to either have them as the last argument or not have them in the argument list at all.
I would in fact also maintain an internal data structure to store Fields that is cleared only after the log operation passes through the entire chain. You can then add a `WithFields(...)` method that wraps around `logrus.WithFields(...)`.
I have created [this sample code](https://play.golang.org/p/RILTxcZtT2w) for reference. The sample code also shows how formatted strings are corresponding args can be passed and we can wrap around `logrus.Logf(...)` for that.
![]() Refactor to Refactor to `LogFile` as it is a pointer to os.File and not string.
![]() Done Done
![]() Done Done
![]() If the code isn't needed it shouldn't be left here. If the commented out code is still needed there should be some justification for it still being here. If the code isn't needed it shouldn't be left here. If the commented out code is still needed there should be some justification for it still being here.
![]() Okay. Will remove the unnecessary code Okay. Will remove the unnecessary code
![]() As fields are optional, it is better to either have them as the last argument or not have them in the argument list at all. As fields are optional, it is better to either have them as the last argument or not have them in the argument list at all.
I would in fact also maintain an internal data structure to store Fields that is cleared only after the log operation passes through the entire chain. You can then add a `WithFields(...)` method that wraps around `logrus.WithFields(...)`.
I have created [this sample code](https://play.golang.org/p/RILTxcZtT2w) for reference. The sample code also shows how formatted strings are corresponding args can be passed and we can wrap around `logrus.Logf(...)` for that.
![]() Refactor to Refactor to `LogFile` as it is a pointer to os.File and not string.
![]() Done Done
![]() Done Done
|
||||
type Logger interface {
|
||||
SetNext(logType Logger)
|
||||
Log(logType int, level log.Level, logData log.Fields, message string)
|
||||
SetLogFile(prefix string)
|
||||
![]() If the code isn't needed it shouldn't be left here. If the commented out code is still needed there should be some justification for it still being here. If the code isn't needed it shouldn't be left here. If the commented out code is still needed there should be some justification for it still being here.
![]() Okay. Will remove the unnecessary code Okay. Will remove the unnecessary code
![]() As fields are optional, it is better to either have them as the last argument or not have them in the argument list at all. As fields are optional, it is better to either have them as the last argument or not have them in the argument list at all.
I would in fact also maintain an internal data structure to store Fields that is cleared only after the log operation passes through the entire chain. You can then add a `WithFields(...)` method that wraps around `logrus.WithFields(...)`.
I have created [this sample code](https://play.golang.org/p/RILTxcZtT2w) for reference. The sample code also shows how formatted strings are corresponding args can be passed and we can wrap around `logrus.Logf(...)` for that.
![]() Refactor to Refactor to `LogFile` as it is a pointer to os.File and not string.
![]() Done Done
![]() Done Done
|
||||
CreateLogFile(prefix string)
|
||||
![]() If the code isn't needed it shouldn't be left here. If the commented out code is still needed there should be some justification for it still being here. If the code isn't needed it shouldn't be left here. If the commented out code is still needed there should be some justification for it still being here.
![]() Okay. Will remove the unnecessary code Okay. Will remove the unnecessary code
![]() As fields are optional, it is better to either have them as the last argument or not have them in the argument list at all. As fields are optional, it is better to either have them as the last argument or not have them in the argument list at all.
I would in fact also maintain an internal data structure to store Fields that is cleared only after the log operation passes through the entire chain. You can then add a `WithFields(...)` method that wraps around `logrus.WithFields(...)`.
I have created [this sample code](https://play.golang.org/p/RILTxcZtT2w) for reference. The sample code also shows how formatted strings are corresponding args can be passed and we can wrap around `logrus.Logf(...)` for that.
![]() Refactor to Refactor to `LogFile` as it is a pointer to os.File and not string.
![]() Done Done
![]() Done Done
|
||||
}
|
||||
type LoggerImpl struct {
|
||||
Type int
|
||||
AllowOnConsole bool
|
||||
LogFileName *os.File
|
||||
![]() If the code isn't needed it shouldn't be left here. If the commented out code is still needed there should be some justification for it still being here. If the code isn't needed it shouldn't be left here. If the commented out code is still needed there should be some justification for it still being here.
![]() Okay. Will remove the unnecessary code Okay. Will remove the unnecessary code
![]() As fields are optional, it is better to either have them as the last argument or not have them in the argument list at all. As fields are optional, it is better to either have them as the last argument or not have them in the argument list at all.
I would in fact also maintain an internal data structure to store Fields that is cleared only after the log operation passes through the entire chain. You can then add a `WithFields(...)` method that wraps around `logrus.WithFields(...)`.
I have created [this sample code](https://play.golang.org/p/RILTxcZtT2w) for reference. The sample code also shows how formatted strings are corresponding args can be passed and we can wrap around `logrus.Logf(...)` for that.
![]() Refactor to Refactor to `LogFile` as it is a pointer to os.File and not string.
![]() Done Done
![]() Done Done
|
||||
LogFile *os.File
|
||||
![]() If the code isn't needed it shouldn't be left here. If the commented out code is still needed there should be some justification for it still being here. If the code isn't needed it shouldn't be left here. If the commented out code is still needed there should be some justification for it still being here.
![]() Okay. Will remove the unnecessary code Okay. Will remove the unnecessary code
![]() As fields are optional, it is better to either have them as the last argument or not have them in the argument list at all. As fields are optional, it is better to either have them as the last argument or not have them in the argument list at all.
I would in fact also maintain an internal data structure to store Fields that is cleared only after the log operation passes through the entire chain. You can then add a `WithFields(...)` method that wraps around `logrus.WithFields(...)`.
I have created [this sample code](https://play.golang.org/p/RILTxcZtT2w) for reference. The sample code also shows how formatted strings are corresponding args can be passed and we can wrap around `logrus.Logf(...)` for that.
![]() Refactor to Refactor to `LogFile` as it is a pointer to os.File and not string.
![]() Done Done
![]() Done Done
|
||||
next Logger
|
||||
}
|
||||
|
||||
|
|
|||
![]() If the code isn't needed it shouldn't be left here. If the commented out code is still needed there should be some justification for it still being here. If the code isn't needed it shouldn't be left here. If the commented out code is still needed there should be some justification for it still being here.
![]() Okay. Will remove the unnecessary code Okay. Will remove the unnecessary code
![]() As fields are optional, it is better to either have them as the last argument or not have them in the argument list at all. As fields are optional, it is better to either have them as the last argument or not have them in the argument list at all.
I would in fact also maintain an internal data structure to store Fields that is cleared only after the log operation passes through the entire chain. You can then add a `WithFields(...)` method that wraps around `logrus.WithFields(...)`.
I have created [this sample code](https://play.golang.org/p/RILTxcZtT2w) for reference. The sample code also shows how formatted strings are corresponding args can be passed and we can wrap around `logrus.Logf(...)` for that.
![]() Refactor to Refactor to `LogFile` as it is a pointer to os.File and not string.
![]() Done Done
![]() Done Done
![]() If the code isn't needed it shouldn't be left here. If the commented out code is still needed there should be some justification for it still being here. If the code isn't needed it shouldn't be left here. If the commented out code is still needed there should be some justification for it still being here.
![]() Okay. Will remove the unnecessary code Okay. Will remove the unnecessary code
![]() As fields are optional, it is better to either have them as the last argument or not have them in the argument list at all. As fields are optional, it is better to either have them as the last argument or not have them in the argument list at all.
I would in fact also maintain an internal data structure to store Fields that is cleared only after the log operation passes through the entire chain. You can then add a `WithFields(...)` method that wraps around `logrus.WithFields(...)`.
I have created [this sample code](https://play.golang.org/p/RILTxcZtT2w) for reference. The sample code also shows how formatted strings are corresponding args can be passed and we can wrap around `logrus.Logf(...)` for that.
![]() Refactor to Refactor to `LogFile` as it is a pointer to os.File and not string.
![]() Done Done
![]() Done Done
|
|
@ -56,7 +56,7 @@ func (c *LoggerConfig) GetConfig() *LoggerConfig {
|
|||
![]() Are column headers being added if enabled? Are column headers being added if enabled?
![]() Refactor to TaskDistrConfig for semantics. Refactor to TaskDistrConfig for semantics.
![]() ditto. ditto.
![]() The error message does not do justice in indicating the reason for the error. The error message does not do justice in indicating the reason for the error.
![]() ditto. ditto.
![]() That was for future purpose. But I have removed it now That was for future purpose. But I have removed it now
![]() Done Done
![]() Done Done
![]() Changed the error message Changed the error message
![]() Done Done
![]() Are column headers being added if enabled? Are column headers being added if enabled?
![]() Refactor to TaskDistrConfig for semantics. Refactor to TaskDistrConfig for semantics.
![]() ditto. ditto.
![]() The error message does not do justice in indicating the reason for the error. The error message does not do justice in indicating the reason for the error.
![]() ditto. ditto.
![]() That was for future purpose. But I have removed it now That was for future purpose. But I have removed it now
![]() Done Done
![]() Done Done
![]() Changed the error message Changed the error message
![]() Done Done
|
||||
}
|
||||
err = yaml.Unmarshal(yamlFile, c)
|
||||
if err != nil {
|
||||
log.Fatalf("Error in yaml unmarshal: %v", err)
|
||||
![]() Are column headers being added if enabled? Are column headers being added if enabled?
![]() Refactor to TaskDistrConfig for semantics. Refactor to TaskDistrConfig for semantics.
![]() ditto. ditto.
![]() The error message does not do justice in indicating the reason for the error. The error message does not do justice in indicating the reason for the error.
![]() ditto. ditto.
![]() That was for future purpose. But I have removed it now That was for future purpose. But I have removed it now
![]() Done Done
![]() Done Done
![]() Changed the error message Changed the error message
![]() Done Done
|
||||
log.Fatalf("Error in unmarshalling yaml: %v", err)
|
||||
![]() Are column headers being added if enabled? Are column headers being added if enabled?
![]() Refactor to TaskDistrConfig for semantics. Refactor to TaskDistrConfig for semantics.
![]() ditto. ditto.
![]() The error message does not do justice in indicating the reason for the error. The error message does not do justice in indicating the reason for the error.
![]() ditto. ditto.
![]() That was for future purpose. But I have removed it now That was for future purpose. But I have removed it now
![]() Done Done
![]() Done Done
![]() Changed the error message Changed the error message
![]() Done Done
|
||||
}
|
||||
|
||||
return c
|
||||
|
|
|||
![]() Are column headers being added if enabled? Are column headers being added if enabled?
![]() Refactor to TaskDistrConfig for semantics. Refactor to TaskDistrConfig for semantics.
![]() ditto. ditto.
![]() The error message does not do justice in indicating the reason for the error. The error message does not do justice in indicating the reason for the error.
![]() ditto. ditto.
![]() That was for future purpose. But I have removed it now That was for future purpose. But I have removed it now
![]() Done Done
![]() Done Done
![]() Changed the error message Changed the error message
![]() Done Done
![]() Are column headers being added if enabled? Are column headers being added if enabled?
![]() Refactor to TaskDistrConfig for semantics. Refactor to TaskDistrConfig for semantics.
![]() ditto. ditto.
![]() The error message does not do justice in indicating the reason for the error. The error message does not do justice in indicating the reason for the error.
![]() ditto. ditto.
![]() That was for future purpose. But I have removed it now That was for future purpose. But I have removed it now
![]() Done Done
![]() Done Done
![]() Changed the error message Changed the error message
![]() Done Done
|
|
@ -7,18 +7,18 @@ import (
|
|||
![]() 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
|
||||
"strings"
|
||||
)
|
||||
|
||||
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
|
||||
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
|
||||
LoggerImpl
|
||||
}
|
||||
|
||||
func NewPcpLogger(logType int, prefix string) *PcpLogger {
|
||||
![]() 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
|
||||
pLog := &PcpLogger{}
|
||||
![]() 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
|
||||
func NewPCPLogger(logType int, prefix string) *PCPLogger {
|
||||
![]() 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
|
||||
pLog := &PCPLogger{}
|
||||
![]() 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
|
||||
pLog.Type = logType
|
||||
pLog.SetLogFile(prefix)
|
||||
![]() 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
|
||||
pLog.CreateLogFile(prefix)
|
||||
![]() 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
|
||||
return pLog
|
||||
}
|
||||
|
||||
func (pLog PcpLogger) Log(logType int, level log.Level, logData log.Fields, message string) {
|
||||
![]() 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
|
||||
func (pLog PCPLogger) Log(logType int, level log.Level, logData log.Fields, message string) {
|
||||
![]() 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
|
||||
if pLog.Type == logType {
|
||||
|
||||
logger.SetLevel(level)
|
||||
|
@ -28,7 +28,7 @@ func (pLog PcpLogger) Log(logType int, level log.Level, logData log.Fields, mess
|
|||
![]() 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
|
||||
logger.WithFields(logData).Println(message)
|
||||
}
|
||||
|
||||
logger.SetOutput(pLog.LogFileName)
|
||||
![]() 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
|
||||
logger.SetOutput(pLog.LogFile)
|
||||
![]() 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
|
||||
logger.WithFields(logData).Println(message)
|
||||
}
|
||||
if pLog.next != nil {
|
||||
|
@ -36,7 +36,7 @@ func (pLog PcpLogger) Log(logType int, level log.Level, logData log.Fields, mess
|
|||
![]() 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
|
||||
}
|
||||
}
|
||||
|
||||
func (pLog *PcpLogger) SetLogFile(prefix string) {
|
||||
![]() 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
|
||||
func (pLog *PCPLogger) CreateLogFile(prefix string) {
|
||||
![]() 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
|
||||
|
||||
filename := strings.Join([]string{prefix, config.PCPConfig.FilenameExtension}, "")
|
||||
dirName := logDir.getDirName()
|
||||
|
@ -44,7 +44,7 @@ func (pLog *PcpLogger) SetLogFile(prefix string) {
|
|||
![]() 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
|
||||
if logFile, err := os.Create(filepath.Join(dirName, filename)); err != nil {
|
||||
log.Fatal("Unable to create logFile: ", err)
|
||||
} else {
|
||||
pLog.LogFileName = logFile
|
||||
![]() 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
|
||||
pLog.LogFile = logFile
|
||||
![]() 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
|
||||
pLog.AllowOnConsole = config.PCPConfig.AllowOnConsole
|
||||
}
|
||||
}
|
||||
|
|
|||
![]() 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
|
|
@ -14,7 +14,7 @@ type SchedPolicySwitchLogger struct {
|
|||
func NewSchedPolicySwitchLogger(logType int, prefix string) *SchedPolicySwitchLogger {
|
||||
sLog := &SchedPolicySwitchLogger{}
|
||||
sLog.Type = logType
|
||||
sLog.SetLogFile(prefix)
|
||||
sLog.CreateLogFile(prefix)
|
||||
return sLog
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ func (sLog SchedPolicySwitchLogger) Log(logType int, level log.Level, logData lo
|
|||
logger.WithFields(logData).Println(message)
|
||||
}
|
||||
|
||||
logger.SetOutput(sLog.LogFileName)
|
||||
logger.SetOutput(sLog.LogFile)
|
||||
logger.WithFields(logData).Println(message)
|
||||
}
|
||||
if sLog.next != nil {
|
||||
|
@ -36,7 +36,7 @@ func (sLog SchedPolicySwitchLogger) Log(logType int, level log.Level, logData lo
|
|||
}
|
||||
}
|
||||
|
||||
func (sLog *SchedPolicySwitchLogger) SetLogFile(prefix string) {
|
||||
func (sLog *SchedPolicySwitchLogger) CreateLogFile(prefix string) {
|
||||
|
||||
filename := strings.Join([]string{prefix, config.SPSConfig.FilenameExtension}, "")
|
||||
dirName := logDir.getDirName()
|
||||
|
@ -44,7 +44,7 @@ func (sLog *SchedPolicySwitchLogger) SetLogFile(prefix string) {
|
|||
if logFile, err := os.Create(filepath.Join(dirName, filename)); err != nil {
|
||||
log.Fatal("Unable to create logFile: ", err)
|
||||
} else {
|
||||
sLog.LogFileName = logFile
|
||||
sLog.LogFile = logFile
|
||||
sLog.AllowOnConsole = config.SPSConfig.AllowOnConsole
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ type SchedTraceLogger struct {
|
|||
func NewSchedTraceLogger(logType int, prefix string) *SchedTraceLogger {
|
||||
sLog := &SchedTraceLogger{}
|
||||
sLog.Type = logType
|
||||
sLog.SetLogFile(prefix)
|
||||
sLog.CreateLogFile(prefix)
|
||||
return sLog
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ func (sLog SchedTraceLogger) Log(logType int, level log.Level, logData log.Field
|
|||
logger.WithFields(logData).Println(message)
|
||||
}
|
||||
|
||||
logger.SetOutput(sLog.LogFileName)
|
||||
logger.SetOutput(sLog.LogFile)
|
||||
logger.WithFields(logData).Println(message)
|
||||
}
|
||||
if sLog.next != nil {
|
||||
|
@ -36,7 +36,7 @@ func (sLog SchedTraceLogger) Log(logType int, level log.Level, logData log.Field
|
|||
}
|
||||
}
|
||||
|
||||
func (sLog *SchedTraceLogger) SetLogFile(prefix string) {
|
||||
func (sLog *SchedTraceLogger) CreateLogFile(prefix string) {
|
||||
|
||||
filename := strings.Join([]string{prefix, config.SchedTraceConfig.FilenameExtension}, "")
|
||||
dirName := logDir.getDirName()
|
||||
|
@ -44,7 +44,7 @@ func (sLog *SchedTraceLogger) SetLogFile(prefix string) {
|
|||
if logFile, err := os.Create(filepath.Join(dirName, filename)); err != nil {
|
||||
log.Fatal("Unable to create logFile: ", err)
|
||||
} else {
|
||||
sLog.LogFileName = logFile
|
||||
sLog.LogFile = logFile
|
||||
sLog.AllowOnConsole = config.SchedTraceConfig.AllowOnConsole
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ type SchedWindowLogger struct {
|
|||
func NewSchedWindowLogger(logType int, prefix string) *SchedWindowLogger {
|
||||
sLog := &SchedWindowLogger{}
|
||||
sLog.Type = logType
|
||||
sLog.SetLogFile(prefix)
|
||||
sLog.CreateLogFile(prefix)
|
||||
return sLog
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ func (sLog SchedWindowLogger) Log(logType int, level log.Level, logData log.Fiel
|
|||
logger.WithFields(logData).Println(message)
|
||||
}
|
||||
|
||||
logger.SetOutput(sLog.LogFileName)
|
||||
logger.SetOutput(sLog.LogFile)
|
||||
logger.WithFields(logData).Println(message)
|
||||
}
|
||||
if sLog.next != nil {
|
||||
|
@ -36,7 +36,7 @@ func (sLog SchedWindowLogger) Log(logType int, level log.Level, logData log.Fiel
|
|||
}
|
||||
}
|
||||
|
||||
func (sLog *SchedWindowLogger) SetLogFile(prefix string) {
|
||||
func (sLog *SchedWindowLogger) CreateLogFile(prefix string) {
|
||||
|
||||
filename := strings.Join([]string{prefix, config.SchedWindowConfig.FilenameExtension}, "")
|
||||
dirName := logDir.getDirName()
|
||||
|
@ -44,7 +44,7 @@ func (sLog *SchedWindowLogger) SetLogFile(prefix string) {
|
|||
if logFile, err := os.Create(filepath.Join(dirName, filename)); err != nil {
|
||||
log.Fatal("Unable to create logFile: ", err)
|
||||
} else {
|
||||
sLog.LogFileName = logFile
|
||||
sLog.LogFile = logFile
|
||||
sLog.AllowOnConsole = config.SchedWindowConfig.AllowOnConsole
|
||||
}
|
||||
}
|
||||
|
|
Use struct literals instead of new as it's more descriptive:
&ClsfnTaskDistOverheadLogger{}
Where is log dir coming from? Shouldn't be a global