Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConvertLogToExtended ¶
ConvertLogToExtended converts MongoDB log line formatted documents to an extended JSON representation
Example ¶
doc, _ := logdoc.ConvertLogToExtended([]byte("{ x: Timestamp(13000000, 0)}")) buf, _ := json.Marshal(doc) fmt.Print(string(buf))
Output: {"x":{"$timestamp":{"t":13000000,"i":0}}}
func ParseLogLine ¶
ParseLogLine attempts to parse a MongoDB log line into a structured representation
Example ¶
package main import ( "encoding/json" "fmt" "github.com/tmc/mongologtools/parser" ) func main() { line := "Mon Feb 23 03:20:19.670 [TTLMonitor] query local.system.indexes query: { expireAfterSeconds: { $exists: true } } ntoreturn:0 ntoskip:0 nscanned:0 keyUpdates:0 locks(micros) r:86 nreturned:0 reslen:20 0ms" doc, _ := parser.ParseLogLine(line) buf, _ := json.Marshal(doc) fmt.Print(string(buf)) }
Output: {"context":"TTLMonitor","duration_ms":"0","keyUpdates":0,"nreturned":0,"ns":"local.system.indexes","nscanned":0,"ntoreturn":0,"ntoskip":0,"op":"query","query":{"expireAfterSeconds":{"$exists":true}},"r":86,"reslen":20,"timestamp":"Mon Feb 23 03:20:19.670"}
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.