Skip to content

Commit 227098a

Browse files
committed
Add more console logging to the logging setup code.
1 parent c0e009f commit 227098a

File tree

1 file changed

+31
-8
lines changed

1 file changed

+31
-8
lines changed

BlocklyLogger.py

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,16 @@
1313

1414

1515
# Platform constants
16+
PLATFORM_POSIX = "posix"
1617
PLATFORM_LINUX = 'Linux'
1718
PLATFORM_MACOS = 'MacOS'
18-
PLATFORM_DARWIN = 'MacOS'
19+
PLATFORM_DARWIN = 'Darwin'
1920
PLATFORM_WINDOWS = 'Windows'
2021

2122
# Default log path for each platform
22-
DEFAULT_PATH_MACOS = '/Library/Logs/Parallax'
23-
DEFAULT_PATH_WINDOWS = '/AppData/Local/Parallax'
24-
DEFAULT_PATH_LINUX = '/tmp'
23+
DEFAULT_PATH_MACOS = 'Library/Logs/Parallax'
24+
DEFAULT_PATH_WINDOWS = 'AppData/Local/Parallax'
25+
DEFAULT_PATH_LINUX = 'tmp'
2526

2627
# Resulting path for log file
2728
path = None
@@ -48,6 +49,17 @@ def emit(self, record):
4849

4950
# Set correct log file location
5051
system = platform.system()
52+
print("Platform detected is: %", system)
53+
54+
# A posix system could be a MacOS or a Linux variety
55+
if system == PLATFORM_POSIX:
56+
is_mac = platform.mac_ver()
57+
if is_mac[0] == "":
58+
# This must be a Linux platform
59+
system = PLATFORM_LINUX
60+
else:
61+
system = PLATFORM_MACOS
62+
5163
if (system == PLATFORM_MACOS) or (system == PLATFORM_DARWIN):
5264
logfile_name = __set_macos_logpath(filename)
5365
elif system == PLATFORM_WINDOWS:
@@ -61,6 +73,7 @@ def emit(self, record):
6173
else:
6274
# Set the module-level path
6375
path = logfile_name
76+
print("Sending file logging output to: ", path)
6477

6578
# Create a logger
6679
logger = logging.getLogger('blockly')
@@ -90,7 +103,9 @@ def emit(self, record):
90103
# Set the default log file location on a Linux system
91104
def __set_linux_logpath(filename):
92105
user_home = os.path.expanduser('~')
93-
log_path = user_home + DEFAULT_PATH_LINUX
106+
print("User home directory is: %s", user_home)
107+
log_path = user_home + "/" + DEFAULT_PATH_LINUX
108+
print("Logfile path is %s", log_path)
94109

95110
# Does the log directory exist
96111
try:
@@ -107,7 +122,9 @@ def __set_linux_logpath(filename):
107122
# Set the default log file location on a MacOS system
108123
def __set_macos_logpath(filename):
109124
user_home = os.path.expanduser('~')
110-
log_path = user_home + DEFAULT_PATH_MACOS
125+
print("User home directory is: %s", user_home)
126+
log_path = user_home + "/" + DEFAULT_PATH_MACOS
127+
print("Logfile path is %s", log_path)
111128

112129
# Does the log directory exist
113130
try:
@@ -127,7 +144,9 @@ def __set_macos_logpath(filename):
127144
# Set the default log file location on a Windows system
128145
def __set_windows_logpath(filename):
129146
user_home = os.path.expanduser('~')
130-
log_path = user_home + DEFAULT_PATH_WINDOWS
147+
print("User home directory is: %s", user_home)
148+
log_path = user_home + "/" + DEFAULT_PATH_WINDOWS
149+
print("Log file path is: %s", log_path)
131150

132151
# Does the log directory exist
133152
try:
@@ -159,8 +178,12 @@ def __create_logpath(file_path):
159178
# Verify that the file for the log file exists
160179
def __verify_logpath(file_path):
161180
try:
162-
info = os.stat(file_path)
181+
print("Testing access to: %s", file_path)
182+
info = os.access(file_path, os.W_OK)
163183
return info
164184
except OSError as ex:
165185
print ex.message
166186
return None
187+
except Exception as ex:
188+
print ex.message
189+
return None

0 commit comments

Comments
 (0)