move cfg to loggers + refactor + log fn wrappers
1. Instead of maintaining a global config, each specialized logger now stores its config. 2. Refactored logInterface to elektronLogger. 3. Refactored loggerImpl to baseElektronLogger to be consistent with the rest of the code base. 4. Wrapped elektronLogger#Log(...) and elektronLogf(...) so that we do not have to use the instance of elektronLogger everytime we want to log. Instead, we just do logging.Log(...) or logging.Logf(...). 5. Wrapped elektronLogger#WithFields(...) and elektronLogger#WithField(...). 6. Refactored codebase to adhere to the changes.
This commit is contained in:
parent
5a6d1bed4a
commit
6fb0e4a3fe
20 changed files with 396 additions and 250 deletions
|
@ -47,7 +47,7 @@ func Start(quit chan struct{}, logging *bool, pcpConfigFile string) {
|
|||
scanner.Scan()
|
||||
|
||||
// Write to logfile
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.PCP, log.InfoLevel, scanner.Text())
|
||||
elekLog.Log(elekLogTypes.PCP, log.InfoLevel, scanner.Text())
|
||||
|
||||
// Throw away first set of results
|
||||
scanner.Scan()
|
||||
|
@ -58,14 +58,14 @@ func Start(quit chan struct{}, logging *bool, pcpConfigFile string) {
|
|||
text := scanner.Text()
|
||||
|
||||
if *logging {
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.PCP, log.InfoLevel, text)
|
||||
elekLog.Log(elekLogTypes.PCP, log.InfoLevel, text)
|
||||
}
|
||||
|
||||
seconds++
|
||||
}
|
||||
}(logging)
|
||||
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE, log.InfoLevel, "PCP logging started")
|
||||
elekLog.Log(elekLogTypes.CONSOLE, log.InfoLevel, "PCP logging started")
|
||||
|
||||
if err := cmd.Start(); err != nil {
|
||||
log.Fatal(err)
|
||||
|
@ -75,7 +75,7 @@ func Start(quit chan struct{}, logging *bool, pcpConfigFile string) {
|
|||
|
||||
select {
|
||||
case <-quit:
|
||||
elekLog.ElektronLogger.Log(elekLogTypes.CONSOLE, log.InfoLevel, "Stopping PCP logging in 5 seconds")
|
||||
elekLog.Log(elekLogTypes.CONSOLE, log.InfoLevel, "Stopping PCP logging in 5 seconds")
|
||||
time.Sleep(5 * time.Second)
|
||||
|
||||
// http://stackoverflow.com/questions/22470193/why-wont-go-kill-a-child-process-correctly
|
||||
|
|
Reference in a new issue