forked from DenisBiondic/DockerLogGenerator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerator.go
40 lines (32 loc) · 772 Bytes
/
generator.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package main
import (
"encoding/json"
"fmt"
"time"
)
type JsonLog struct {
TimeStamp string
LogMessage string
}
func main() {
generate()
}
func generate() {
for {
generateSimpleLogLine()
generateJsonLogLine()
generateMultilineLogLine()
time.Sleep(5 * time.Second)
}
}
func generateSimpleLogLine() {
fmt.Printf("[DockerLogGenerator] Current Time: %v\n", time.Now())
}
func generateJsonLogLine() {
jsonMap := map[string]string{"timeStamp": fmt.Sprintf("%v", time.Now()), "logMessage": "[DockerLogGenerator] This is a JSON log entry"}
json, _ := json.Marshal(jsonMap)
fmt.Println(string(json))
}
func generateMultilineLogLine() {
fmt.Printf("[DockerLogGenerator] Multiline: %v\n This is the second line\nThis is the third line\n", time.Now())
}