log

package
v0.0.0-...-9742f5a Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2020 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidLengthMessage = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowMessage   = fmt.Errorf("proto: integer overflow")
)
View Source
var (
	ErrInvalidLengthServer = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowServer   = fmt.Errorf("proto: integer overflow")
)
View Source
var ErrBundleTooLarge = errors.New("log bundle is too large")

ErrBundleTooLarge indicates when the bundle has exceeded the limits the logpipe server has placed.

View Source
var ErrSpoolFull = errors.New("the spool is full, please retry later")

ErrSpoolFull is sent when the spool dir is full and no more logs can be accepted.

View Source
var ErrTooManyConnections = errors.New("too many connections, please retry later")

ErrTooManyConnections is thrown when the server is overloaded

View Source
var ErrTooMuchData = errors.New("too much data sent; please retry later")

ErrTooMuchData indicates when too much data has been sent.

Functions

func NewHook

func NewHook(c *Client) logrus.Hook

NewHook initializes a logrus Hook.

func RegisterLogPipeServer

func RegisterLogPipeServer(s *grpc.Server, srv LogPipeServer)

Types

type CLIOpt

type CLIOpt struct {
	JSON  bool
	Debug bool
}

CLIOpt is used to parameterise NewCLILogger in an extensible fashion. For instance, to make JSON logging the default:

``` NewCLILogger(CLIOpt{Json:true}) ```

type Client

type Client struct {
	Error error
	// contains filtered or unexported fields
}

Client is a logging client that uses grpc to send a structured log.

func NewClient

func NewClient(serverAddress, service, logDir string, debug, insecure bool, config *Config, kp *keypair.KeyPair) (*Client, error)

NewClient creates a new client.

func (*Client) Close

func (c *Client) Close() error

Close closes any logfile and connections

func (*Client) Write

func (c *Client) Write(e *logrus.Entry) error

type Config

type Config struct {
	// ShowOurLogs determines whether or not to show our own diagnostic information.
	ShowOurLogs bool
	// DeliverLogs indicates whether or not logs should be delivered at all
	DeliverLogs bool
	// BackoffCap determines the maximum amount of time to wait in an backoff scenario.
	BackoffCap time.Duration
	// BackoffGranularity determines the time interval to use for calculating new backoff values
	BackoffGranularity time.Duration
	// TickInterval is the minimum/default amount of time to wait before waking up to deliver logs.
	TickInterval time.Duration
}

Config is the configuration of the background logging services.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns the default configuration

type Entry

type Entry struct {
	Message              string           `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"`
	Fields               *types.Struct    `protobuf:"bytes,2,opt,name=fields,proto3" json:"fields,omitempty"`
	At                   *types.Timestamp `protobuf:"bytes,3,opt,name=at,proto3" json:"at,omitempty"`
	Service              string           `protobuf:"bytes,4,opt,name=service,proto3" json:"service,omitempty"`
	Level                int64            `protobuf:"varint,5,opt,name=level,proto3" json:"level,omitempty"`
	XXX_NoUnkeyedLiteral struct{}         `json:"-"`
	XXX_unrecognized     []byte           `json:"-"`
	XXX_sizecache        int32            `json:"-"`
}

Entry is a log message

func (*Entry) Descriptor

func (*Entry) Descriptor() ([]byte, []int)

func (*Entry) GetAt

func (m *Entry) GetAt() *types.Timestamp

func (*Entry) GetFields

func (m *Entry) GetFields() *types.Struct

func (*Entry) GetLevel

func (m *Entry) GetLevel() int64

func (*Entry) GetMessage

func (m *Entry) GetMessage() string

func (*Entry) GetService

func (m *Entry) GetService() string

func (*Entry) Marshal

func (m *Entry) Marshal() (dAtA []byte, err error)

func (*Entry) MarshalTo

func (m *Entry) MarshalTo(dAtA []byte) (int, error)

func (*Entry) ProtoMessage

func (*Entry) ProtoMessage()

func (*Entry) Reset

func (m *Entry) Reset()

func (*Entry) Size

func (m *Entry) Size() (n int)

func (*Entry) String

func (m *Entry) String() string

func (*Entry) Unmarshal

func (m *Entry) Unmarshal(dAtA []byte) error

func (*Entry) XXX_DiscardUnknown

func (m *Entry) XXX_DiscardUnknown()

func (*Entry) XXX_Marshal

func (m *Entry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Entry) XXX_Merge

func (m *Entry) XXX_Merge(src proto.Message)

func (*Entry) XXX_Size

func (m *Entry) XXX_Size() int

func (*Entry) XXX_Unmarshal

func (m *Entry) XXX_Unmarshal(b []byte) error

type Hook

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

Hook is a log emitter compatible with logrus; speaks to a client to send its data over the wire

func (*Hook) Fire

func (l *Hook) Fire(e *logrus.Entry) error

Fire sends the event to our client.

func (*Hook) Levels

func (l *Hook) Levels() []logrus.Level

Levels returns the levels appropriate for this hook.

type LogData

type LogData struct {
	Data                 []byte   `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
	PubKey               []byte   `protobuf:"bytes,2,opt,name=pubKey,proto3" json:"pubKey,omitempty"`
	Signature            []byte   `protobuf:"bytes,3,opt,name=signature,proto3" json:"signature,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

LogData is the data to be shipped over the wire

func (*LogData) Descriptor

func (*LogData) Descriptor() ([]byte, []int)

func (*LogData) GetData

func (m *LogData) GetData() []byte

func (*LogData) GetPubKey

func (m *LogData) GetPubKey() []byte

func (*LogData) GetSignature

func (m *LogData) GetSignature() []byte

func (*LogData) Marshal

func (m *LogData) Marshal() (dAtA []byte, err error)

func (*LogData) MarshalTo

func (m *LogData) MarshalTo(dAtA []byte) (int, error)

func (*LogData) ProtoMessage

func (*LogData) ProtoMessage()

func (*LogData) Reset

func (m *LogData) Reset()

func (*LogData) Size

func (m *LogData) Size() (n int)

func (*LogData) String

func (m *LogData) String() string

func (*LogData) Unmarshal

func (m *LogData) Unmarshal(dAtA []byte) error

func (*LogData) XXX_DiscardUnknown

func (m *LogData) XXX_DiscardUnknown()

func (*LogData) XXX_Marshal

func (m *LogData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*LogData) XXX_Merge

func (m *LogData) XXX_Merge(src proto.Message)

func (*LogData) XXX_Size

func (m *LogData) XXX_Size() int

func (*LogData) XXX_Unmarshal

func (m *LogData) XXX_Unmarshal(b []byte) error

type LogPipeClient

type LogPipeClient interface {
	// ReceiveLogs receives a stream of log data to later unpack and send to ES.
	ReceiveLogs(ctx context.Context, opts ...grpc.CallOption) (LogPipe_ReceiveLogsClient, error)
}

LogPipeClient is the client API for LogPipe service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

func NewLogPipeClient

func NewLogPipeClient(cc *grpc.ClientConn) LogPipeClient

type LogPipeServer

type LogPipeServer interface {
	// ReceiveLogs receives a stream of log data to later unpack and send to ES.
	ReceiveLogs(LogPipe_ReceiveLogsServer) error
}

LogPipeServer is the server API for LogPipe service.

type LogPipe_ReceiveLogsClient

type LogPipe_ReceiveLogsClient interface {
	Send(*LogData) error
	CloseAndRecv() (*types.Empty, error)
	grpc.ClientStream
}

type LogPipe_ReceiveLogsServer

type LogPipe_ReceiveLogsServer interface {
	SendAndClose(*types.Empty) error
	Recv() (*LogData, error)
	grpc.ServerStream
}

type LoggerConfig

type LoggerConfig struct {
	logrus.Logger
	LogAddress  string
	LogSpoolDir string
	LogLevelStr string
	LogCaller   bool
	LogFile     string
	// contains filtered or unexported fields
}

LoggerConfig describes the configuration of logging for a program.

func NewCLILogger

func NewCLILogger(serviceName string, opts CLIOpt) *LoggerConfig

NewCLILogger creates a new CLI logger. Specifically this: - adds CLI flags for configuring the logging system - instantiates a Logrus logger - returns a struct with CLI flags registered and ready to be parsed by flag.Parse

func (*LoggerConfig) ConfigureLogger

func (c *LoggerConfig) ConfigureLogger() error

ConfigureLogger configures logging from command line parameters.

func (*LoggerConfig) Connect

func (c *LoggerConfig) Connect(insecure bool, kp *keypair.KeyPair) error

Connect to a logpipe endpoint to accept logs remotely.

type Reader

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

Reader is a reader for the structured log bundles. A "log bundle" is a stream of bytes consisting of a length prefix in int32 form, a padding int32, and the protobuf marshaled out. This pattern repeats itself until EOF. The marshaled proto is expected to unmarshal into the log.Entry type (see message.proto).

Reading the bundle is an act of instantiating this struct with NewReader() and calling NextProto() on the result until io.EOF is returned.

func NewReader

func NewReader(filename string) (*Reader, error)

NewReader creates a reader.

func (*Reader) Close

func (r *Reader) Close() error

Close the file

func (*Reader) NextProto

func (r *Reader) NextProto() (*Entry, error)

NextProto finds the next protobuf in the bundle, if nil is returned, error will contain state which may be io.EOF -- indicating the file is finished.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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