diff --git a/BlocklyLogger.py b/BlocklyLogger.py index 63e9b71..d30307f 100644 --- a/BlocklyLogger.py +++ b/BlocklyLogger.py @@ -14,8 +14,13 @@ PLATFORM_MACOS = 'darwin' PLATFORM_WINDOWS = 'win32' +DEFAULT_PATH_MACOS = '/Library/Logs/Parallax' +DEFAULT_PATH_WINDOWS = '/AppData/Local/Parallax' +DEFAULT_PATH_LINUX = '/tmp/' + path = None + def init(filename = 'BlocklyPropClient.log'): global path @@ -48,41 +53,36 @@ def emit(self, record): logger = logging.getLogger('blockly') logger.setLevel(logging.DEBUG) - # create a file handler to log events to the debug level. Log file - # is overwritten each time the app runs. - if not disable_filelogging: - handler = logging.FileHandler(logfile_name, mode='w') - handler.setLevel(logging.DEBUG) - # create a console handler for error-level events console = logging.StreamHandler() console.setLevel(logging.ERROR) # create a logging format formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') - - if not disable_filelogging: - handler.setFormatter(formatter) - console.setFormatter(formatter) - # add the handlers to the logger + # create a file handler to log events to the debug level if disk logging is active. + # Log file is overwritten each time the app runs. if not disable_filelogging: + handler = logging.FileHandler(logfile_name, mode='w') + handler.setLevel(logging.DEBUG) + handler.setFormatter(formatter) logger.addHandler(handler) + # add the handlers to the logger logger.addHandler(console) logger.info("Logger has been started.") def __set_macos_logpath(filename): user_home = os.path.expanduser('~') - log_path = user_home + '/Library/Logs/Parallax' + log_path = user_home + DEFAULT_PATH_MACOS # Does the log directory exist try: result = __verify_logpath(log_path) if result is None and __create_logpath(log_path) is None: - # Try to create the directory in the tmp directory + # Try to create the directory in the tmp directory log_path = '/tmp' result = __verify_logpath(log_path) if result is None: @@ -95,7 +95,7 @@ def __set_macos_logpath(filename): def __set_windows_logpath(filename): user_home = os.path.expanduser('~') - log_path = user_home + '/AppData/Parallax' + log_path = user_home + DEFAULT_PATH_WINDOWS # Does the log directory exist try: diff --git a/BlocklyPropClient.py b/BlocklyPropClient.py index 4ab2b04..d71cb71 100644 --- a/BlocklyPropClient.py +++ b/BlocklyPropClient.py @@ -23,7 +23,7 @@ __author__ = 'Michel & Vale' PORT = 6009 -VERSION = "0.5.1" +VERSION = "0.5.2" # Enable logging for functions outside of the class definition @@ -159,7 +159,7 @@ def initialize(self): if BlocklyLogger.path is None: self.logfile.set(' ') - self.logger.info('Disk logging is inactive') + self.logger.info('Disk logging is disabled.') else: self.logfile.set(BlocklyLogger.path) self.logger.info('Disk log file location is: %s', BlocklyLogger.path)