Skip to content

Commit

Permalink
Improved logging. IP address, hostname and text printed is logged to …
Browse files Browse the repository at this point in the history
…file. Webserver (bottle) is made quiet.
  • Loading branch information
Jeroen684 committed Jan 22, 2018
1 parent ce4f028 commit ba35a10
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion brother_ql_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

from font_helpers import get_fonts

logging.basicConfig(filename='printhistory.log',level=logging.INFO)
logger = logging.getLogger(__name__)

DEBUG = False
Expand Down Expand Up @@ -214,6 +215,9 @@ def print_text():
logger.warning('Exception happened: %s', e)
return return_dict

remote_hostinfo = socket.gethostbyaddr("request['REMOTE_ADDR']")
logger.info('IP: %s Hostname: %s Printing: %s', request['REMOTE_ADDR'], remote_hostinfo[0], context['text'])

return_dict['success'] = True
if DEBUG: return_dict['data'] = str(qlr.data)
return return_dict
Expand Down Expand Up @@ -269,7 +273,7 @@ def main():
DEFAULT_FONT = {'family': family, 'style': style}
sys.stderr.write('The default font is now set to: {family} ({style})\n'.format(**DEFAULT_FONT))

run(host='', port=args.port, debug=DEBUG)
run(host='', port=args.port, debug=DEBUG, quiet=not DEBUG)

if __name__ == "__main__":
main()

0 comments on commit ba35a10

Please sign in to comment.