logger

package
v0.0.0-...-fab78a3 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2025 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ParseFailedIDs            = "parse failed ids"
	FilterByID                = "id = ?"
	StrRefreshMovies          = "Refresh Movies"
	StrRefreshMoviesInc       = "Refresh Movies Incremental"
	StrRefreshSeries          = "Refresh Series"
	StrRefreshSeriesInc       = "Refresh Series Incremental"
	StrDebug                  = "debug"
	StrDate                   = "date"
	StrSearchMissingInc       = "searchmissinginc"
	StrSearchMissingFull      = "searchmissingfull"
	StrSearchMissingIncTitle  = "searchmissinginctitle"
	StrSearchMissingFullTitle = "searchmissingfulltitle"
	StrSearchUpgradeInc       = "searchupgradeinc"
	StrSearchUpgradeFull      = "searchupgradefull"
	StrSearchUpgradeIncTitle  = "searchupgradeinctitle"
	StrSearchUpgradeFullTitle = "searchupgradefulltitle"
	StrCheckMissing           = "checkmissing"
	StrCheckMissingFlag       = "checkmissingflag"
	StrUpgradeFlag            = "checkupgradeflag"
	StrReachedFlag            = "checkreachedflag"
	StrClearHistory           = "clearhistory"
	StrRssSeasonsAll          = "rssseasonsall"
	StrSerie                  = "serie"
	StrRssSeasons             = "rssseasons"
	StrRss                    = "rss"
	Underscore                = "_"
	StrTt                     = "tt"
	CacheDBMedia              = "CacheDBMedia"
	DBCountDBMedia            = "DBCountDBMedia"
	DBCacheDBMedia            = "DBCacheDBMedia"
	CacheMedia                = "CacheMedia"
	DBCountMedia              = "DBCountMedia"
	DBCacheMedia              = "DBCacheMedia"
	CacheHistoryTitle         = "CacheHistoryTitle"
	CacheHistoryURL           = "CacheHistoryUrl"
	DBHistoriesURL            = "DBHistoriesUrl"
	DBHistoriesTitle          = "DBHistoriesTitle"
	DBCountHistoriesURL       = "DBCountHistoriesUrl"
	DBCountHistoriesTitle     = "DBCountHistoriesTitle"
	CacheMediaTitles          = "CacheMediaTitles"
	DBCountDBTitles           = "DBCountDBTitles"
	DBCacheDBTitles           = "DBCacheDBTitles"
	CacheFiles                = "CacheFiles"
	DBCountFiles              = "DBCountFiles"
	DBCacheFiles              = "DBCacheFiles"
	CacheUnmatched            = "CacheUnmatched"
	DBCountUnmatched          = "DBCountUnmatched"
	DBCacheUnmatched          = "DBCacheUnmatched"
	DBCountFilesLocation      = "DBCountFilesLocation"
	DBCountUnmatchedPath      = "DBCountUnmatchedPath"
	DBCountDBTitlesDBID       = "DBCountDBTitlesDBID"
	DBDistinctDBTitlesDBID    = "DBDistinctDBTitlesDBID"
	DBMediaTitlesID           = "DBMediaTitlesID"
	DBFilesQuality            = "DBFilesQuality"
	DBCountFilesByList        = "DBCountFilesByList"
	DBLocationFilesByList     = "DBLocationFilesByList"
	DBIDsFilesByLocation      = "DBIDsFilesByLocation"
	DBCountFilesByMediaID     = "DBCountFilesByMediaID"
	DBCountFilesByLocation    = "DBCountFilesByLocation"
	TableFiles                = "TableFiles"
	TableMedia                = "TableMedia"
	DBCountMediaByList        = "DBCountMediaByList"
	DBIDMissingMediaByList    = "DBIDMissingMediaByList"
	DBUpdateMissing           = "DBUpdateMissing"
	DBListnameByMediaID       = "DBListnameByMediaID"
	DBRootPathFromMediaID     = "DBRootPathFromMediaID"
	DBDeleteFileByIDLocation  = "DBDeleteFileByIDLocation"
	DBCountHistoriesByTitle   = "DBCountHistoriesByTitle"
	DBCountHistoriesByURL     = "DBCountHistoriesByUrl"
	DBLocationIDFilesByID     = "DBLocationIDFilesByID"
	DBFilePrioFilesByID       = "DBFilePrioFilesByID"
	UpdateMediaLastscan       = "UpdateMediaLastscan"
	DBQualityMediaByID        = "DBQualityMediaByID"
	SearchGenSelect           = "SearchGenSelect"
	SearchGenTable            = "SearchGenTable"
	SearchGenMissing          = "SearchGenMissing"
	SearchGenMissingEnd       = "SearchGenMissingEnd"
	SearchGenReached          = "SearchGenReached"
	SearchGenLastScan         = "SearchGenLastScan"
	SearchGenDate             = "SearchGenDate"
	SearchGenOrder            = "SearchGenOrder"
	CacheMovie                = "CacheMovie"
	CacheSeries               = "CacheSeries"
	CacheDBMovie              = "CacheDBMovie"
	CacheDBSeries             = "CacheDBSeries"
	CacheDBSeriesAlt          = "CacheDBSeriesAlt"
	CacheTitlesMovie          = "CacheTitlesMovie"
	CacheUnmatchedMovie       = "CacheUnmatchedMovie"
	CacheUnmatchedSeries      = "CacheUnmatchedSeries"
	CacheFilesMovie           = "CacheFilesMovie"
	CacheFilesSeries          = "CacheFilesSeries"
	CacheHistoryURLMovie      = "CacheHistoryUrlMovie"
	CacheHistoryTitleMovie    = "CacheHistoryTitleMovie"
	CacheHistoryURLSeries     = "CacheHistoryUrlSeries"
	CacheHistoryTitleSeries   = "CacheHistoryTitleSeries"
	DBIDUnmatchedPathList     = "DBIDUnmatchedPathList"
	DBMovieDetails            = "" /* 329-byte string literal not displayed */

	Strstructure = "structure"
	StrStatus    = "status"
	StrRow       = "row"
	StrDot       = "."
	StrDash      = "-"
	StrSpace     = " "
	StrIndexer   = "indexer"
	StrSize      = "Size"
)

Variables

View Source
var (
	StrFeeds                 = "feeds"
	StrDataFull              = "datafull"
	StrStructure             = "structure"
	V0                       = 0
	StrMovie                 = "movie"
	StrSeries                = "series"
	StrID                    = "id"
	StrWaitfor               = "waitfor"
	StrURL                   = "Url"
	StrImdb                  = "imdb"
	StrFound                 = "found"
	StrWanted                = "wanted"
	StrTitle                 = "Title"
	StrAccepted              = "accepted"
	StrDenied                = "denied"
	StrJob                   = "Job"
	StrPath                  = "Path"
	StrFile                  = "File"
	StrListname              = "Listname"
	StrData                  = "data"
	StrTvdb                  = "tvdb"
	StrSeason                = "season"
	StrConfig                = "config"
	StrReason                = "reason"
	StrPriority              = "Priority"
	StrMinPrio               = "minimum prio"
	StrQuality               = "Quality"
	ArrHTMLEntitys           = []string{"&AElig", "&AMP", "&Aacute", "&Acirc", "&Agrave", "&Aring", "&Atilde", "&Auml", "&COPY", "&Ccedil", "&ETH", "&Eacute", "&Ecirc", "&Egrave", "&Euml", "&GT", "&Iacute", "&Icirc", "&Igrave", "&Iuml", "&LT", "&Ntilde", "&Oacute", "&Ocirc", "&Ograve", "&Oslash", "&Otilde", "&Ouml", "&QUOT", "&REG", "&THORN", "&Uacute", "&Ucirc", "&Ugrave", "&Uuml", "&Yacute", "&aacute", "&acirc", "&acute", "&aelig", "&agrave", "&amp", "&aring", "&atilde", "&auml", "&brvbar", "&ccedil", "&cedil", "&cent", "&copy", "&curren", "&deg", "&divide", "&eacute", "&ecirc", "&egrave", "&eth", "&euml", "&gt", "&iacute", "&icirc", "&iexcl", "&igrave", "&iquest", "&iuml", "&laquo", "&lt", "&macr", "&micro", "&middot", "&nbsp", "&not", "&ntilde", "&oacute", "&ocirc", "&ograve", "&ordf", "&ordm", "&oslash", "&otilde", "&ouml", "&para", "&plusmn", "&pound", "&quot", "&raquo", "&reg", "&sect", "&shy", "&szlig", "&thorn", "&times", "&uacute", "&ucirc", "&ugrave", "&uml", "&uuml", "&yacute", "&yen", "&yuml"}
	ErrNoID                  = errors.New("no id")
	ErrNotFound              = errors.New("not found")
	ErrNotAllowed            = errors.New("not allowed")
	ErrDisabled              = errors.New("disabled")
	ErrToWait                = errors.New("please wait")
	ErrContextCanceled       = errors.New("context canceled")
	Errnoresults             = errors.New("no results")
	ErrNotFoundDbmovie       = errors.New("dbmovie not found")
	ErrNotFoundMovie         = errors.New("movie not found")
	ErrNotFoundDbserie       = errors.New("dbserie not found")
	ErrCfgpNotFound          = errors.New("cfgpstr not found")
	ErrNotFoundEpisode       = errors.New("episode not found")
	ErrListnameEmpty         = errors.New("listname empty")
	ErrListnameTemplateEmpty = errors.New("listname template empty")
	ErrTvdbEmpty             = errors.New("tvdb empty")
	ErrImdbEmpty             = errors.New("imdb empty")
	ErrTracksEmpty           = errors.New("tracks empty")
	PlAddBuffer              pool.Poolobj[AddBuffer]
	PlBuffer                 pool.Poolobj[bytes.Buffer]
	PLArrAny                 pool.Poolobj[Arrany]
)

global vars.

Functions

func AddImdbPrefixP

func AddImdbPrefixP(str string) string

AddImdbPrefixP adds the "tt" prefix to the given string if it doesn't already have the prefix. If the string is nil or has a length less than 1, this function does nothing.

func BytesToString

func BytesToString(b []byte) string

func CheckContextEnded

func CheckContextEnded(ctx context.Context) error

CheckContextEnded checks if the provided context has been canceled or has expired. If the context has been canceled or has expired, it returns the context's error. Otherwise, it returns nil.

func Checkhtmlentities

func Checkhtmlentities(instr string) string

Checkhtmlentities checks if the input string contains HTML entities, and if so, unescapes the entities using html.UnescapeString. If the input string does not contain any HTML entities, it is returned as-is.

func ContainsByteI

func ContainsByteI(a, b []byte) bool

ContainsByteI checks if the byte slice a contains the byte slice b, ignoring case. It first checks for a direct match using bytes.Contains. If not found, it does a case-insensitive search by converting both a and b to lowercase and then checking if the lowercase a contains the lowercase b.

func ContainsI

func ContainsI(a, b string) bool

ContainsI checks if string a contains string b, ignoring case. It first checks for a direct match with strings.Contains. If not found, it does a case-insensitive search by looping through a and comparing substrings with EqualFold.

func ContainsInt

func ContainsInt(a string, b uint16) bool

ContainsInt checks if the string a contains the string representation of the integer b. It converts b to a string using strconv.Itoa and calls strings.Contains to check for a match.

func GetStringsMap

func GetStringsMap(useseries bool, typestr string) string

GetStringsMap returns the map of strings for the given type based on whether to use the series or movies map. If useseries is true, it returns the mapstringsseries map, otherwise it returns the mapstringsmovies map.

func GetTimeFormat

func GetTimeFormat() string

GetTimeFormat returns the time format string used for formatting logs. This allows checking the current time format.

func GetTimeZone

func GetTimeZone() *time.Location

GetTimeZone returns a pointer to the time.Location representing the timezone used for formatting logs. This allows checking the current timezone.

func HandlePanic

func HandlePanic()

HandlePanic recovers from a panic and logs the recovered value along with the stack trace.

func HasPrefixI

func HasPrefixI(s, prefix string) bool

HasPrefixI checks if string s starts with prefix, ignoring case. It first checks for a direct match with strings.HasPrefix. If not found, it does a case-insensitive check by comparing the substring of s from 0 to len(prefix) with prefix using EqualFold.

func HasSuffixI

func HasSuffixI(s, suffix string) bool

HasSuffixI checks if string s ends with suffix, ignoring case. It first checks for a direct match with strings.HasSuffix. If not found, it does a case-insensitive check by comparing the substring of s from len(s)-len(suffix) to len(s) with suffix using EqualFold.

func IndexI

func IndexI(a, b string) int

IndexI searches for the first case-insensitive instance of b in a. It returns the index of the first match, or -1 if no match is found.

func InitLogger

func InitLogger(config Config)

InitLogger initializes the global logger based on the provided Config. It sets the log level, output format, rotation options, etc.

func Int64ToUint

func Int64ToUint(in int64) uint

IntToUint converts an int64 to a uint, returning 0 if the input is negative.

func IntToString

func IntToString(a uint16) string

IntToString converts any numeric type to a string. It handles all integer types, including signed and unsigned.

func IntToUint

func IntToUint(in int) uint

IntToUint converts an int to a uint, returning 0 if the input is negative.

func JoinStrings

func JoinStrings(elems ...string) string

JoinStrings concatenates any number of strings together. It is optimized to avoid unnecessary allocations when there are few elements.

func JoinStringsSep

func JoinStringsSep(elems []string, sep string) string

JoinStringsSep concatenates the elements of the provided slice of strings into a single string, separated by the provided separator string. It is optimized to avoid unnecessary allocations when there are few elements.

func LogDynamicany

func LogDynamicany(typev, msg string, fields ...any)

LogDynamicany logs a message with dynamic fields. The 'typev' parameter specifies the log level (info, debug, error, fatal, warn, panic). The 'msg' parameter is the log message. The 'fields' parameter is a variadic list of key-value pairs to be logged.

func LogDynamicany0

func LogDynamicany0(typev, msg string)

LogDynamicany0 logs a message with no dynamic fields. The 'typev' parameter specifies the log level (info, debug, error, fatal, warn, panic). The 'msg' parameter is the log message.

func LogDynamicany1Int

func LogDynamicany1Int(typev, msg, field1 string, value1 int)

LogDynamicany1Int logs a message with a dynamic int field. The 'typev' parameter specifies the log level (info, debug, error, fatal, warn, panic). The 'msg' parameter is the log message. The 'field1' parameter is the field name for the dynamic int field. The 'value1' parameter is the value for the dynamic int field.

func LogDynamicany1IntErr

func LogDynamicany1IntErr(typev, msg string, err error, field1 string, value1 int)

LogDynamicany1IntErr logs a message with a dynamic int field and an error. The 'typev' parameter specifies the log level (info, debug, error, fatal, warn, panic). The 'msg' parameter is the log message. The 'err' parameter is the error to be logged. The 'field1' parameter is the field name for the dynamic int field. The 'value1' parameter is the value for the dynamic int field.

func LogDynamicany1String

func LogDynamicany1String(typev, msg, field1, value1 string)

LogDynamicany1String logs a message with a dynamic string field. The 'typev' parameter specifies the log level (info, debug, error, fatal, warn, panic). The 'msg' parameter is the log message. The 'field1' parameter is the field name for the dynamic string field. The 'value1' parameter is the value for the dynamic string field.

func LogDynamicany1StringErr

func LogDynamicany1StringErr(typev, msg string, err error, field1, value1 string)

LogDynamicany1StringErr logs a message with a dynamic string field and an error. The 'typev' parameter specifies the log level (info, debug, error, fatal, warn, panic). The 'msg' parameter is the log message. The 'err' parameter is the error to be logged. The 'field1' parameter is the field name for the dynamic string field. The 'value1' parameter is the value for the dynamic string field.

func LogDynamicany1UInt

func LogDynamicany1UInt(typev, msg, field1 string, value1 uint)

LogDynamicany1UInt logs a message with a dynamic uint field. The 'typev' parameter specifies the log level (info, debug, error, fatal, warn, panic). The 'msg' parameter is the log message. The 'field1' parameter is the field name for the dynamic uint field. The 'value1' parameter is the value for the dynamic uint field.

func LogDynamicany1UIntErr

func LogDynamicany1UIntErr(typev, msg string, err error, field1 string, value1 uint)

LogDynamicany1UIntErr logs a message with a dynamic uint field and an error. The 'typev' parameter specifies the log level (info, debug, error, fatal, warn, panic). The 'msg' parameter is the log message. The 'err' parameter is the error to be logged. The 'field1' parameter is the field name for the dynamic uint field. The 'value1' parameter is the value for the dynamic uint field.

func LogDynamicany2Int

func LogDynamicany2Int(typev, msg, field1 string, value1 int, field2 string, value2 int)

LogDynamicany2Int logs a message with two dynamic integer fields. The 'typev' parameter specifies the log level (info, debug, error, fatal, warn, panic). The 'msg' parameter is the log message. The 'field1' and 'field2' parameters are the field names for the dynamic integer fields. The 'value1' and 'value2' parameters are the values for the dynamic integer fields.

func LogDynamicany2Str

func LogDynamicany2Str(typev, msg, field1, value1, field2, value2 string)

LogDynamicany2Str logs a message with two dynamic string fields. The 'typev' parameter specifies the log level (info, debug, error, fatal, warn, panic). The 'msg' parameter is the log message. The 'field1' and 'field2' parameters are the field names for the dynamic string fields. The 'value1' and 'value2' parameters are the values for the dynamic string fields.

func LogDynamicany2StrAny

func LogDynamicany2StrAny(typev, msg, field1, value1, field2 string, value2 any)

LogDynamicany2StrAny logs a message with two dynamic fields: a string and any type. The 'typev' parameter specifies the log level (info, debug, error, fatal, warn, panic). The 'msg' parameter is the log message. The 'field1' and 'field2' parameters are the field names for the dynamic fields. The 'value1' parameter is the value for the string field. The 'value2' parameter is the value for the any type field.

func LogDynamicany3StrIntInt

func LogDynamicany3StrIntInt(typev, msg, field1 string, value1 string, field2 string, value2 int, field3 string, value3 int)

LogDynamicany3StrIntInt logs a message with three dynamic fields: a string, an integer, and another integer. The 'typev' parameter specifies the log level (info, debug, error, fatal, warn, panic). The 'msg' parameter is the log message. The 'field1', 'field2', and 'field3' parameters are the field names for the dynamic fields. The 'value1', 'value2', and 'value3' parameters are the values for the dynamic fields.

func LogDynamicanyErr

func LogDynamicanyErr(typev, msg string, err error)

LogDynamicanyErr logs a message with an error. The 'typev' parameter specifies the log level (info, debug, error, fatal, warn, panic). The 'msg' parameter is the log message. The 'err' parameter is the error to be logged.

func Logtype

func Logtype(typev string, skip int) *zerolog.Event

Logtype returns a zerolog.Event with the specified log level. If the log level is not recognized, it defaults to log.Info(). The 'skip' parameter specifies the number of stack frames to skip when determining the caller location for the log event.

func ParseStringTemplate

func ParseStringTemplate(message string, messagedata any) (bool, string)

ParseStringTemplate parses a text/template string into a template.Template, caches it, and executes it with the given data. It returns the executed template string and any error encountered.

func Path

func Path(s *string, allowslash bool)

Path sanitizes the given string by cleaning it with path.Clean, unquoting and unescaping it, optionally removing slashes, and replacing invalid characters. It returns the cleaned path string.

func SlicesContainsI

func SlicesContainsI(s []string, v string) bool

Contains reports whether v is present in s - case insensitive.

func SlicesContainsPart2I

func SlicesContainsPart2I(s []string, v string) bool

Contains reports whether s is contained in v - case insensitive.

func SplitByLR

func SplitByLR(str string, splitby byte) (string, string)

SplitByLR splits str into left and right substrings by the last occurrence of splitby byte. It returns the left substring before the split byte and the right substring after. If splitby byte is not found or invalid, an empty string and the original str are returned.

func Stack

func Stack() string

func StringRemoveAllRunesP

func StringRemoveAllRunesP(s *string, r ...byte)

StringRemoveAllRunesP removes all occurrences of the given runes from the string pointed to by s. It modifies the string in-place. If s is nil or an empty string, or if the slice of runes r is empty, this function does nothing. If the slice of runes r contains only one rune and that rune is not present in the string, this function does nothing. If the slice of runes r contains more than one rune and none of them are present in the string, this function does nothing. Otherwise, this function creates a new buffer, writes all the characters from the string that are not in the slice of runes r, and updates the string pointed to by s with the new content.

func StringReplaceWith

func StringReplaceWith(s string, r, t byte) string

StringReplaceWith replaces all occurrences of the byte r in s with the byte t. It returns a new string with the replacements.

func StringReplaceWithP

func StringReplaceWithP(s *string, r, t byte)

StringReplaceWithP replaces all occurrences of the rune r in the given string pointer s with the rune t. It modifies the string in-place.

func StringReplaceWithStr

func StringReplaceWithStr(s, r, t string) string

StringReplaceWithStr replaces all occurrences of the string r in s with the string t. It returns a new string with the replacements.

func StringToDuration

func StringToDuration(s string) time.Duration

StringToDuration converts the given string to a time.Duration. It first tries to parse the string as a float and then cast it to time.Duration. If that fails, it tries to parse the string directly as an int and then cast it to time.Duration. If both attempts fail, it returns 0.

func StringToFileMode

func StringToFileMode(s string) fs.FileMode

StringToFileMode converts a string representing a file mode in octal to a uint32. It returns 0 if the string is empty or cannot be parsed.

func StringToInt

func StringToInt(s string) int

StringToInt converts the given string to an int. It uses stringToUint64 to convert to a uint64 first, then converts the result to an int.

func StringToInt32

func StringToInt32(s string) int32

StringToInt32 converts the given string to an int32. It first tries to parse the string as a float and then cast it to int32. If that fails, it tries to parse the string directly as an int32. If both attempts fail, it returns 0.

func StringToInt64

func StringToInt64(s string) int64

StringToInt64 converts the given string to an int64. It uses stringToUint64 to convert to a uint64 first, then converts the result to an int64.

func StringToSlug

func StringToSlug(instr string) string

StringToSlug converts the given string to a slug format by replacing unwanted characters, transliterating accented characters, replacing multiple hyphens with a single hyphen, and trimming leading/trailing hyphens.

func StringToSlugBytes

func StringToSlugBytes(instr string) []byte

StringToSlug converts the given string to a slug format by replacing unwanted characters, transliterating accented characters, replacing multiple hyphens with a single hyphen, and trimming leading/trailing hyphens.

func StringToUInt16

func StringToUInt16(s string) uint16

StringToUInt16 converts a string to a uint16 value. It does this by first converting the string to an int64 using StringToInt, and then casting the result to a uint16.

func TimeAfter

func TimeAfter(a, b time.Time) bool

TimeAfter returns true if the time a is after the time b. If the Unix timestamps of a and b are equal, it compares the nanosecond parts of the times to determine the order.

func TimeGetNow

func TimeGetNow() time.Time

TimeGetNow returns the current time in the time zone specified by the global timeZone variable.

func Trim

func Trim(s string, cutset ...rune) string

Trim returns a slice of the string s, with all leading and trailing Unicode code points contained in cutset removed. If s is empty or cutset is empty, Trim returns s.

func TrimLeft

func TrimLeft(s string, cutset ...rune) string

TrimLeft returns a slice of the string s, with all leading Unicode code points contained in cutset removed. If s is empty or cutset is empty, TrimLeft returns s.

func TrimRight

func TrimRight(s string, cutset ...rune) string

TrimRight returns a slice of the string s, with all trailing Unicode code points contained in cutset removed.

func TrimSpace

func TrimSpace(s string) string

TrimSpace returns a slice of the string s, with all leading and trailing Unicode code points that are considered whitespace removed. If s is empty, TrimSpace returns s.

func TryTimeParse

func TryTimeParse(layout string, s string) (time.Time, bool)

TryTimeParse attempts to parse the given string `s` using the provided time layout `layout`. It returns the parsed time.Time value and a boolean indicating whether the parsing was successful.

func UnquoteUnescape

func UnquoteUnescape(s string) string

UnquoteUnescape unquotes a quoted string and unescapes HTML entities. It first tries to unquote the string as a quoted string literal. If that succeeds and the unquoted string contains HTML entities, it unescapes the HTML entities. If unquoting fails, it just unescapes any HTML entities in the original string.

Types

type AddBuffer

type AddBuffer struct {
	bytes.Buffer
}

func (*AddBuffer) WriteInt

func (b *AddBuffer) WriteInt(i int)

WriteInt writes the string representation of the given integer i to the buffer.

func (*AddBuffer) WriteStringMap

func (b *AddBuffer) WriteStringMap(useseries bool, typestr string)

WriteStringMap writes a string to the buffer based on the provided boolean and string parameters. If useseries is true, it writes the value from the Mapstringsseries map using the typestr key. If useseries is false, it writes the value from the Mapstringsmovies map using the typestr key.

func (*AddBuffer) WriteUInt

func (b *AddBuffer) WriteUInt(i uint)

WriteUInt writes the string representation of the given unsigned integer to the buffer.

func (*AddBuffer) WriteUInt16

func (b *AddBuffer) WriteUInt16(i uint16)

WriteUInt16 writes the given uint16 value to the buffer as a string.

func (*AddBuffer) WriteURL

func (b *AddBuffer) WriteURL(s string)

WriteURL writes the given string to the buffer after escaping it for use in a URL.

type Arrany

type Arrany struct {
	Arr []any
}

type Config

type Config struct {
	// LogLevel sets the minimum enabled logging level. Valid levels are
	// "debug", "info", "warn", and "error".
	LogLevel string

	// LogFileSize is the maximum size in megabytes of the log file before it gets
	// rotated. It defaults to 10 megabytes.
	LogFileSize int

	// LogFileCount is the maximum number of old log files to retain.
	// The default is 5.
	LogFileCount uint8

	// LogCompress determines if the rotated log files should be compressed
	// using gzip. The default is false.
	LogCompress bool

	// LogColorize enables output with colors
	LogColorize bool

	// TimeFormat sets the format for timestamp in logs. Valid formats are
	// "rfc3339", "iso8601", etc. The default is RFC3339.
	TimeFormat string

	// TimeZone sets the time zone to use for timestamps in logs.
	// The default is to use the local time zone.
	TimeZone string

	// LogToFileOnly disables logging to stdout.
	// If true, logs will only be written to the file and not also stdout.
	LogToFileOnly bool

	LogZeroValues bool
}

Config defines the configuration options for the logger.

type SyncMap

type SyncMap[T any] struct {
	// contains filtered or unexported fields
}

func NewSyncMap

func NewSyncMap[T any](size int) *SyncMap[T]

NewSyncMap creates a new SyncMap with the specified initial size. The SyncMap is a thread-safe map that stores key-value pairs along with additional metadata such as expiration time, IMDB flag, and last scan time. The initial size of the underlying maps is set to the provided size parameter.

func (*SyncMap[T]) Add

func (s *SyncMap[T]) Add(key string, value T, expires int64, imdb bool, lastscan int64)

Add adds a new key-value pair to the SyncMap, along with its expiration time, IMDB flag, and last scan time. The method acquires a write lock on the SyncMap before adding the new entry, and releases the lock before returning.

func (*SyncMap[T]) Check

func (s *SyncMap[T]) Check(key string) bool

Check returns true if the given key exists in the SyncMap, false otherwise. The method acquires a read lock on the SyncMap before checking for the key, and releases the lock before returning.

func (*SyncMap[T]) CheckExpires

func (s *SyncMap[T]) CheckExpires(key string, extend bool, dur int) bool

CheckExpires checks if the given key in the SyncMap has expired. If the key has expired and extend is false, it logs a warning and returns true. If extend is true, it updates the expiration time of the key by adding the given duration (in hours) to the current time. If the key does not exist or has not expired, it returns false.

func (*SyncMap[T]) Delete

func (s *SyncMap[T]) Delete(key string)

Delete removes the given key from the SyncMap, including its associated value, expiration time, last scan time, and IMDB flag. This is an internal helper function and is not part of the public API.

func (*SyncMap[T]) DeleteFunc

func (s *SyncMap[T]) DeleteFunc(fn func(T) bool)

DeleteFunc deletes all entries in the SyncMap for which the provided function returns true, using the value as the argument.

func (*SyncMap[T]) DeleteFuncExpires

func (s *SyncMap[T]) DeleteFuncExpires(fn func(int64) bool)

DeleteFuncExpires deletes all entries in the SyncMap for which the provided function fn returns true, using the expiration time of the entry as the argument. It then calls the provided function fnVal with the value associated with the key before deleting the entry.

func (*SyncMap[T]) DeleteFuncExpiresVal

func (s *SyncMap[T]) DeleteFuncExpiresVal(fn func(int64) bool, fnVal func(T))

DeleteFuncExpiresVal deletes all entries in the SyncMap for which the provided function fn returns true, using the expiration time of the entry as the argument. It then calls the provided function fnVal with the value associated with the key before deleting the entry.

func (*SyncMap[T]) DeleteFuncImdbVal

func (s *SyncMap[T]) DeleteFuncImdbVal(fn func(bool) bool, fnVal func(T))

DeleteFuncImdbVal deletes all entries in the SyncMap for which the provided function fn returns true, using both the imdb value and the value associated with the key as arguments. It then calls the provided function fnVal with the value associated with the key before deleting the entry.

func (*SyncMap[T]) DeleteFuncKey

func (s *SyncMap[T]) DeleteFuncKey(fn func(string, T) bool)

DeleteFuncKey deletes all entries in the SyncMap for which the provided function returns true, using both the key and value as arguments.

func (*SyncMap[T]) GetExpire

func (s *SyncMap[T]) GetExpire(key string) int64

GetExpire returns the expiration time for the given key in the SyncMap. If the key does not exist, it returns 0.

func (*SyncMap[T]) GetLastscan

func (s *SyncMap[T]) GetLastscan(key string) int64

GetLastscan returns the last scan time for the given key in the SyncMap. If the key does not exist, it returns 0.

func (*SyncMap[T]) GetVal

func (s *SyncMap[T]) GetVal(key string) T

GetVal returns the value associated with the given key in the SyncMap. The method acquires a read lock on the SyncMap before retrieving the value, and releases the lock before returning the value.

func (*SyncMap[T]) GetValP

func (s *SyncMap[T]) GetValP(key string) *T

GetValP returns a pointer to the value associated with the given key in the SyncMap. If the key does not exist in the SyncMap, it returns nil. The method acquires a read lock on the SyncMap before retrieving the value, and releases the lock before returning the pointer.

func (*SyncMap[T]) UpdateExpire

func (s *SyncMap[T]) UpdateExpire(key string, value int64)

UpdateExpire updates the expiration time for the given key in the SyncMap.

func (*SyncMap[T]) UpdateLastscan

func (s *SyncMap[T]) UpdateLastscan(key string, value int64)

UpdateLastscan updates the last scan time for the given key in the SyncMap.

func (*SyncMap[T]) UpdateVal

func (s *SyncMap[T]) UpdateVal(key string, value T)

UpdateVal updates the value associated with the given key in the SyncMap.

Jump to

Keyboard shortcuts

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