parser

package
v0.0.0-...-3f4cbe2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 25, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	JSONParserType string = "json"
	TextParserType string = "text"
)
View Source
const (
	FILE_KEY    = "file"
	MESSAGE_KEY = "message"
	LINE_KEY    = "line"
	LEVEL_KEY   = "level"
	TIME_KEY    = "time"
)
View Source
const (
	FIRST_GROUP = 1
)

Variables

View Source
var (
	ERROR_LEVEL_NOT_FOUND     = errors.New("level extractor is not exist")
	ERROR_MESSAGE_NOT_FOUND   = errors.New("message extractor is not exist")
	ERROR_LEVEL_IS_REQUIRED   = errors.New("level extractor is not exist")
	ERROR_NOT_FOUND_SUBSTRING = errors.New("key substring is not found")
)

Functions

This section is empty.

Types

type JSONOption

type JSONOption struct {
	LevelField     string `json:"level"`
	MessageField   string `json:"message"`
	AppName        string `json:"app_name,omitempty"`
	LogName        string `json:"log_name,omitempty"`
	TimestampField string `json:"timestamp"`
	FileField      string `json:"file,omitempty"`
}

type JSONParser

type JSONParser struct {
	// contains filtered or unexported fields
}

func NewJSONParser

func NewJSONParser(kind Type, config JSONOption) (*JSONParser, error)

func (JSONParser) Parse

func (j JSONParser) Parse(body []byte) (Log, error)

type Level

type Level int
const (
	INFO Level = iota + 1
	DEBUG
	WARNING
	ERROR
	FATAL
	UNKNOWN
)

func (Level) ToPBLevel

func (l Level) ToPBLevel() pb.Level

func (Level) ToString

func (l Level) ToString() string

type Log

type Log struct {
	App       string    `json:"watchers"`
	LogName   string    `json:"log_name"`
	Timestamp time.Time `json:"timestamp"`
	Level     Level     `json:"level"`
	Message   string    `json:"message"`
	File      string    `json:"file"`
	Type      Type      `json:"type"`
	Line      int64     `json:"line"`
	Payload   []byte    `json:"payload"`
}

func NewLog

func NewLog() *Log

type Parser

type Parser interface {
	Parse([]byte) (Log, error)
}

type ParserType

type ParserType string

type TextOption

type TextOption struct {
	LevelField     string `json:"level"`
	MessageField   string `json:"message"`
	AppName        string `json:"app_name,omitempty"`
	LogName        string `json:"log_name,omitempty"`
	TimestampField string `json:"timestamp"`
	FileField      string `json:"file,omitempty"`
	LineField      string `json:"line,omitempty"`
}

type TextParser

type TextParser struct {
	// contains filtered or unexported fields
}

func NewTextParser

func NewTextParser(kind Type, config TextOption) (*TextParser, error)

func (TextParser) Parse

func (t TextParser) Parse(body []byte) (Log, error)

type Type

type Type int
const (
	FILE Type = iota + 1
	HTTP
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL