LogFly 2.1__tar.gz → 2.3__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.1/src/logfly.egg-info → logfly-2.3}/PKG-INFO +2 -2
- {logfly-2.1 → logfly-2.3}/README.md +1 -1
- {logfly-2.1 → logfly-2.3}/setup.py +1 -1
- {logfly-2.1 → logfly-2.3}/src/logfly/__init__.py +54 -19
- {logfly-2.1 → logfly-2.3/src/logfly.egg-info}/PKG-INFO +2 -2
- {logfly-2.1 → logfly-2.3}/LICENSE +0 -0
- {logfly-2.1 → logfly-2.3}/pyproject.toml +0 -0
- {logfly-2.1 → logfly-2.3}/setup.cfg +0 -0
- {logfly-2.1 → logfly-2.3}/src/logfly.egg-info/SOURCES.txt +0 -0
- {logfly-2.1 → logfly-2.3}/src/logfly.egg-info/dependency_links.txt +0 -0
- {logfly-2.1 → logfly-2.3}/src/logfly.egg-info/requires.txt +0 -0
- {logfly-2.1 → logfly-2.3}/src/logfly.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: logfly
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.3
|
|
4
4
|
Summary: A simple log tool by python
|
|
5
5
|
Home-page: https://about.guki.me
|
|
6
6
|
Author: Yuan Sui
|
|
@@ -15,7 +15,7 @@ Requires-Python: >=3.6
|
|
|
15
15
|
Description-Content-Type: text/markdown
|
|
16
16
|
License-File: LICENSE
|
|
17
17
|
|
|
18
|
-
# logfly 2.
|
|
18
|
+
# logfly 2.3
|
|
19
19
|
### a simple log tool by python.
|
|
20
20
|
|
|
21
21
|
## position
|
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
#####################
|
|
2
2
|
# Author: Yuki Sui
|
|
3
|
-
# Date: 2022-
|
|
3
|
+
# Date: 2022-4-1
|
|
4
4
|
#####################
|
|
5
5
|
|
|
6
6
|
import time
|
|
7
7
|
import shutil
|
|
8
8
|
import os
|
|
9
9
|
from pathlib import Path
|
|
10
|
-
|
|
10
|
+
try:
|
|
11
|
+
from colorama import init
|
|
12
|
+
__colorama_init__ = True
|
|
13
|
+
except Exception:
|
|
14
|
+
__colorama_init__ = False
|
|
15
|
+
pass
|
|
11
16
|
|
|
12
|
-
|
|
13
|
-
|
|
17
|
+
if __colorama_init__ == True:
|
|
18
|
+
init(autoreset=True)
|
|
19
|
+
else:
|
|
20
|
+
pass
|
|
21
|
+
|
|
22
|
+
__version__ = '2.3'
|
|
14
23
|
|
|
15
24
|
|
|
16
25
|
def create_or_check_file(pathorfile, name, warning='yes'):
|
|
@@ -107,6 +116,8 @@ def write_log(name, position, level, message, mode='add',
|
|
|
107
116
|
elif str_message == 'no':
|
|
108
117
|
pass
|
|
109
118
|
else:
|
|
119
|
+
mesg = str(message) + '\r\n\r\n'
|
|
120
|
+
print(mesg)
|
|
110
121
|
raise ParameterERROR('function write_log Parameter error! str_message must be "yes" or "no"! ')
|
|
111
122
|
if hidden == "no":
|
|
112
123
|
logfolder = '.\\logs\\' + folder_name + '\\' + get_time('date') + '\\'
|
|
@@ -115,6 +126,8 @@ def write_log(name, position, level, message, mode='add',
|
|
|
115
126
|
logfolder_hidden = str(Path.home()) + '\\.1o9f1y\\' + folder_name + '\\' + get_time('date') + '\\'
|
|
116
127
|
create_log_folder(folder_name, hidden)
|
|
117
128
|
else:
|
|
129
|
+
mesg = str(message) + '\r\n\r\n'
|
|
130
|
+
print(mesg)
|
|
118
131
|
raise ParameterERROR('function write_log Parameter error! hidden must be "no" or "yes"! ')
|
|
119
132
|
if mode == 'add':
|
|
120
133
|
LOGFILE_hidden = name + '-' + get_time('date') + '.log'
|
|
@@ -123,6 +136,8 @@ def write_log(name, position, level, message, mode='add',
|
|
|
123
136
|
LOGFILE_hidden = name + '-' + get_time('datetimefile') + '.log'
|
|
124
137
|
LOGFILE = logfolder + name + '-' + get_time('datetimefile') + '.log'
|
|
125
138
|
else:
|
|
139
|
+
mesg = str(message) + '\r\n\r\n'
|
|
140
|
+
print(mesg)
|
|
126
141
|
raise ParameterERROR('function write_log Parameter error! mode must be "add" or "new"! ')
|
|
127
142
|
if position == 'CLI':
|
|
128
143
|
if color == 'no':
|
|
@@ -130,15 +145,20 @@ def write_log(name, position, level, message, mode='add',
|
|
|
130
145
|
elif color == 'yes':
|
|
131
146
|
LogFlyMessage = name + ' ' + get_time('datetime') + ' ' + '[' + str.upper(level) + ']' + ' ' + message + \
|
|
132
147
|
'\r\n '
|
|
133
|
-
if
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
148
|
+
if __colorama_init__ == True:
|
|
149
|
+
if str.upper(level) == 'INFO':
|
|
150
|
+
print(f'\033[0;34m{LogFlyMessage}\033[0m')
|
|
151
|
+
elif str.upper(level) == 'WARNING':
|
|
152
|
+
print(f'\033[0;33m{LogFlyMessage}\033[0m')
|
|
153
|
+
elif str.upper(level) == 'ERROR':
|
|
154
|
+
print(f'\033[0;31m{LogFlyMessage}\033[0m')
|
|
155
|
+
else:
|
|
156
|
+
print(f'\033[0;37m{LogFlyMessage}\033[0m')
|
|
139
157
|
else:
|
|
140
|
-
print(
|
|
158
|
+
print(LogFlyMessage)
|
|
141
159
|
else:
|
|
160
|
+
mesg = str(message) + '\r\n\r\n'
|
|
161
|
+
print(mesg)
|
|
142
162
|
raise ParameterERROR('function write_log Parameter error! color must be "yes" or "no"! ')
|
|
143
163
|
elif position == 'file':
|
|
144
164
|
if mode == 'add':
|
|
@@ -151,6 +171,8 @@ def write_log(name, position, level, message, mode='add',
|
|
|
151
171
|
File.write(get_time('datetime') + ' ' + '[' + str.upper(level) + ']' + ' ' + message + '\r\n')
|
|
152
172
|
File.close()
|
|
153
173
|
else:
|
|
174
|
+
mesg = str(message) + '\r\n\r\n'
|
|
175
|
+
print(mesg)
|
|
154
176
|
raise ParameterERROR('function write_log Parameter error! hidden must be "no" or "yes"! ')
|
|
155
177
|
elif mode == 'new':
|
|
156
178
|
File = open(LOGFILE, 'w', newline='', encoding='utf-8')
|
|
@@ -164,6 +186,8 @@ def write_log(name, position, level, message, mode='add',
|
|
|
164
186
|
elif hidden == 'no':
|
|
165
187
|
pass
|
|
166
188
|
else:
|
|
189
|
+
mesg = str(message) + '\r\n\r\n'
|
|
190
|
+
print(mesg)
|
|
167
191
|
raise ParameterERROR('function write_log Parameter error! hidden must be "no" or "yes"! ')
|
|
168
192
|
elif position == 'fileCLI':
|
|
169
193
|
if color == 'no':
|
|
@@ -171,15 +195,20 @@ def write_log(name, position, level, message, mode='add',
|
|
|
171
195
|
elif color == 'yes':
|
|
172
196
|
LogFlyMessage = name + ' ' + get_time('datetime') + ' ' + '[' + str.upper(level) + ']' + ' ' + message + \
|
|
173
197
|
'\r\n '
|
|
174
|
-
if
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
198
|
+
if __colorama_init__ == True:
|
|
199
|
+
if str.upper(level) == 'INFO':
|
|
200
|
+
print(f'\033[0;34m{LogFlyMessage}\033[0m')
|
|
201
|
+
elif str.upper(level) == 'WARNING':
|
|
202
|
+
print(f'\033[0;33m{LogFlyMessage}\033[0m')
|
|
203
|
+
elif str.upper(level) == 'ERROR':
|
|
204
|
+
print(f'\033[0;31m{LogFlyMessage}\033[0m')
|
|
205
|
+
else:
|
|
206
|
+
print(f'\033[0;37m{LogFlyMessage}\033[0m')
|
|
180
207
|
else:
|
|
181
|
-
print(
|
|
208
|
+
print(LogFlyMessage)
|
|
182
209
|
else:
|
|
210
|
+
mesg = str(message) + '\r\n\r\n'
|
|
211
|
+
print(mesg)
|
|
183
212
|
raise ParameterERROR('function write_log Parameter error! color must be "yes" or "no"! ')
|
|
184
213
|
if mode == 'add':
|
|
185
214
|
File = open(LOGFILE, 'a', newline='', encoding='utf-8')
|
|
@@ -193,6 +222,8 @@ def write_log(name, position, level, message, mode='add',
|
|
|
193
222
|
elif hidden == 'no':
|
|
194
223
|
pass
|
|
195
224
|
else:
|
|
225
|
+
mesg = str(message) + '\r\n\r\n'
|
|
226
|
+
print(mesg)
|
|
196
227
|
raise ParameterERROR('function write_log Parameter error! hidden must be "no" or "yes"! ')
|
|
197
228
|
elif mode == 'new':
|
|
198
229
|
File = open(LOGFILE, 'w', newline='', encoding='utf-8')
|
|
@@ -206,8 +237,12 @@ def write_log(name, position, level, message, mode='add',
|
|
|
206
237
|
elif hidden == 'no':
|
|
207
238
|
pass
|
|
208
239
|
else:
|
|
240
|
+
mesg = str(message) + '\r\n\r\n'
|
|
241
|
+
print(mesg)
|
|
209
242
|
raise ParameterERROR('function write_log Parameter error! mode must be "add" or "new"! ')
|
|
210
243
|
else:
|
|
244
|
+
mesg = str(message) + '\r\n\r\n'
|
|
245
|
+
print(mesg)
|
|
211
246
|
raise ParameterERROR('function write_log Parameter error! position must be "file" or "fileCLI"! ')
|
|
212
247
|
except Exception as e:
|
|
213
248
|
linenum = e.__traceback__.tb_lineno
|
|
@@ -239,4 +274,4 @@ class ParameterERROR(Exception):
|
|
|
239
274
|
|
|
240
275
|
|
|
241
276
|
if __name__ == '__main__':
|
|
242
|
-
write_log('logfly-log', '
|
|
277
|
+
write_log('logfly-log', 'CLI', 'error', 'test', hidden='yes')
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: logfly
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.3
|
|
4
4
|
Summary: A simple log tool by python
|
|
5
5
|
Home-page: https://about.guki.me
|
|
6
6
|
Author: Yuan Sui
|
|
@@ -15,7 +15,7 @@ Requires-Python: >=3.6
|
|
|
15
15
|
Description-Content-Type: text/markdown
|
|
16
16
|
License-File: LICENSE
|
|
17
17
|
|
|
18
|
-
# logfly 2.
|
|
18
|
+
# logfly 2.3
|
|
19
19
|
### a simple log tool by python.
|
|
20
20
|
|
|
21
21
|
## position
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|