common

package
v0.0.0-...-23e2505 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2023 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package common contains definitions used throughout the application

Index

Constants

View Source
const (
	AppName                  = "Blockbuster"
	Version                  = "0.0.5"
	Debug                    = true
	TimestampFormatMinute    = "2006-01-02 15:04"
	TimestampFormat          = "2006-01-02 15:04:05"
	TimestampFormatSubSecond = "2006-01-02 15:04:05.0000 MST"
	TimestampFormatDate      = "2006-01-02"
	TimestampFormatTime      = "15:04:05"
)

AppName is the name under which the application identifies itself. Version is the version number. Debug, if true, causes the application to log additional messages and perform additional sanity checks. TimestampFormat is the default format for timestamp used throughout the application.

Variables

BaseDir is the folder where all application-specific files are stored. It defaults to $HOME/.Kuang2.d

DbPath is the filename of the database.

View Source
var DoTrace = true

DoTrace causes the log level to be lowered to TRACE when set.

View Source
var LogLevels = []logutils.LogLevel{
	"TRACE",
	"DEBUG",
	"INFO",
	"WARN",
	"ERROR",
	"CRITICAL",
	"CANTHAPPEN",
	"SILENT",
}

LogLevels are the names of the log levels supported by the logger.

LogPath is the filename of the log file.

View Source
var MinLogLevel logutils.LogLevel = "TRACE"

MinLogLevel is the minimum level a log message must have to be written out to the log. This value is configurable to reduce log verbosity in regular use.

View Source
var PackageLevels = make(map[logdomain.ID]logutils.LogLevel, len(LogLevels))

PackageLevels defines minimum log levels per package.

Functions

func GetChecksum

func GetChecksum(data []byte) (string, error)

GetChecksum computes the SHA512 checksum of the given data.

func GetLogger

func GetLogger(domain logdomain.ID) (*log.Logger, error)

GetLogger tries to create a named logger instance and return it. If the directory to hold the log file does not exist, try to create it.

func GetLoggerStdout

func GetLoggerStdout(domain logdomain.ID) (*log.Logger, error)

GetLoggerStdout returns a Logger that will log to stdout AND the log file.

func GetUUID

func GetUUID() string

GetUUID returns a randomized UUID

func InitApp

func InitApp() error

InitApp performs some basic preparations for the application to run. Currently, this means creating the BaseDir folder.

func SetBaseDir

func SetBaseDir(path string) error

SetBaseDir sets the application's base directory. This should only be done during initialization. Once the log file and the database are opened, this is useless at best and opens a world of confusion at worst, so this function should only be called at the very beginning of the program.

func TimeEqual

func TimeEqual(t1, t2 time.Time) bool

TimeEqual returns true if the two timestamps are less than one second apart.

Types

This section is empty.

Jump to

Keyboard shortcuts

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