diff options
author | 2024-07-12 09:39:47 +0000 | |
---|---|---|
committer | 2024-07-12 09:39:47 +0000 | |
commit | cde2fb6244a791b3c5b746112e3a8be3a79f39a4 (patch) | |
tree | 6079d6fb66d90ffbe8c1623525bb86829c162459 /vendor/github.com/dsoprea/go-logging/config.go | |
parent | [chore] Add interaction policy gtsmodels (#3075) (diff) | |
download | gotosocial-cde2fb6244a791b3c5b746112e3a8be3a79f39a4.tar.xz |
[feature] support processing of (many) more media types (#3090)
* initial work replacing our media decoding / encoding pipeline with ffprobe + ffmpeg
* specify the video codec to use when generating static image from emoji
* update go-storage library (fixes incompatibility after updating go-iotools)
* maintain image aspect ratio when generating a thumbnail for it
* update readme to show go-ffmpreg
* fix a bunch of media tests, move filesize checking to callers of media manager for more flexibility
* remove extra debug from error message
* fix up incorrect function signatures
* update PutFile to just use regular file copy, as changes are file is on separate partition
* fix remaining tests, remove some unneeded tests now we're working with ffmpeg/ffprobe
* update more tests, add more code comments
* add utilities to generate processed emoji / media outputs
* fix remaining tests
* add test for opus media file, add license header to utility cmds
* limit the number of concurrently available ffmpeg / ffprobe instances
* reduce number of instances
* further reduce number of instances
* fix envparsing test with configuration variables
* update docs and configuration with new media-{local,remote}-max-size variables
Diffstat (limited to 'vendor/github.com/dsoprea/go-logging/config.go')
-rw-r--r-- | vendor/github.com/dsoprea/go-logging/config.go | 246 |
1 files changed, 0 insertions, 246 deletions
diff --git a/vendor/github.com/dsoprea/go-logging/config.go b/vendor/github.com/dsoprea/go-logging/config.go deleted file mode 100644 index 20896e342..000000000 --- a/vendor/github.com/dsoprea/go-logging/config.go +++ /dev/null @@ -1,246 +0,0 @@ -package log - -import ( - "fmt" - "os" -) - -// Config keys. -const ( - ckFormat = "LogFormat" - ckDefaultAdapterName = "LogDefaultAdapterName" - ckLevelName = "LogLevelName" - ckIncludeNouns = "LogIncludeNouns" - ckExcludeNouns = "LogExcludeNouns" - ckExcludeBypassLevelName = "LogExcludeBypassLevelName" -) - -// Other constants -const ( - defaultFormat = "{{.Noun}}: [{{.Level}}] {{if eq .ExcludeBypass true}} [BYPASS]{{end}} {{.Message}}" - defaultLevelName = LevelNameInfo -) - -// Config -var ( - // Alternative format. - format = defaultFormat - - // Alternative adapter. - defaultAdapterName = "" - - // Alternative level at which to display log-items - levelName = defaultLevelName - - // Configuration-driven comma-separated list of nouns to include. - includeNouns = "" - - // Configuration-driven comma-separated list of nouns to exclude. - excludeNouns = "" - - // Level at which to disregard exclusion (if the severity of a message - // meets or exceed this, always display). - excludeBypassLevelName = "" -) - -// Other -var ( - configurationLoaded = false -) - -// Return the current default adapter name. -func GetDefaultAdapterName() string { - return defaultAdapterName -} - -// The adapter will automatically be the first one registered. This overrides -// that. -func SetDefaultAdapterName(name string) { - defaultAdapterName = name -} - -func LoadConfiguration(cp ConfigurationProvider) { - configuredDefaultAdapterName := cp.DefaultAdapterName() - - if configuredDefaultAdapterName != "" { - defaultAdapterName = configuredDefaultAdapterName - } - - includeNouns = cp.IncludeNouns() - excludeNouns = cp.ExcludeNouns() - excludeBypassLevelName = cp.ExcludeBypassLevelName() - - f := cp.Format() - if f != "" { - format = f - } - - ln := cp.LevelName() - if ln != "" { - levelName = ln - } - - configurationLoaded = true -} - -func getConfigState() map[string]interface{} { - return map[string]interface{}{ - "format": format, - "defaultAdapterName": defaultAdapterName, - "levelName": levelName, - "includeNouns": includeNouns, - "excludeNouns": excludeNouns, - "excludeBypassLevelName": excludeBypassLevelName, - } -} - -func setConfigState(config map[string]interface{}) { - format = config["format"].(string) - - defaultAdapterName = config["defaultAdapterName"].(string) - levelName = config["levelName"].(string) - includeNouns = config["includeNouns"].(string) - excludeNouns = config["excludeNouns"].(string) - excludeBypassLevelName = config["excludeBypassLevelName"].(string) -} - -func getConfigDump() string { - return fmt.Sprintf( - "Current configuration:\n"+ - " FORMAT=[%s]\n"+ - " DEFAULT-ADAPTER-NAME=[%s]\n"+ - " LEVEL-NAME=[%s]\n"+ - " INCLUDE-NOUNS=[%s]\n"+ - " EXCLUDE-NOUNS=[%s]\n"+ - " EXCLUDE-BYPASS-LEVEL-NAME=[%s]", - format, defaultAdapterName, levelName, includeNouns, excludeNouns, excludeBypassLevelName) -} - -func IsConfigurationLoaded() bool { - return configurationLoaded -} - -type ConfigurationProvider interface { - // Alternative format (defaults to . - Format() string - - // Alternative adapter (defaults to "appengine"). - DefaultAdapterName() string - - // Alternative level at which to display log-items (defaults to - // "info"). - LevelName() string - - // Configuration-driven comma-separated list of nouns to include. Defaults - // to empty. - IncludeNouns() string - - // Configuration-driven comma-separated list of nouns to exclude. Defaults - // to empty. - ExcludeNouns() string - - // Level at which to disregard exclusion (if the severity of a message - // meets or exceed this, always display). Defaults to empty. - ExcludeBypassLevelName() string -} - -// Environment configuration-provider. -type EnvironmentConfigurationProvider struct { -} - -func NewEnvironmentConfigurationProvider() *EnvironmentConfigurationProvider { - return new(EnvironmentConfigurationProvider) -} - -func (ecp *EnvironmentConfigurationProvider) Format() string { - return os.Getenv(ckFormat) -} - -func (ecp *EnvironmentConfigurationProvider) DefaultAdapterName() string { - return os.Getenv(ckDefaultAdapterName) -} - -func (ecp *EnvironmentConfigurationProvider) LevelName() string { - return os.Getenv(ckLevelName) -} - -func (ecp *EnvironmentConfigurationProvider) IncludeNouns() string { - return os.Getenv(ckIncludeNouns) -} - -func (ecp *EnvironmentConfigurationProvider) ExcludeNouns() string { - return os.Getenv(ckExcludeNouns) -} - -func (ecp *EnvironmentConfigurationProvider) ExcludeBypassLevelName() string { - return os.Getenv(ckExcludeBypassLevelName) -} - -// Static configuration-provider. -type StaticConfigurationProvider struct { - format string - defaultAdapterName string - levelName string - includeNouns string - excludeNouns string - excludeBypassLevelName string -} - -func NewStaticConfigurationProvider() *StaticConfigurationProvider { - return new(StaticConfigurationProvider) -} - -func (scp *StaticConfigurationProvider) SetFormat(format string) { - scp.format = format -} - -func (scp *StaticConfigurationProvider) SetDefaultAdapterName(adapterName string) { - scp.defaultAdapterName = adapterName -} - -func (scp *StaticConfigurationProvider) SetLevelName(levelName string) { - scp.levelName = levelName -} - -func (scp *StaticConfigurationProvider) SetIncludeNouns(includeNouns string) { - scp.includeNouns = includeNouns -} - -func (scp *StaticConfigurationProvider) SetExcludeNouns(excludeNouns string) { - scp.excludeNouns = excludeNouns -} - -func (scp *StaticConfigurationProvider) SetExcludeBypassLevelName(excludeBypassLevelName string) { - scp.excludeBypassLevelName = excludeBypassLevelName -} - -func (scp *StaticConfigurationProvider) Format() string { - return scp.format -} - -func (scp *StaticConfigurationProvider) DefaultAdapterName() string { - return scp.defaultAdapterName -} - -func (scp *StaticConfigurationProvider) LevelName() string { - return scp.levelName -} - -func (scp *StaticConfigurationProvider) IncludeNouns() string { - return scp.includeNouns -} - -func (scp *StaticConfigurationProvider) ExcludeNouns() string { - return scp.excludeNouns -} - -func (scp *StaticConfigurationProvider) ExcludeBypassLevelName() string { - return scp.excludeBypassLevelName -} - -func init() { - // Do the initial configuration-load from the environment. We gotta seed it - // with something for simplicity's sake. - ecp := NewEnvironmentConfigurationProvider() - LoadConfiguration(ecp) -} |