Scripts fall under error section

Is there a reason why scripts ran by sonarr are under Error section in sonarr log page whether it is succesful or not? It is a bit misleading. It is not like my script fails or anything. Shouldnt it be under information or have its own section?

Not sure if applicable, but if your script uses ffmpeg: Custom script on Synology generating errors

If the script logs to standard error (like ffmpeg the post @Thirrian linked) then Sonarr will log it as an error.

All my script does is write lines to a text file

#!/usr/bin/env python

import logging
from logging.handlers import RotatingFileHandler
import time
from datetime import datetime
import os
import sys

#Set time zone
os.environ['TZ'] = 'EST+05EDT,M4.1.0,M10.5.0'
time.tzset()


log_filename = "/media/sdu1/home/saitoh183/data/logs/process/TV_process.log"

logger = logging.getLogger('process')
logger.setLevel(logging.INFO)

formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')

fh = RotatingFileHandler(log_filename, maxBytes=1000000, backupCount=5)
fh.setFormatter(formatter)
logger.addHandler(fh)

console = logging.StreamHandler()
console.setLevel(logging.DEBUG)
console.setFormatter(formatter)
logger.addHandler(console)


#Variables:
src_path = os.environ.get('sonarr_episodefile_path')
logger.info('SYS ARGV1 {}'.format(src_path))
o_src_path = os.environ.get('sonarr_episodefile_sourcepath')
logger.info('SYS ARGV2 {}'.format(o_src_path))
src_path_filename = src_path.rsplit('/',1)[1]

logger.info('Creating TV process file {}.txt'.format(src_path_filename))

p2 = open('/media/sdu1/home/saitoh183/data/downloads/to_process/%s.txt' %src_path_filename,"w")
p2.write('/media/sdu1/home/saitoh183/data/scripts/rclone_move_tv_new.py -s "%s" -o "%s"' %(src_path,o_src_path))
p2.close()

It’s also logging to stderr, does changing console = logging.StreamHandler() to console = logging.StreamHandler(sys.stdout) make a difference?

Nothing shows up in the Sonarr log when the script is executed.

Then what shows up in the “Error Section”? If the script is not logging everything is it exiting with an exit code other than 0?

In the Error Section it was showing every line in my script that starts with “logger.info”

Please post your logs showing that.

image

18-5-3 12:02:40.2|Error|process_file_tv.py|2018-05-03 12:02:40,201 - process - INFO - SYS ARGV1 /media/sdu1/home/saitoh183/data/Videos/Kids-TV/Peppa Pig/Season 05/Peppa Pig - S05E33 - Peppa Goes To Paris.mkv
18-5-3 12:02:40.2|Error|process_file_tv.py|2018-05-03 12:02:40,221 - process - INFO - SYS ARGV2 /media/sdu1/home/saitoh183/data/downloads/_josh_tvshows/Peppa.Pig.S05E33.Wendy.Wolfs.Birthday.720p.HDTV.DD5.1.x264-NTb/9acb7c35795e4171a4015db40438046c.mkv
18-5-3 12:02:40.2|Error|process_file_tv.py|2018-05-03 12:02:40,221 - process - INFO - Creating TV process file Peppa Pig - S05E33 - Peppa Goes To Paris.mkv.txt

Right, it was what @Thirrian and I have already said, your script is logging to standard error, Sonarr sees that and logs them as errors.

Not sure what you meant by

Because that’s definitely in Sonarr’s log.

When i did

those log entries dont appear in the Error Section of the Sonarr log.

Ahh, right, so it worked. They should show up in the debug logs.

Sorry for the confusion, sounds like that fixed it.

Yeah it works. So if i change

console.setLevel(logging.DEBUG) to console.setLevel(logging.INFO)

it should show up in Information Section in Sonarr?

Actually not really i was mistaking

image

Script Output is Blank

Not sure how it’s blank since it captured the output above and logged it above.

Which version of Sonarr?

Version
2.0.0.5169
Mono Version
5.4.0.199

Well what it caputed was the execution of the script but not the actual INFO lines of my script if you compare to post above

Ahh right. My suggestion (after a few minutes of googling) obviously doesn’t work, it just silences it completely. I’m not sure why your script is logging to standard error by default or how to fix it.

Ok…well it is not a big deal , it was more of an observation and i wasnt sure this was the expected behavior since it was my first time using scripts with sonarr. It is the same in Radarr as well

One more thing that seems applicable after a quick google search, for whatever reason the default is stderr…

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.