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: 15 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 {
	AppEnv               string `toml:"app_env"`
	ProjectRoot          string `toml:"project_root_dir"`
	DownloadDir          string `toml:"download_dir"`
	GcpSourceDir         string `toml:"gcp_source_dir"`
	GcpSourceKeyFile     string `toml:"gcp_source_key_file"`
	GcpSourceProjectId   string `toml:"gcp_source_project_id"`
	GcpSinkDir           string `toml:"gcp_sink_dir"`
	GcpSinkKeyFile       string `toml:"gcp_sink_key_file"`
	GcpSinkProjectId     string `toml:"gcp_sink_project_id"`
	SourceBucketName     string `toml:"source_bucket_name"`
	SinkBucketName       string `toml:"sink_bucket_name"`
	ApiPort              string `toml:"api_port"`
	LogTimeTrack         bool   `toml:"log_timetrack"`
	LogFullStackTrace    bool   `toml:"log_full_stack_trace"`
	LogDebugInfo         bool   `toml:"log_debug_info"`
	LogDebugInfoForTests bool   `toml:"log_debug_info_for_tests"`
}
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