mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-31 15:06:26 +00:00
wip
This commit is contained in:
parent
353b0661a7
commit
00294e5d0d
1 changed files with 5 additions and 8 deletions
|
@ -72,7 +72,8 @@ var parserPool sync.Pool
|
||||||
//
|
//
|
||||||
// The p.Fields remains valid until the next call to PutJSONParser().
|
// The p.Fields remains valid until the next call to PutJSONParser().
|
||||||
func (p *JSONParser) ParseLogMessageNoResetBuf(msg, prefix string) error {
|
func (p *JSONParser) ParseLogMessageNoResetBuf(msg, prefix string) error {
|
||||||
return p.parseLogMessage(msg, prefix, false)
|
p.resetNobuf()
|
||||||
|
return p.parseLogMessage(msg, prefix)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ParseLogMessage parses the given JSON log message msg into p.Fields.
|
// ParseLogMessage parses the given JSON log message msg into p.Fields.
|
||||||
|
@ -82,10 +83,11 @@ func (p *JSONParser) ParseLogMessageNoResetBuf(msg, prefix string) error {
|
||||||
// The p.Fields remains valid until the next call to ParseLogMessage() or PutJSONParser().
|
// The p.Fields remains valid until the next call to ParseLogMessage() or PutJSONParser().
|
||||||
func (p *JSONParser) ParseLogMessage(msg []byte, prefix string) error {
|
func (p *JSONParser) ParseLogMessage(msg []byte, prefix string) error {
|
||||||
msgStr := bytesutil.ToUnsafeString(msg)
|
msgStr := bytesutil.ToUnsafeString(msg)
|
||||||
return p.parseLogMessage(msgStr, prefix, true)
|
p.reset()
|
||||||
|
return p.parseLogMessage(msgStr, prefix)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *JSONParser) parseLogMessage(msg, prefix string, resetBuf bool) error {
|
func (p *JSONParser) parseLogMessage(msg, prefix string) error {
|
||||||
v, err := p.p.Parse(msg)
|
v, err := p.p.Parse(msg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("cannot parse json: %w", err)
|
return fmt.Errorf("cannot parse json: %w", err)
|
||||||
|
@ -93,11 +95,6 @@ func (p *JSONParser) parseLogMessage(msg, prefix string, resetBuf bool) error {
|
||||||
if t := v.Type(); t != fastjson.TypeObject {
|
if t := v.Type(); t != fastjson.TypeObject {
|
||||||
return fmt.Errorf("expecting json dictionary; got %s", t)
|
return fmt.Errorf("expecting json dictionary; got %s", t)
|
||||||
}
|
}
|
||||||
if resetBuf {
|
|
||||||
p.reset()
|
|
||||||
} else {
|
|
||||||
p.resetNobuf()
|
|
||||||
}
|
|
||||||
p.prefixBuf = append(p.prefixBuf[:0], prefix...)
|
p.prefixBuf = append(p.prefixBuf[:0], prefix...)
|
||||||
p.Fields, p.buf, p.prefixBuf = appendLogFields(p.Fields, p.buf, p.prefixBuf, v)
|
p.Fields, p.buf, p.prefixBuf = appendLogFields(p.Fields, p.buf, p.prefixBuf, v)
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in a new issue