RAW: Improve JPEG converter logging #1362

This commit is contained in:
Michael Mayer 2021-09-21 16:29:03 +02:00
parent b081f27e17
commit b83625a653
3 changed files with 15 additions and 7 deletions

View file

@ -393,10 +393,13 @@ func (c *Config) AdminPassword() string {
return c.options.AdminPassword
}
// LogLevel returns the logrus log level.
// LogLevel returns the Logrus log level.
func (c *Config) LogLevel() logrus.Level {
if c.Debug() {
c.options.LogLevel = "debug"
// Normalize string.
c.options.LogLevel = strings.ToLower(strings.TrimSpace(c.options.LogLevel))
if c.Debug() && c.options.LogLevel != logrus.TraceLevel.String() {
c.options.LogLevel = logrus.DebugLevel.String()
}
if logLevel, err := logrus.ParseLevel(c.options.LogLevel); err == nil {

View file

@ -184,7 +184,7 @@ func (c *Convert) ToJson(f *MediaFile) (jsonName string, err error) {
// JpegConvertCommand returns the command for converting files to JPEG, depending on the format.
func (c *Convert) JpegConvertCommand(f *MediaFile, jpegName string, xmpName string) (result *exec.Cmd, useMutex bool, err error) {
if f == nil {
return result, useMutex, fmt.Errorf("convert: file is nil - you might have found a bug")
return result, useMutex, fmt.Errorf("file is nil - you might have found a bug")
}
size := strconv.Itoa(c.conf.JpegSize())
@ -220,14 +220,19 @@ func (c *Convert) JpegConvertCommand(f *MediaFile, jpegName string, xmpName stri
result = exec.Command(c.conf.RawtherapeeBin(), args...)
} else {
return nil, useMutex, fmt.Errorf("convert: no converter found for %s", txt.Quote(f.BaseName()))
return nil, useMutex, fmt.Errorf("no suitable converter found")
}
} else if f.IsVideo() && c.conf.FFmpegEnabled() {
result = exec.Command(c.conf.FFmpegBin(), "-y", "-i", f.FileName(), "-ss", "00:00:00.001", "-vframes", "1", jpegName)
} else if f.IsHEIF() && c.conf.HeifConvertEnabled() {
result = exec.Command(c.conf.HeifConvertBin(), f.FileName(), jpegName)
} else {
return nil, useMutex, fmt.Errorf("convert: file type %s not supported in %s", f.FileType(), txt.Quote(f.BaseName()))
return nil, useMutex, fmt.Errorf("file type %s not supported", f.FileType())
}
// Log convert command in trace mode only as it exposes server internals.
if result != nil {
log.Tracef("convert: %s", result.String())
}
return result, useMutex, nil

View file

@ -14,7 +14,7 @@ type ConvertJob struct {
func ConvertWorker(jobs <-chan ConvertJob) {
logError := func(err error, job ConvertJob) {
fileName := job.file.RelName(job.convert.conf.OriginalsPath())
log.Errorf("%s in %s", strings.TrimSpace(err.Error()), txt.Quote(fileName))
log.Errorf("convert: %s for %s", strings.TrimSpace(err.Error()), txt.Quote(fileName))
}
for job := range jobs {