pkg

package
v0.0.0-...-e2f31ef Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GetEntriesFilter

type GetEntriesFilter struct {
	Level            string
	Session          string
	From             time.Time
	To               time.Time
	SelectedMetaKeys []string
	MetaFilters      map[string]interface{}
}

func NewGetEntriesFilter

func NewGetEntriesFilter(opts ...GetEntriesFilterOption) *GetEntriesFilter

func (*GetEntriesFilter) Apply

func (gef *GetEntriesFilter) Apply(metaKeys *MetaKeys, q *sqlbuilder.SelectBuilder)

type GetEntriesFilterOption

type GetEntriesFilterOption func(*GetEntriesFilter)

func WithFrom

func WithFrom(from time.Time) GetEntriesFilterOption

func WithLevel

func WithLevel(level string) GetEntriesFilterOption

func WithMetaFilters

func WithMetaFilters(filters map[string]interface{}) GetEntriesFilterOption

func WithSelectedMetaKeys

func WithSelectedMetaKeys(keys ...string) GetEntriesFilterOption

func WithSession

func WithSession(session string) GetEntriesFilterOption

func WithTo

func WithTo(to time.Time) GetEntriesFilterOption

type LogEntry

type LogEntry struct {
	ID      int       `db:"id"`
	Date    time.Time `db:"date"`
	Level   string    `db:"level"`
	Session string    `db:"session"`
	Meta    map[string]interface{}
}

type LogEntryMeta

type LogEntryMeta struct {
	ID         int          `db:"id"`
	LogEntryID int          `db:"log_entry_id"`
	Type       LogEntryType `db:"type"`
	Name       *string      `db:"name"`
	MetaKeyID  *int         `db:"meta_key_id"`
	IntValue   *int64       `db:"int_value"`
	RealValue  *float64     `db:"real_value"`
	TextValue  *string      `db:"text_value"`
	BlobValue  *[]byte      `db:"blob_value"`
	MetaKey    *string      `db:"meta_key"`
}

func (*LogEntryMeta) Value

func (lem *LogEntryMeta) Value() (interface{}, error)

type LogEntryType

type LogEntryType int

LogEntryType represents the different types LogEntries can have.

const (
	LogEntryTypeReal LogEntryType = iota
	LogEntryTypeText
	LogEntryTypeBlob
	LogEntryTypeJSON
)

func ToLogEntryType

func ToLogEntryType(v interface{}) LogEntryType

func (LogEntryType) String

func (t LogEntryType) String() string

type LogWriter

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

LogWriter is the main class in Plunger.

It deserializes the JSON binaries handed over by zerolog, and decomposes the message into the database schema specified at creation time.

func InitLogging

func InitLogging(config *LoggerConfig) (*LogWriter, *sqlx.DB, error)

func NewLogWriter

func NewLogWriter(db *sqlx.DB) *LogWriter

func (*LogWriter) Close

func (l *LogWriter) Close() error

func (*LogWriter) GetEntries

func (l *LogWriter) GetEntries(filter *GetEntriesFilter) ([]*LogEntry, error)

func (*LogWriter) Init

func (l *LogWriter) Init() error

func (*LogWriter) Write

func (l *LogWriter) Write(p []byte) (int, error)

type LoggerConfig

type LoggerConfig struct {
	WithCaller bool
	Level      string
	DBFile     string
	Schema     *Schema
}

type MetaKey

type MetaKey struct {
	Name string
	ID   int
}

MetaKey is used to store keys that are often used, to avoid storing them as full strings. Instead, we store them by id and use a lookup table to get the full string.

type MetaKeys

type MetaKeys struct {
	Keys map[string]*MetaKey
	// contains filtered or unexported fields
}

MetaKeys is a collection of MetaKey. It is used to quickly manage adding new keys.

func NewMetaKeys

func NewMetaKeys() *MetaKeys

func (*MetaKeys) Add

func (m *MetaKeys) Add(name string) *MetaKey

func (*MetaKeys) AddWithID

func (m *MetaKeys) AddWithID(name string, id int) (*MetaKey, error)

func (*MetaKeys) Get

func (m *MetaKeys) Get(name string) (*MetaKey, bool)

func (*MetaKeys) GetByID

func (m *MetaKeys) GetByID(id int) (*MetaKey, bool)

type MissingDBFileError

type MissingDBFileError struct {
}

func (*MissingDBFileError) Error

func (e *MissingDBFileError) Error() string

type Row

type Row struct {
	Name string
	Type LogEntryType
}

type Schema

type Schema struct {
	MetaKeys *MetaKeys
}

Schema is a set of MetaKeys

func NewSchema

func NewSchema() *Schema

Jump to

Keyboard shortcuts

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