Skip to content

Commit 43d00c2

Browse files
committed
curr dir
1 parent 897cd48 commit 43d00c2

1 file changed

Lines changed: 10 additions & 11 deletions

File tree

test_loger/logs.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@
77
from time import asctime
88
from sys import platform
99

10-
1110
plfm = 'windows'
1211

1312
if platform == "linux" or platform == "linux2":
1413
plfm = 'linux'
1514
elif platform == "darwin":
16-
plfm = 'OS X'
15+
plfm = 'OS X'
1716
elif platform == "win32":
1817
plfm = 'windows'
1918

19+
2020
class Log:
21-
file_path = "D:\\"
21+
file_path = os.getcwd()
2222
file_name = 'file_log'
2323
logger = logging.getLogger()
2424

@@ -58,15 +58,14 @@ def getLogger(self):
5858

5959
def addToLog(self, s):
6060
if plfm == 'windows':
61-
file_ = self.file_path + "\\logs\\" + self.file_name + "_" + strftime('%d_%m_%Y', gmtime())+ ".txt"
61+
file_ = self.file_path + "\\logs\\" + self.file_name + "_" + strftime('%d_%m_%Y', gmtime()) + ".txt"
6262
else:
6363
file_ = self.file_path + "/logs/" + self.file_name + "_" + strftime('%d_%m_%Y', gmtime()) + ".txt"
6464

65-
66-
if os.path.isfile(file_) != True:
67-
self.init_logging()
65+
if not os.path.isfile(file_):
66+
self.init_logging()
6867
self.getLogger().info(s)
69-
68+
7069
def initLogFolder(self):
7170
try:
7271
print self.file_path
@@ -77,7 +76,7 @@ def initLogFolder(self):
7776
if not os.path.exists(self.file_path + "/logs/"):
7877
os.makedirs("logs")
7978

80-
except Exception as e :
79+
except Exception as e:
8180
print 'error makedir in log lib {}'.format(str(e))
8281
except IOError:
8382
print "Ошибка создания каталога logs" \
@@ -90,8 +89,8 @@ def init_logging(self):
9089
formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s')
9190
self.initLogFolder()
9291

93-
if (plfm == 'windows'):
94-
file_ = self.file_path + "\\logs\\" + self.file_name + "_" + strftime('%d_%m_%Y', gmtime())+ ".txt"
92+
if plfm == 'windows':
93+
file_ = self.file_path + "\\logs\\" + self.file_name + "_" + strftime('%d_%m_%Y', gmtime()) + ".txt"
9594
else:
9695
file_ = self.file_path + "/logs/" + self.file_name + "_" + strftime('%d_%m_%Y', gmtime()) + ".txt"
9796

0 commit comments

Comments
 (0)