Added clean target to Makefile. Created package logger

This commit is contained in:
Héctor Hurtado
2020-04-15 17:52:46 +02:00
parent e1788b2874
commit 63a675675a
2 changed files with 33 additions and 1 deletions
+29
View File
@@ -0,0 +1,29 @@
package logger
import (
"log"
"os"
)
type LogMsg struct {
prefix,
messages []string
}
var (
loggerChannel = make(chan LogMsg)
execLog = log.New(os.Stdout, "", log.Ldate|log.Ltime|log.LUTC|log.Lmicroseconds)
)
func WriteLog(log LogMsg) {
loggerChannel <- log
}
func ProccessLogs() {
for msg := range loggerChannel {
for _, msgLine := range msg.messages {
execLog.Printf("%s\t%s", msg.prefix, msgLine)
}
}
}