mirror of
https://github.com/moparisthebest/SickRage
synced 2025-01-06 03:18:01 -05:00
Made logging configurable
Made logging configurable through settings - general page. Changing the logging requires a restart (since the logger is initialized on startup.
This commit is contained in:
parent
8b84e4f4bc
commit
e88e12f5d5
@ -96,6 +96,26 @@
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="field-pair">
|
||||
<label for="log_nr">
|
||||
<span class="component-title">Number of Log files saved</span>
|
||||
<span class="component-desc">
|
||||
<input type="text" name="log_nr" id="log_nr" value="$sickbeard.LOG_NR" class="form-control input-sm input75" />
|
||||
<p>number of log files saved when rotating logs (default: 5) (REQUIRES RESTART)</p>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="field-pair">
|
||||
<label for="log_size">
|
||||
<span class="component-title">Size of Log files saved</span>
|
||||
<span class="component-desc">
|
||||
<input type="text" name="log_size" id="log_size" value="$sickbeard.LOG_SIZE" class="form-control input-sm input75" />
|
||||
<p>maximum size of a log file saved (default: 1048576 (1MB)) (REQUIRES RESTART)</p>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="field-pair">
|
||||
<label for="indexer_default">
|
||||
|
@ -125,6 +125,8 @@ started = False
|
||||
|
||||
ACTUAL_LOG_DIR = None
|
||||
LOG_DIR = None
|
||||
LOG_NR = 5
|
||||
LOG_SIZE = 1048576
|
||||
|
||||
SOCKET_TIMEOUT = None
|
||||
|
||||
@ -484,7 +486,7 @@ def get_backlog_cycle_time():
|
||||
def initialize(consoleLogging=True):
|
||||
with INIT_LOCK:
|
||||
|
||||
global BRANCH, GIT_RESET, GIT_REMOTE, GIT_REMOTE_URL, CUR_COMMIT_HASH, CUR_COMMIT_BRANCH, ACTUAL_LOG_DIR, LOG_DIR, WEB_PORT, WEB_LOG, ENCRYPTION_VERSION, WEB_ROOT, WEB_USERNAME, WEB_PASSWORD, WEB_HOST, WEB_IPV6, API_KEY, API_ROOT, ENABLE_HTTPS, HTTPS_CERT, HTTPS_KEY, \
|
||||
global BRANCH, GIT_RESET, GIT_REMOTE, GIT_REMOTE_URL, CUR_COMMIT_HASH, CUR_COMMIT_BRANCH, ACTUAL_LOG_DIR, LOG_DIR, LOG_NR, LOG_SIZE, WEB_PORT, WEB_LOG, ENCRYPTION_VERSION, WEB_ROOT, WEB_USERNAME, WEB_PASSWORD, WEB_HOST, WEB_IPV6, API_KEY, API_ROOT, ENABLE_HTTPS, HTTPS_CERT, HTTPS_KEY, \
|
||||
HANDLE_REVERSE_PROXY, USE_NZBS, USE_TORRENTS, NZB_METHOD, NZB_DIR, DOWNLOAD_PROPERS, RANDOMIZE_PROVIDERS, CHECK_PROPERS_INTERVAL, ALLOW_HIGH_PRIORITY, TORRENT_METHOD, \
|
||||
SAB_USERNAME, SAB_PASSWORD, SAB_APIKEY, SAB_CATEGORY, SAB_CATEGORY_ANIME, SAB_HOST, \
|
||||
NZBGET_USERNAME, NZBGET_PASSWORD, NZBGET_CATEGORY, NZBGET_CATEGORY_ANIME, NZBGET_PRIORITY, NZBGET_HOST, NZBGET_USE_HTTPS, backlogSearchScheduler, \
|
||||
@ -568,7 +570,8 @@ def initialize(consoleLogging=True):
|
||||
|
||||
ACTUAL_LOG_DIR = check_setting_str(CFG, 'General', 'log_dir', 'Logs')
|
||||
LOG_DIR = os.path.normpath(os.path.join(DATA_DIR, ACTUAL_LOG_DIR))
|
||||
|
||||
LOG_NR = check_setting_int(CFG, 'General', 'log_nr', 5) #Default to 5 backup file (sickrage.log.x)
|
||||
LOG_SIZE = check_setting_int(CFG, 'General', 'log_size', 1048576) #Default to max 1MB per logfile
|
||||
fileLogging = True
|
||||
if not helpers.makeDir(LOG_DIR):
|
||||
sys.stderr.write("!!! No log folder, logging to screen only!\n")
|
||||
@ -1422,6 +1425,8 @@ def save_config():
|
||||
new_config['General']['config_version'] = CONFIG_VERSION
|
||||
new_config['General']['encryption_version'] = int(ENCRYPTION_VERSION)
|
||||
new_config['General']['log_dir'] = ACTUAL_LOG_DIR if ACTUAL_LOG_DIR else 'Logs'
|
||||
new_config['General']['log_nr'] = int(LOG_NR)
|
||||
new_config['General']['log_size'] = int(LOG_SIZE)
|
||||
new_config['General']['socket_timeout'] = SOCKET_TIMEOUT
|
||||
new_config['General']['web_port'] = WEB_PORT
|
||||
new_config['General']['web_host'] = WEB_HOST
|
||||
|
@ -111,7 +111,7 @@ class Logger(object):
|
||||
|
||||
# rotating log file handler
|
||||
if self.fileLogging:
|
||||
rfh = logging.handlers.RotatingFileHandler(self.logFile, maxBytes=1024 * 1024, backupCount=5, encoding='utf-8')
|
||||
rfh = logging.handlers.RotatingFileHandler(self.logFile, maxBytes=sickbeard.LOG_SIZE, backupCount=sickbeard.LOG_NR, encoding='utf-8')
|
||||
rfh.setFormatter(CensoredFormatter('%(asctime)s %(levelname)-8s %(message)s', '%Y-%m-%d %H:%M:%S'))
|
||||
rfh.setLevel(DEBUG)
|
||||
|
||||
|
@ -3422,7 +3422,7 @@ class ConfigGeneral(Config):
|
||||
|
||||
sickbeard.save_config()
|
||||
|
||||
def saveGeneral(self, log_dir=None, web_port=None, web_log=None, encryption_version=None, web_ipv6=None,
|
||||
def saveGeneral(self, log_dir=None, log_nr = 5, log_size = 1048576, web_port=None, web_log=None, encryption_version=None, web_ipv6=None,
|
||||
update_shows_on_start=None, trash_remove_show=None, trash_rotate_logs=None, update_frequency=None,
|
||||
launch_browser=None, web_username=None,
|
||||
api_key=None, indexer_default=None, timezone_display=None, cpu_preset=None,
|
||||
@ -3443,7 +3443,8 @@ class ConfigGeneral(Config):
|
||||
sickbeard.AUTO_UPDATE = config.checkbox_to_value(auto_update)
|
||||
sickbeard.NOTIFY_ON_UPDATE = config.checkbox_to_value(notify_on_update)
|
||||
# sickbeard.LOG_DIR is set in config.change_LOG_DIR()
|
||||
|
||||
sickbeard.LOG_NR = log_nr
|
||||
sickbeard.LOG_SIZE = log_size
|
||||
sickbeard.UPDATE_SHOWS_ON_START = config.checkbox_to_value(update_shows_on_start)
|
||||
sickbeard.TRASH_REMOVE_SHOW = config.checkbox_to_value(trash_remove_show)
|
||||
sickbeard.TRASH_ROTATE_LOGS = config.checkbox_to_value(trash_rotate_logs)
|
||||
|
Loading…
Reference in New Issue
Block a user