common

package
v0.0.0-...-f84254b Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2022 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package common provides constants, variables and functions used throughout the application.

Index

Constants

View Source
const (
	Debug                    = true
	Version                  = "0.4.0"
	AppName                  = "Guang"
	TimestampFormat          = "2006-01-02 15:04:05"
	TimestampFormatMinute    = "2006-01-02 15:04"
	TimestampFormatSubSecond = "2006-01-02 15:04:05.0000 MST"
	TimestampFormatDate      = "2006-01-02"
	HeartBeat                = time.Millisecond * 500
	RCTimeout                = time.Millisecond * 10
)

Debug indicated whether to emit additional log messages and perform additional sanity checks. Version is the version number to display. AppName is the name of the application. TimestampFormat is the format string used to render datetime values. HeartBeat is the interval for worker goroutines to wake up and check their status.

View Source
const MinLogLevel = "TRACE"

Variables

View Source
var (
	BaseDir       = filepath.Join(os.Getenv("HOME"), "guang.d")
	LogPath       = filepath.Join(BaseDir, "guang.log")
	DbPath        = filepath.Join(BaseDir, "guang.db")
	HostCachePath = filepath.Join(BaseDir, "ip_cache")
	XfrDbgPath    = filepath.Join(BaseDir, "xfr")
)

BaseDir is the folder where all application-specific files (database, log files, etc) are stored. LogPath is the file to the log path. DbPath is the path of the main database. HostCachePath is the path to the IP cache. XfrDbgPath is the path of the folder where data on DNS zone transfers are stored.

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.

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(name string) (*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 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 BASE_DIR folder.

func SetBaseDir

func SetBaseDir(path string)

SetBaseDir sets the BaseDir and related variables.

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