threaded_logging

Logging is an important aspect of every application, as logs provide valuable feedback to developers and first line support. Camelot adds some additional functions on top of the standard Python logging library.

The added functionallity is needed for two reasons :

  • Camelot applications are often installed in a distributed fashion. Thus the log files need to be collected to provide meaningfull information to the developer.
  • Logging should never slow down/freeze the application. Even when logging to files this may happen, since the application never knows for sure if a file is really local, and network connections may turn slow at any time.

Both issues are resolved by using a logging handler that collects all logs, and periodically sends them to an http server in the background:

handler = ThreadedHttpHandler('www.example.com:80', '/my_logs/')
handler.setLevel(logging.INFO)
logging.root.addHandler(handler)

The logging url could include a part indentifying the user and as such assisting first line support.

class camelot.core.threaded_logging.CloudLaunchHandler(cloud_record, connection_kwargs={})[source]

A logging handler that sends the logs to the Cloud Launch service, requires the cloudlaunch library, and only works with applications tested or deployed through cloudlaunch

The cloudlaunch record can be obtained using the get_cloud_record method of the cloudlaunch.resources module.

class camelot.core.threaded_logging.ThreadedAwsHandler(access_key, secret_access_key, queue_name, revision=0, connection_kwargs={})[source]

A logging handler that sends the logs to an AWS queue through the SQS, this handler requires the boto library

class camelot.core.threaded_logging.ThreadedHttpHandler(host, url, method='GET')[source]

An Http Logging handler that does the logging itself in a different thread, to prevent slow down of the main thread

class camelot.core.threaded_logging.ThreadedTimer(interval, handler)[source]

Thread that checks every interval milli seconds if there are logs to be sent to the server

Previous topic

templates

Next topic

threading

This Page