Skip to content

Commit 9b84f04

Browse files
authored
Merge pull request #49 from zfi/demo
Correct error in Windows default log file location.
2 parents 9cff8f7 + 7c74b74 commit 9b84f04

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

BlocklyLogger.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,13 @@
1414
PLATFORM_MACOS = 'darwin'
1515
PLATFORM_WINDOWS = 'win32'
1616

17+
DEFAULT_PATH_MACOS = '/Library/Logs/Parallax'
18+
DEFAULT_PATH_WINDOWS = '/AppData/Local/Parallax'
19+
DEFAULT_PATH_LINUX = '/tmp/'
20+
1721
path = None
1822

23+
1924
def 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

7777
def __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

9696
def __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:

BlocklyPropClient.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
__author__ = 'Michel & Vale'
2424

2525
PORT = 6009
26-
VERSION = "0.5.1"
26+
VERSION = "0.5.2"
2727

2828

2929
# Enable logging for functions outside of the class definition
@@ -159,7 +159,7 @@ def initialize(self):
159159

160160
if BlocklyLogger.path is None:
161161
self.logfile.set(' ')
162-
self.logger.info('Disk logging is inactive')
162+
self.logger.info('Disk logging is disabled.')
163163
else:
164164
self.logfile.set(BlocklyLogger.path)
165165
self.logger.info('Disk log file location is: %s', BlocklyLogger.path)

0 commit comments

Comments
 (0)