parse

package
v0.6.9 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2021 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package parse provides functions to parse LSP logs. Fully processed logs are returned by ToRLog().

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromClient

func FromClient(msg string) bool

FromClient says if the message is from the client

func FromServer

func FromServer(msg string) bool

FromServer says if the message is from the server

func IsNotify

func IsNotify(msg string) bool

IsNotify says if the message is a notification

func Notifs

func Notifs(m string) interface{}

Notifs returns a pointer to a type suitable for Unmarshal

func Requests

func Requests(m string) interface{}

Requests returns a pointer to a type suitable for Unmarshal

func Responses

func Responses(m string) []interface{}

Responses returns a slice of types, one of which should be suitable for Unmarshal

Types

type LogHist

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

LogHist gets ints, and puts them into buckets: <=10, <=30, 100, 300, 1000, ... It produces a historgram of elapsed times in milliseconds

func (*LogHist) String

func (l *LogHist) String() string

String returns a string describing a histogram

type Logmsg

type Logmsg struct {
	Type    MsgType
	Method  string
	ID      string      // for requests/responses. Client and server request ids overlap
	Elapsed string      // for responses
	Hdr     string      // header. do we need to keep all these strings?
	Rest    string      // the unparsed result, with newlines or not
	Body    interface{} // the parsed result
}

Logmsg is the type of a parsed log entry.

func ReadLogs

func ReadLogs(fname string) ([]*Logmsg, error)

ReadLogs from a file. Most users should use ToRlog().

type MsgType

type MsgType int

MsgType is the type of message.

const (
	// ClRequest from client to server has method and id
	ClRequest MsgType = iota
	// ClResponse from server to client
	ClResponse
	// SvRequest from server to client, has method and id
	SvRequest
	// SvResponse from client to server
	SvResponse
	// ToServer notification has method, but no id
	ToServer
	// ToClient notification
	ToClient
	// ReportErr is an error message
	ReportErr // errors have method and id
)

func (MsgType) String

func (d MsgType) String() string

String returns a user-useful versin of a Direction

type Msgtype

type Msgtype int

Msgtype given method names. Note that mSrv|mCl is possible

const (
	// Mnot for notifications
	Mnot Msgtype = 1
	// Mreq for requests
	Mreq Msgtype = 2
	// Msrv for messages from the server
	Msrv Msgtype = 4
	// Mcl for messages from the client
	Mcl Msgtype = 8
)

type Rlog

type Rlog struct {
	Logs         []*Logmsg          // In the order in the log file
	ServerCall   map[string]*Logmsg // ID->Request, client->server
	ServerReply  map[string]*Logmsg // ID->Response, server->client (includes Errors)
	ClientCall   map[string]*Logmsg
	ClientReply  map[string]*Logmsg
	ClientNotifs []*Logmsg
	ServerNotifs []*Logmsg
	Histogram    *LogHist
}

Rlog contains the processed logs

func ToRlog

func ToRlog(fname string) (*Rlog, error)

ToRlog reads a log file and returns a *Rlog

func (*Rlog) Counts

func (r *Rlog) Counts() string

Counts returns a one-line summary of an Rlog

Jump to

Keyboard shortcuts

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