Documentation ¶
Overview ¶
Package common contains definitions used throughout the application
Index ¶
- Constants
- Variables
- func ExpandTilde(path string) string
- func GetChecksum(data []byte) (string, error)
- func GetHomeDirectory() string
- func GetLogger(domain logdomain.ID) (*log.Logger, error)
- func GetLoggerStdout(domain logdomain.ID) (*log.Logger, error)
- func GetUUID() string
- func InitApp() error
- func SetBaseDir(path string) error
- func TimeEqual(t1, t2 time.Time) bool
Constants ¶
const ( AppName = "Ticker" Version = "0.17.1" 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" )
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 ¶
var AdvisorDir = filepath.Join(BaseDir, "advisor")
AdvisorDir is the path to the Shield advisor's databases.
var ArchiveDir = filepath.Join(BaseDir, "archive")
ArchiveDir is the folder where downloaded/archived pages are stored.
var BaseDir = filepath.Join( GetHomeDirectory(), fmt.Sprintf(".%s.d", strings.ToLower(AppName)))
BaseDir is the folder where all application-specific files are stored. It defaults to $HOME/.Kuang2.d
var CacheDir = filepath.Join(BaseDir, "cache")
CacheDir is the folder where prefetched images are stored.
var ClassifierDir = filepath.Join(BaseDir, "classifier")
ClassifierDir is the path to the Shield classifier's databases.
DbPath is the filename of the database.
var DoTrace = true
DoTrace causes the log level to be lowered to TRACE when set.
var Languages = []string{
"de",
"en",
}
Languages is the list of country codes for the languages we support.
At this time, this only refers to the Classifier, but who knows... one day we might support L10N in the user interface or something.
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.
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.
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 ExpandTilde ¶
ExpandTilde replaces a leading "~" in a path with the current user's home directory.
func GetChecksum ¶
GetChecksum computes the SHA512 checksum of the given data.
func GetHomeDirectory ¶
func GetHomeDirectory() string
GetHomeDirectory determines the user's home directory. The reason this is even a thing is that Unix-like systems store this path in the environment variable "HOME", whereas Windows uses the environment variable "USERPROFILE", Hence this function.
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 GetLoggerStdout ¶
GetLoggerStdout returns a Logger that will log to stdout AND the log file.
func InitApp ¶
func InitApp() error
InitApp performs some basic preparations for the application to run. Currently, this means creating the BaseDir folder.
func SetBaseDir ¶
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.
Types ¶
This section is empty.