Skip to content

Commit

Permalink
Minor Logging Issues
Browse files Browse the repository at this point in the history
This patch fixes a few minor logging issues where exceptions were not
logged properly or the loggers own formatting was not used.
  • Loading branch information
lkiesow committed Sep 7, 2020
1 parent 3f22995 commit 730f0e4
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 12 deletions.
4 changes: 1 addition & 3 deletions pyca/capture.py
Expand Up @@ -23,7 +23,6 @@
import subprocess
import sys
import time
import traceback

logger = logging.getLogger(__name__)
notify = sdnotify.SystemdNotifier()
Expand Down Expand Up @@ -169,8 +168,7 @@ def recording_command(event):
try:
os.remove(preview.replace('{{previewdir}}', conf['preview_dir']))
except OSError:
logger.warning('Could not remove preview files')
logger.warning(traceback.format_exc())
logger.warning('Could not remove preview files', exc_info=True)

# Check process for errors
exitcode = conf['exit_code']
Expand Down
6 changes: 2 additions & 4 deletions pyca/ingest.py
Expand Up @@ -18,7 +18,6 @@
import sdnotify
import shutil
import time
import traceback

logger = logging.getLogger(__name__)
notify = sdnotify.SystemdNotifier()
Expand Down Expand Up @@ -80,7 +79,7 @@ def ingest(event):

# add track
for (flavor, track) in event.get_tracks():
logger.info('Adding track ({0} -> {1})'.format(flavor, track))
logger.info('Adding track (%s -> %s)', flavor, track)
track = track.encode('ascii', 'ignore')
fields = [('mediaPackage', mediapackage), ('flavor', flavor),
('BODY1', (pycurl.FORM_FILE, track))]
Expand Down Expand Up @@ -117,8 +116,7 @@ def safe_start_ingest(event):
try:
ingest(event)
except Exception:
logger.error('Something went wrong during the upload')
logger.error(traceback.format_exc())
logger.exception('Something went wrong during the upload')
# Update state if something went wrong
recording_state(event.uid, 'upload_error')
update_event_status(event, Status.FAILED_UPLOADING)
Expand Down
4 changes: 1 addition & 3 deletions pyca/schedule.py
Expand Up @@ -19,7 +19,6 @@
import pycurl
import sdnotify
import time
import traceback
from urllib.parse import urlencode

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -79,8 +78,7 @@ def get_schedule(db):
try:
cal = parse_ical(vcal.decode('utf-8'))
except Exception:
logger.error('Could not parse ical')
logger.error(traceback.format_exc())
logger.exception('Could not parse ical')
return
db.query(UpcomingEvent).delete()
for event in cal:
Expand Down
5 changes: 3 additions & 2 deletions pyca/utils.py
Expand Up @@ -123,8 +123,9 @@ def service(service_name, force_update=False):
logger.debug('Updates service URL for %s: %s',
service_name,
config('services', service_id))
except pycurl.error as e:
logger.error(f'Could not get {service} endpoint: {e}. Retry in 5s')
except pycurl.error:
logger.exception('Could not get %s endpoint. Retry in 5s',
service_name)
time.sleep(5.0)
return config('services', service_id)

Expand Down

0 comments on commit 730f0e4

Please sign in to comment.