1414PLATFORM_MACOS = 'darwin'
1515PLATFORM_WINDOWS = 'win32'
1616
17+ DEFAULT_PATH_MACOS = '/Library/Logs/Parallax'
18+ DEFAULT_PATH_WINDOWS = '/AppData/Local/Parallax'
19+ DEFAULT_PATH_LINUX = '/tmp/'
20+
1721path = None
1822
23+
1924def init (filename = 'BlocklyPropClient.log' ):
2025 global path
2126
@@ -48,41 +53,36 @@ def emit(self, record):
4853 logger = logging .getLogger ('blockly' )
4954 logger .setLevel (logging .DEBUG )
5055
51- # create a file handler to log events to the debug level. Log file
52- # is overwritten each time the app runs.
53- if not disable_filelogging :
54- handler = logging .FileHandler (logfile_name , mode = 'w' )
55- handler .setLevel (logging .DEBUG )
56-
5756 # create a console handler for error-level events
5857 console = logging .StreamHandler ()
5958 console .setLevel (logging .ERROR )
6059
6160 # create a logging format
6261 formatter = logging .Formatter ('%(asctime)s - %(name)s - %(levelname)s - %(message)s' )
63-
64- if not disable_filelogging :
65- handler .setFormatter (formatter )
66-
6762 console .setFormatter (formatter )
6863
69- # add the handlers to the logger
64+ # create a file handler to log events to the debug level if disk logging is active.
65+ # Log file is overwritten each time the app runs.
7066 if not disable_filelogging :
67+ handler = logging .FileHandler (logfile_name , mode = 'w' )
68+ handler .setLevel (logging .DEBUG )
69+ handler .setFormatter (formatter )
7170 logger .addHandler (handler )
7271
72+ # add the handlers to the logger
7373 logger .addHandler (console )
7474 logger .info ("Logger has been started." )
7575
7676
7777def __set_macos_logpath (filename ):
7878 user_home = os .path .expanduser ('~' )
79- log_path = user_home + '/Library/Logs/Parallax'
79+ log_path = user_home + DEFAULT_PATH_MACOS
8080
8181 # Does the log directory exist
8282 try :
8383 result = __verify_logpath (log_path )
8484 if result is None and __create_logpath (log_path ) is None :
85- # Try to create the directory in the tmp directory
85+ # Try to create the directory in the tmp directory
8686 log_path = '/tmp'
8787 result = __verify_logpath (log_path )
8888 if result is None :
@@ -95,7 +95,7 @@ def __set_macos_logpath(filename):
9595
9696def __set_windows_logpath (filename ):
9797 user_home = os .path .expanduser ('~' )
98- log_path = user_home + '/AppData/Parallax'
98+ log_path = user_home + DEFAULT_PATH_WINDOWS
9999
100100 # Does the log directory exist
101101 try :
0 commit comments