LogFly 2.3__tar.gz → 2.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {logfly-2.3/src/logfly.egg-info → logfly-2.5}/PKG-INFO +2 -6
- {logfly-2.3 → logfly-2.5}/README.md +1 -1
- {logfly-2.3 → logfly-2.5}/setup.py +1 -1
- {logfly-2.3 → logfly-2.5}/src/logfly/__init__.py +36 -8
- {logfly-2.3 → logfly-2.5/src/logfly.egg-info}/PKG-INFO +2 -6
- {logfly-2.3 → logfly-2.5}/LICENSE +0 -0
- {logfly-2.3 → logfly-2.5}/pyproject.toml +0 -0
- {logfly-2.3 → logfly-2.5}/setup.cfg +0 -0
- {logfly-2.3 → logfly-2.5}/src/logfly.egg-info/SOURCES.txt +0 -0
- {logfly-2.3 → logfly-2.5}/src/logfly.egg-info/dependency_links.txt +0 -0
- {logfly-2.3 → logfly-2.5}/src/logfly.egg-info/requires.txt +0 -0
- {logfly-2.3 → logfly-2.5}/src/logfly.egg-info/top_level.txt +0 -0
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: logfly
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.5
|
|
4
4
|
Summary: A simple log tool by python
|
|
5
5
|
Home-page: https://about.guki.me
|
|
6
6
|
Author: Yuan Sui
|
|
7
7
|
Author-email: orisui@icloud.com
|
|
8
|
-
License: UNKNOWN
|
|
9
8
|
Project-URL: Github, https://github.com/tinqlo/logfly
|
|
10
|
-
Platform: UNKNOWN
|
|
11
9
|
Classifier: Programming Language :: Python :: 3
|
|
12
10
|
Classifier: License :: OSI Approved :: MIT License
|
|
13
11
|
Classifier: Operating System :: OS Independent
|
|
@@ -15,7 +13,7 @@ Requires-Python: >=3.6
|
|
|
15
13
|
Description-Content-Type: text/markdown
|
|
16
14
|
License-File: LICENSE
|
|
17
15
|
|
|
18
|
-
# logfly 2.
|
|
16
|
+
# logfly 2.4
|
|
19
17
|
### a simple log tool by python.
|
|
20
18
|
|
|
21
19
|
## position
|
|
@@ -53,5 +51,3 @@ if use hidden, log will also appear in user/.1o9f1y folder.
|
|
|
53
51
|
#### Description
|
|
54
52
|
pathfile is the file path that you want to create, must fill with '//'
|
|
55
53
|
filenname is the file name that you want to create, must is with '*.*'
|
|
56
|
-
|
|
57
|
-
|
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
#####################
|
|
2
2
|
# Author: Yuki Sui
|
|
3
|
-
# Date:
|
|
3
|
+
# Date: 2023-8-7
|
|
4
4
|
#####################
|
|
5
5
|
|
|
6
6
|
import time
|
|
7
7
|
import shutil
|
|
8
8
|
import os
|
|
9
9
|
from pathlib import Path
|
|
10
|
+
import subprocess
|
|
11
|
+
|
|
10
12
|
try:
|
|
11
13
|
from colorama import init
|
|
14
|
+
|
|
12
15
|
__colorama_init__ = True
|
|
13
|
-
except
|
|
16
|
+
except ModuleNotFoundError:
|
|
14
17
|
__colorama_init__ = False
|
|
15
18
|
pass
|
|
16
19
|
|
|
17
|
-
if __colorama_init__
|
|
20
|
+
if __colorama_init__:
|
|
18
21
|
init(autoreset=True)
|
|
19
22
|
else:
|
|
20
23
|
pass
|
|
21
24
|
|
|
22
|
-
__version__ = '2.
|
|
25
|
+
__version__ = '2.5'
|
|
23
26
|
|
|
24
27
|
|
|
25
28
|
def create_or_check_file(pathorfile, name, warning='yes'):
|
|
@@ -145,13 +148,15 @@ def write_log(name, position, level, message, mode='add',
|
|
|
145
148
|
elif color == 'yes':
|
|
146
149
|
LogFlyMessage = name + ' ' + get_time('datetime') + ' ' + '[' + str.upper(level) + ']' + ' ' + message + \
|
|
147
150
|
'\r\n '
|
|
148
|
-
if __colorama_init__
|
|
151
|
+
if __colorama_init__:
|
|
149
152
|
if str.upper(level) == 'INFO':
|
|
150
153
|
print(f'\033[0;34m{LogFlyMessage}\033[0m')
|
|
151
154
|
elif str.upper(level) == 'WARNING':
|
|
152
155
|
print(f'\033[0;33m{LogFlyMessage}\033[0m')
|
|
153
156
|
elif str.upper(level) == 'ERROR':
|
|
154
157
|
print(f'\033[0;31m{LogFlyMessage}\033[0m')
|
|
158
|
+
elif str.upper(level) == 'PASS':
|
|
159
|
+
print(f'\033[0;32m{LogFlyMessage}\033[0m')
|
|
155
160
|
else:
|
|
156
161
|
print(f'\033[0;37m{LogFlyMessage}\033[0m')
|
|
157
162
|
else:
|
|
@@ -170,6 +175,8 @@ def write_log(name, position, level, message, mode='add',
|
|
|
170
175
|
File = open(LOGFILE2, 'a', newline='', encoding='utf-8')
|
|
171
176
|
File.write(get_time('datetime') + ' ' + '[' + str.upper(level) + ']' + ' ' + message + '\r\n')
|
|
172
177
|
File.close()
|
|
178
|
+
elif hidden == 'no':
|
|
179
|
+
pass
|
|
173
180
|
else:
|
|
174
181
|
mesg = str(message) + '\r\n\r\n'
|
|
175
182
|
print(mesg)
|
|
@@ -195,13 +202,15 @@ def write_log(name, position, level, message, mode='add',
|
|
|
195
202
|
elif color == 'yes':
|
|
196
203
|
LogFlyMessage = name + ' ' + get_time('datetime') + ' ' + '[' + str.upper(level) + ']' + ' ' + message + \
|
|
197
204
|
'\r\n '
|
|
198
|
-
if __colorama_init__
|
|
205
|
+
if __colorama_init__:
|
|
199
206
|
if str.upper(level) == 'INFO':
|
|
200
207
|
print(f'\033[0;34m{LogFlyMessage}\033[0m')
|
|
201
208
|
elif str.upper(level) == 'WARNING':
|
|
202
209
|
print(f'\033[0;33m{LogFlyMessage}\033[0m')
|
|
203
210
|
elif str.upper(level) == 'ERROR':
|
|
204
211
|
print(f'\033[0;31m{LogFlyMessage}\033[0m')
|
|
212
|
+
elif str.upper(level) == 'PASS':
|
|
213
|
+
print(f'\033[0;32m{LogFlyMessage}\033[0m')
|
|
205
214
|
else:
|
|
206
215
|
print(f'\033[0;37m{LogFlyMessage}\033[0m')
|
|
207
216
|
else:
|
|
@@ -255,7 +264,25 @@ def mv_file(original_file_name, new_file_name, folder_name='mv_file'):
|
|
|
255
264
|
write_log('logfly-log', 'CLI', 'error', message, folder_name=folder_name)
|
|
256
265
|
|
|
257
266
|
|
|
258
|
-
def
|
|
267
|
+
def run_cmd(cmd):
|
|
268
|
+
p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
|
269
|
+
while True:
|
|
270
|
+
result = p.stdout.readline() # 默认获取到的是二进制内容
|
|
271
|
+
if result != b'': # 获取内容不为空时
|
|
272
|
+
try:
|
|
273
|
+
print(result.decode('gbk').strip('\r\n')) # 处理GBK编码的输出,去掉结尾换行
|
|
274
|
+
write_log('logfly-log', 'file', 'info', message=result.decode('gbk').strip('\r\n'))
|
|
275
|
+
return result.decode('gbk').strip('\r\n')
|
|
276
|
+
except Exception as e:
|
|
277
|
+
print(e)
|
|
278
|
+
print(result.decode('utf-8').strip('\r\n')) # 如果GBK解码失败再尝试UTF-8解码
|
|
279
|
+
write_log('logfly-log', 'file', 'info', message=result.decode('utf-8').strip('\r\n'))
|
|
280
|
+
return result.decode('utf-8').strip('\r\n')
|
|
281
|
+
else:
|
|
282
|
+
break
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
def error(exp, linenum, mode='logfly'):
|
|
259
286
|
if mode == 'logfly':
|
|
260
287
|
logflyErrorMessage = 'ERROR occurred! at row ' + str(linenum) + '\r\n\r\n' + str(
|
|
261
288
|
exp) + "\r\n\r\nplease re-check it! \r\nAnd you can see the " \
|
|
@@ -274,4 +301,5 @@ class ParameterERROR(Exception):
|
|
|
274
301
|
|
|
275
302
|
|
|
276
303
|
if __name__ == '__main__':
|
|
277
|
-
write_log('logfly-log', 'CLI', '
|
|
304
|
+
# write_log('logfly-log', 'CLI', 'pass', 'test', hidden='yes')
|
|
305
|
+
run_cmd("echo 111111")
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: logfly
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.5
|
|
4
4
|
Summary: A simple log tool by python
|
|
5
5
|
Home-page: https://about.guki.me
|
|
6
6
|
Author: Yuan Sui
|
|
7
7
|
Author-email: orisui@icloud.com
|
|
8
|
-
License: UNKNOWN
|
|
9
8
|
Project-URL: Github, https://github.com/tinqlo/logfly
|
|
10
|
-
Platform: UNKNOWN
|
|
11
9
|
Classifier: Programming Language :: Python :: 3
|
|
12
10
|
Classifier: License :: OSI Approved :: MIT License
|
|
13
11
|
Classifier: Operating System :: OS Independent
|
|
@@ -15,7 +13,7 @@ Requires-Python: >=3.6
|
|
|
15
13
|
Description-Content-Type: text/markdown
|
|
16
14
|
License-File: LICENSE
|
|
17
15
|
|
|
18
|
-
# logfly 2.
|
|
16
|
+
# logfly 2.4
|
|
19
17
|
### a simple log tool by python.
|
|
20
18
|
|
|
21
19
|
## position
|
|
@@ -53,5 +51,3 @@ if use hidden, log will also appear in user/.1o9f1y folder.
|
|
|
53
51
|
#### Description
|
|
54
52
|
pathfile is the file path that you want to create, must fill with '//'
|
|
55
53
|
filenname is the file name that you want to create, must is with '*.*'
|
|
56
|
-
|
|
57
|
-
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|