Commit af249dfc authored by Bram Daams's avatar Bram Daams
Browse files

default log level ERROR

parent e2d2bbcb
......@@ -6,6 +6,9 @@ __pycache__/
# C extensions
# config file
# Distribution / packaging
......@@ -6,7 +6,7 @@
A cron shell wrapper for registering and updating cron jobs automatically in
[healthchecks]( or your [own hosted copy of Healthchecks](
> warning: this software package should be considered "alpha"
> WARNING: once setup and configured, the code in this package runs as user specified in the cron jobs and is wrapped around the cron job commands. Errors in this package could prevent your cron jobs from being executed.
## Installation
......@@ -76,10 +76,16 @@ Create a configuration file `/etc/sch.conf` that looks like:
healthchecks_api_url =
healthchecks_api_key = xxmysecretkeyxx
And fill in the API URL and the key obtained from the Healthchecks project
settings block labeled "API Access".
Optionally, specify the log level in the configuration file:
``` ini
loglevel = DEBUG
Possible values for loglevel are explained [here]( The default log level is `ERROR`.
## Monitoring cron jobs
Just decorate your existing cron tabs by specifying the alternative `sch`:
......@@ -22,6 +22,23 @@ import tzlocal
from crontabs import CronTabs
from . import __version__
def get_config():
try loading the configuration file
my_config = configparser.ConfigParser()['sch.conf', '/etc/sch.conf'])
except configparser.Error:
'Could not find/read/parse config'
'file sch.conf or /etc/sch.conf'
my_config = None
return my_config
HANDLER = logging.handlers.SysLogHandler('/dev/log')
FORMATTER = logging.Formatter(
......@@ -29,8 +46,13 @@ FORMATTER = logging.Formatter(
ROOT = logging.getLogger()
# log level DEBUG
CONFIG = get_config()
LEVEL = CONFIG.get('sch', 'loglevel')
except configparser.Error:
......@@ -81,10 +103,8 @@ def get_hc_api():
try loading Healthchecks API url and key
and return an instance of Healthchecks or None if it failed
config = get_config()
config = configparser.ConfigParser()['sch.conf', '/etc/sch.conf'])
url = config.get('hc', 'healthchecks_api_url')
key = config.get('hc', 'healthchecks_api_key')
......@@ -97,7 +117,6 @@ def get_hc_api():
except configparser.Error:
'Could not find/read/parse config'
'file sch.conf or /etc/sch.conf'
healthchecks = None
......@@ -195,7 +214,7 @@ def shell(command):
start_time = time.time()
# execute command
"Executing shell commmand: %s (",
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment