parameters: (app)
docstring: Configure file(info) and email(error) logging.
docstring_summary: Configure file(info) and email(error) logging.
docstring_tokens: Configure file ( info ) and email ( error ) logging .
function: def configure_logging(app):
      """Configure file(info) and email(error) logging."""
  
      if app.debug or app.testing:
          # Skip debug and test mode.
          # You can check stdout logging.
          return
  
      import logging
      from logging.handlers import SMTPHandler
  
      # Set info level on logger, which might be overwritten by handers.
      # Suppress DEBUG messages.
      app.logger.setLevel(logging.INFO)
  
      info_log = os.path.join(app.root_path, "..", "logs", "app-info.log")
      info_file_handler = logging.handlers.RotatingFileHandler(
          info_log, maxBytes=1048576, backupCount=20)
      info_file_handler.setLevel(logging.INFO)
      info_file_handler.setFormatter(logging.Formatter(
          '%(asctime)s %(levelname)s: %(message)s '
          '[in %(pathname)s:%(lineno)d]')
      )
      app.logger.addHandler(info_file_handler)
  
      ADMINS = ['seasonstar@126.com']
      mail_handler = SMTPHandler(app.config['MAIL_SERVER'],
                                 app.config['MAIL_USERNAME'],
                                 ADMINS,
                                 'O_ops... %s failed!' % app.config['PROJECT'],
                                 (app.config['MAIL_USERNAME'],
                                  app.config['MAIL_PASSWORD']))
      mail_handler.setLevel(logging.ERROR)
      mail_handler.setFormatter(logging.Formatter(
          '%(asctime)s %(levelname)s: %(message)s '
          '[in %(pathname)s:%(lineno)d]')
      )
      app.logger.addHandler(mail_handler)
function_tokens: def configure_logging ( app ) : if app . debug or app . testing : # Skip debug and test mode. # You can check stdout logging. return import logging from logging . handlers import SMTPHandler # Set info level on logger, which might be overwritten by handers. # Suppress DEBUG messages. app . logger . setLevel ( logging . INFO ) info_log = os . path . join ( app . root_path , ".." , "logs" , "app-info.log" ) info_file_handler = logging . handlers . RotatingFileHandler ( info_log , maxBytes = 1048576 , backupCount = 20 ) info_file_handler . setLevel ( logging . INFO ) info_file_handler . setFormatter ( logging . Formatter ( '%(asctime)s %(levelname)s: %(message)s ' '[in %(pathname)s:%(lineno)d]' ) ) app . logger . addHandler ( info_file_handler ) ADMINS = [ 'seasonstar@126.com' ] mail_handler = SMTPHandler ( app . config [ 'MAIL_SERVER' ] , app . config [ 'MAIL_USERNAME' ] , ADMINS , 'O_ops... %s failed!' % app . config [ 'PROJECT' ] , ( app . config [ 'MAIL_USERNAME' ] , app . config [ 'MAIL_PASSWORD' ] ) ) mail_handler . setLevel ( logging . ERROR ) mail_handler . setFormatter ( logging . Formatter ( '%(asctime)s %(levelname)s: %(message)s ' '[in %(pathname)s:%(lineno)d]' ) ) app . logger . addHandler ( mail_handler )