Documentation ¶
Overview ¶
Package common provides constants, variables and functions used throughout the application.
Index ¶
Constants ¶
const ( Debug = true Version = "0.3.1" AppName = "uptimed" 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 Interval = time.Second * 120 )
Debug indicates 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.
const EncJSON = "application/json"
EncJSON is the MIME type used for JSON payloads.
const MinLogLevel = "INFO"
MinLogLevel is the mininum log level all loggers forward.
Variables ¶
var ( BaseDir = filepath.Join(os.Getenv("HOME"), "uptimed.d") LogPath = filepath.Join(BaseDir, "uptimed.log") DbPath = filepath.Join(BaseDir, "uptimed.db") BufferPath = filepath.Join(BaseDir, "offline") WebPort int64 = 1337 )
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. WebPort is the TCP port the server listens on.
var LogLevels = []logutils.LogLevel{
"TRACE",
"DEBUG",
"INFO",
"WARN",
"ERROR",
"CRITICAL",
"CANTHAPPEN",
"SILENT",
}
LogLevels are the names of the log levels supported by the logger.
PackageLevels defines minimum log levels per package.
var SuffixPattern = regexp.MustCompile("([.][^.]+)$")
SuffixPattern is a regular expression that matches the suffix of a file name. For "text.txt", it should match ".txt" and capture "txt".
Functions ¶
func GetChecksum ¶
GetChecksum computes the SHA512 checksum of the given data.
func GetLogger ¶
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 InitApp ¶
func InitApp() error
InitApp performs some basic preparations for the application to run. Currently, this means creating the BASE_DIR folder.
func SetBaseDir ¶
SetBaseDir sets the BaseDir and related variables.