Permalink
Browse files

Debug logging toggle in settings.

SIGUSR2 signal to viewer.py reloads the settings
  • Loading branch information...
1 parent b494ba1 commit ca330b5ce315e78c878618a5c9f6fc89acf7d6b2 @mcbuddha mcbuddha committed Mar 14, 2013
Showing with 32 additions and 1 deletion.
  1. +3 −0 misc/screenly.conf
  2. +1 −0 settings.py
  3. +14 −1 viewer.py
  4. +14 −0 views/settings.haml
View
@@ -17,3 +17,6 @@ shuffle_playlist = False
; Asset duration default value
default_duration = 10
+
+; Debug logging toggle
+debug_logging = False
View
@@ -20,6 +20,7 @@
'shuffle_playlist': False,
'resolution': '1920x1080',
'default_duration': '10',
+ 'debug_logging': False,
}
}
View
@@ -52,6 +52,16 @@ def sigusr1(signum, frame):
logging.info("Signal received, skipping.")
system("killall omxplayer.bin")
+def sigusr2(signum, frame):
+ """
+ This is the signal handler for SIGUSR2
+ Resets the last_settings_refresh timestamp to force
+ settings reloading.
+ """
+ logging.info("Signal received, reloading settings.")
+ last_settings_refresh = None
+ reload_settings()
+
class Scheduler(object):
def __init__(self, *args, **kwargs):
@@ -270,14 +280,17 @@ def reload_settings():
if not last_settings_refresh or settings_file_timestamp > last_settings_refresh:
settings.load()
+ logging.getLogger().setLevel(logging.DEBUG if settings['debug_logging'] else logging.INFO)
+
global last_setting_refresh
last_setting_refresh = datetime.utcnow()
if __name__ == "__main__":
- # Install signal handler
+ # Install signal handlers
signal.signal(signal.SIGUSR1, sigusr1)
+ signal.signal(signal.SIGUSR2, sigusr2)
# Before we start, reload the settings.
reload_settings()
View
@@ -91,6 +91,20 @@
.controls
%input.span1(type="number", name="default_duration", value=default_duration)
+ .control-group
+ %label.control-label Debug logging
+ .controls
+
+ %label.checkbox.toggle.well#debug_checkbox
+ - if debug_logging:
+ %input(type="checkbox", checked="checked", name="debug_logging")
+ - else:
+ %input(type="checkbox", name="debug_logging")
+ %p
+ %span.on On
+ %span.off Off
+ %a.btn.btn-primary.slide-button
+
.form-actions
%input.btn.btn-primary(type="submit", value="Save Settings")
%a.btn(href="/") Cancel

0 comments on commit ca330b5

Please sign in to comment.