Example #1
0
def log_app_settings(app_settings, logger):
    logger.info("App Settings")
    logger.info("  Debug Mode:            " + str(app_settings.debug))
    logger.info("  Dir - Main:            " + app_settings.app_data_dir)
    logger.info("  Dir - Autonomous Data: " + app_settings.autonomous_data_dir)
    logger.info("  Dir - Remote Data:     " + app_settings.remote_data_dir)
    logger.info("  Dir - Logs:            " + app_settings.log_dir)
    logger.info("  Log - File:            " + app_settings.log_file_path)
    logger.info("  Log - Console Level:   " +
                loggingutils.level_to_string(app_settings.log_console_level))
    logger.info("  Log - File Level:      " +
                loggingutils.level_to_string(app_settings.log_file_level))
    logger.info("  Serial Port:           " + app_settings.serial_port)
Example #2
0
def print_app_settings(app_settings, logger):
    ''' Debugging method to be called when the logger is misbehaving.
    '''

    print("App Settings:")
    print("    Debug Mode            " + str(app_settings.debug))
    print("    Dir - Main            " + app_settings.app_data_dir)
    print("    Dir - Autonomous Data " + app_settings.autonomous_data_dir)
    print("    Dir - Remote Data     " + app_settings.remote_data_dir)
    print("    Dir - Logs            " + app_settings.log_dir)
    print("    Log - File            " + app_settings.log_file_path)
    print("    Log - Console Level   " +
          loggingutils.level_to_string(app_settings.log_console_level))
    print("    Log - File Level      " +
          loggingutils.level_to_string(app_settings.log_file_level))
    print("    Serial Port           " + app_settings.serial_port)
Example #3
0
def log_app_settings(app_settings, logger):
    ''' Logs the current settings.
    '''

    logger.info("App Settings:")
    logger.info("Debug Mode            %s", str(app_settings.debug))
    logger.info("Dir - Main            %s", app_settings.app_data_dir)
    logger.info("Dir - Autonomous Data %s", app_settings.autonomous_data_dir)
    logger.info("Dir - Remote Data     %s", app_settings.remote_data_dir)
    logger.info("Dir - Logs            %s", app_settings.log_dir)
    logger.info("Log - File            %s", app_settings.log_file_path)
    logger.info("Log - Console Level   %s",
                loggingutils.level_to_string(app_settings.log_console_level))
    logger.info("Log - File Level      %s",
                loggingutils.level_to_string(app_settings.log_file_level))
    logger.info("Serial Port           %s", app_settings.serial_port)
Example #4
0
DEFAULT_LOG_LEVEL = logging.INFO
DEFAULT_LOG_FORMAT = "%(asctime)s - %(name)s - %(levelname)s - %(message)s"
DEFAULT_DATE_FORMAT = "%Y-%m-%d %H:%M:%S"

DEFAULT_SERIAL_PORT_VALUE = "/dev/ttyACM0"

DEFAULT_CONFIG_FILE_LINES = [
    "# Place your settings here.",
    "",
    "[" + APP_CONFIG_SECTION + "]",
    "",
    DEBUG_CONFIG_PROPERTY + " = " + str(DEFAULT_DEBUG_VALUE),
    SERIAL_PORT_CONFIG_PROPERTY + " = " + DEFAULT_SERIAL_PORT_VALUE,
    "",
    CONSOLE_LOG_LEVEL_PROPERTY + " = " +
    loggingutils.level_to_string(DEFAULT_LOG_LEVEL),
    FILE_LOG_LEVEL_PROPERTY + " = " +
    loggingutils.level_to_string(DEFAULT_LOG_LEVEL),
    "",
]


class AppSettings:
    def __init__(self, debug=None, app_data_dir=None):

        self.debug = debug
        self.app_data_dir = app_data_dir

        # Derived settings:

        self.config_file_path = fileutils.join(self.app_data_dir,