Scraper log improvements (#1741)

* Fix logs from scraper and plugins not being shown in UI

Using `logger.` in the logger package to write logs is "incorrect". This
as the package contains a variable named `logger` which contains the
logrus instance. So instead of the log line being handled by the custom
log implementation / wrapper which makes sure the lines are shown in the
UI as well, it's written to logrus directly meaning the wrapper is
skipped.

This "issue" is obviously triggered because in any other place
`logger.X` can be used and it will used the custom logger package /
wrapper which works fine.

* Add plugin / scraper name to logging output

Indicate which plugin / scraper wrote a log message by including its
name to the `[Scrape]` prefix.

* Add missing addLogItem call
This commit is contained in:
gitgiggety
2021-09-19 02:06:34 +02:00
committed by GitHub
parent 66f92c5dcc
commit b83ce29ac4
6 changed files with 22 additions and 15 deletions

View File

@@ -1,22 +1,23 @@
package plugin
import (
"fmt"
"io"
"github.com/stashapp/stash/pkg/logger"
)
func (t *pluginTask) handlePluginStderr(pluginOutputReader io.ReadCloser) {
func (t *pluginTask) handlePluginStderr(name string, pluginOutputReader io.ReadCloser) {
logLevel := logger.PluginLogLevelFromName(t.plugin.PluginErrLogLevel)
if logLevel == nil {
// default log level to error
logLevel = &logger.ErrorLevel
}
const pluginPrefix = "[Plugin] "
const pluginPrefix = "[Plugin / %s] "
lgr := logger.PluginLogger{
Prefix: pluginPrefix,
Prefix: fmt.Sprintf(pluginPrefix, name),
DefaultLogLevel: logLevel,
ProgressChan: t.progress,
}