Skip to content

Commit 1d88516

Browse files
committed
fix bug with log path on mac/linux, bump required version to py3
1 parent c7e323c commit 1d88516

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

csmlog/__init__.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,16 @@
88
import os
99
import shutil
1010
import sys
11-
12-
__version__ = '0.9a'
11+
import uuid
12+
from pathlib import Path
1313

1414
from csmlog.system_call import LoggedSystemCall
1515
from csmlog.udp_handler import UdpHandler
1616
from csmlog.udp_handler_receiver import UdpHandlerReceiver
1717

18+
__version__ = '0.10'
19+
20+
1821
class CSMLogger(object):
1922
'''
2023
object to wrap logging logic
@@ -108,7 +111,17 @@ def getDefaultSaveDirectoryWithName(cls, appName):
108111
if os.name == 'nt':
109112
logFolder = os.path.join(os.path.expandvars("%APPDATA%"), appName)
110113
else:
111-
logFolder = os.path.join('/var/log/', appName)
114+
tmpPath = Path(f'/var/log/{uuid.uuid4()}')
115+
try:
116+
tmpPath.touch()
117+
tmpPath.unlink()
118+
tmpPath = tmpPath.parent
119+
except PermissionError:
120+
# can't use /var/log... try using ~/log/
121+
tmpPath = Path.home() / 'log'
122+
tmpPath.mkdir(exist_ok=True)
123+
124+
logFolder = tmpPath / appName
112125

113126
if not os.path.isdir(logFolder):
114127
os.makedirs(logFolder)

setup.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,14 @@
1313
version=__version__,
1414
packages=['csmlog'],
1515
license='MIT License',
16-
python_requires='>=2.7',
16+
python_requires='>=3.6',
1717
long_description=open('README.md').read(),
1818
long_description_content_type='text/markdown',
1919
classifiers=[
2020
'Intended Audience :: Developers',
2121
'Natural Language :: English',
2222
'Operating System :: Microsoft :: Windows',
2323
'Programming Language :: Python',
24-
'Programming Language :: Python :: 2.7',
2524
'Programming Language :: Python :: 3',
2625
],
2726
include_package_data = True,

0 commit comments

Comments
 (0)