Logger

Coaster can help your application log errors at run-time. Initialize with coaster.logger.init_app().

class coaster.logger.LocalVarFormatter(fmt=None, datefmt=None)

Custom log formatter that logs the contents of local variables in the stack frame.

class coaster.logger.SMSHandler(app_name, exotel_sid, exotel_token, exotel_from, twilio_sid, twilio_token, twilio_from, phonenumbers)

Custom logging handler to send SMSes to admins

coaster.logger.configure(app)

Enables logging for an app using LocalVarFormatter.

This function requires an app that has already been configured (perhaps using coaster.app.init_app()). It checks for the following configuration parameters:

  • LOGFILE: Name of the file to log to (default error.log)
  • ADMINS: List of email addresses of admins who will be mailed error reports
  • MAIL_DEFAULT_SENDER: From address of email. Can be an address or a tuple with name and address
  • MAIL_SERVER: SMTP server to send with (default localhost)
  • MAIL_USERNAME and MAIL_PASSWORD: SMTP credentials, if required
  • FLUENTD_SERVER: If specified, will enable logging to fluentd (pending)
  • ADMIN_NUMBERS: List of mobile numbers of admin to send SMS alerts. Requires the following values too
  • SMS_EXOTEL_SID: Exotel SID for Indian numbers
  • SMS_EXOTEL_TOKEN: Exotel token
  • SMS_EXOTEL_FROM: Exotel sender’s number
  • SMS_TWILIO_SID: Twilio SID for non-Indian numbers
  • SMS_TWILIO_TOKEN: Twilio token
  • SMS_TWILIO_FROM: Twilio sender’s number
coaster.logger.init_app(app)

Enables logging for an app using LocalVarFormatter.

This function requires an app that has already been configured (perhaps using coaster.app.init_app()). It checks for the following configuration parameters:

  • LOGFILE: Name of the file to log to (default error.log)
  • ADMINS: List of email addresses of admins who will be mailed error reports
  • MAIL_DEFAULT_SENDER: From address of email. Can be an address or a tuple with name and address
  • MAIL_SERVER: SMTP server to send with (default localhost)
  • MAIL_USERNAME and MAIL_PASSWORD: SMTP credentials, if required
  • FLUENTD_SERVER: If specified, will enable logging to fluentd (pending)
  • ADMIN_NUMBERS: List of mobile numbers of admin to send SMS alerts. Requires the following values too
  • SMS_EXOTEL_SID: Exotel SID for Indian numbers
  • SMS_EXOTEL_TOKEN: Exotel token
  • SMS_EXOTEL_FROM: Exotel sender’s number
  • SMS_TWILIO_SID: Twilio SID for non-Indian numbers
  • SMS_TWILIO_TOKEN: Twilio token
  • SMS_TWILIO_FROM: Twilio sender’s number