Add proper logging
This commit is contained in:
@@ -3,10 +3,10 @@ package torrent
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"log"
|
||||
"os/exec"
|
||||
|
||||
"github.com/debridmediamanager.com/zurg/internal/config"
|
||||
"github.com/debridmediamanager.com/zurg/pkg/logutil"
|
||||
)
|
||||
|
||||
type ScriptExecutor struct {
|
||||
@@ -30,15 +30,18 @@ func (se *ScriptExecutor) Execute() (string, error) {
|
||||
}
|
||||
|
||||
func OnLibraryUpdateHook(config config.ConfigInterface) {
|
||||
rlog := logutil.NewLogger()
|
||||
log := rlog.Named("hooks")
|
||||
|
||||
executor := &ScriptExecutor{
|
||||
Script: config.GetOnLibraryUpdate(),
|
||||
}
|
||||
output, err := executor.Execute()
|
||||
if err != nil {
|
||||
log.Printf("Failed to execute hook on_library_update:\n%v\n", err)
|
||||
log.Errorf("Failed to execute hook on_library_update: %v", err)
|
||||
return
|
||||
}
|
||||
if output != "" {
|
||||
log.Printf("Output of hook on_library_update:\n%s\n", output)
|
||||
log.Infof("Output of hook on_library_update:\n%s", output)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user