utils

package
v0.0.0-...-c3bd378 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2022 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorActionErr = iota
	ErrorActionWarn
	ErrorActionDebug
	ErrorActionInfo
)
View Source
const BasicTimeStampFormat = "2006-01-02 15:04:05"

Variables

View Source
var (
	Debug        *log.Logger
	Info         *log.Logger
	Error        *log.Logger
	InfoHandler  io.Writer
	ErrorHandler io.Writer
)
View Source
var LevelDescriptions = []string{"PANC", "FATL", "ERRO", "WARN", "INFO", "DEBG"}

Functions

func FromLineOfFile

func FromLineOfFile() string

HandlePanic _Never_ returns on error, instead it panics

func GetOptions

func GetOptions() bool

func HandleError

func HandleError(err error, action int) bool

func HandlePanic

func HandlePanic(err error)

HandlePanic _Never_ returns an error, instead it panics

func InSlice

func InSlice(slice []string, searchFor string) (found bool)

func InitLog

func InitLog(
	traceFileName string,
	debugHandler io.Writer,
	infoHandler io.Writer,
	errorHandler io.Writer,
)

func PadRight

func PadRight(str string, padWith string, length int) string

pad str with padWith count times to right

func UpdateConfigVal

func UpdateConfigVal(d Datastore, key, val string) (oldValue string)

UpdateConfigVal returns string representation of old config value

func WriteFile

func WriteFile(filename string, source io.Reader) error

Types

type APIError

type APIError struct {
	ErrorMessage string `json:"error_message"`
	HTTPStatus   int    `json:"http_status"`
}

type BasicFormatter

type BasicFormatter struct {
	TimestampFormat string
	LevelDesc       []string
}

func (*BasicFormatter) Format

func (f *BasicFormatter) Format(entry *log.Entry) ([]byte, error)

type Conf

type Conf struct {
	Port                     string `toml:"port"`
	LogDebugInfo             bool   `toml:"log_debug_info"`
	MaxConcurrentConnections int    `toml:"max_concurrent_connections"`
	MaxNumber                int    `toml:"max_number"`
	UseNumberHandler         bool   `toml:"use_number_handler"`
}
var Config Conf

type Datastore

type Datastore interface{}

type HttpErrorHandler

type HttpErrorHandler struct {
	Caller   string
	Response http.ResponseWriter
	Request  *http.Request
}

func NewHttpErrorHandle

func NewHttpErrorHandle(caller string, response http.ResponseWriter, request *http.Request) *HttpErrorHandler

func (*HttpErrorHandler) Handle

func (h *HttpErrorHandler) Handle(err error, httpStatus int, action int) bool

HandleError locally, according to the action passed to h.Handle, and then serialized in json and sent to the remote address via http, then returns true. Otherwise, if there is no error, h.Handle returns false

type PlainFormatter

type PlainFormatter struct{}

func (*PlainFormatter) Format

func (f *PlainFormatter) Format(entry *log.Entry) ([]byte, error)

type PlusVFormatter

type PlusVFormatter struct {
	TimestampFormat string
	LevelDesc       []string
	FullTimestamp   bool
}

func (*PlusVFormatter) Format

func (f *PlusVFormatter) Format(entry *log.Entry) ([]byte, error)

Jump to

Keyboard shortcuts

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