LogFly 2.0__tar.gz → 2.2__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.0/src/logfly.egg-info → logfly-2.2}/PKG-INFO +6 -6
- {logfly-2.0 → logfly-2.2}/README.md +5 -5
- {logfly-2.0 → logfly-2.2}/setup.py +1 -1
- {logfly-2.0 → logfly-2.2}/src/logfly/__init__.py +29 -4
- {logfly-2.0 → logfly-2.2/src/logfly.egg-info}/PKG-INFO +6 -6
- {logfly-2.0 → logfly-2.2}/LICENSE +0 -0
- {logfly-2.0 → logfly-2.2}/pyproject.toml +0 -0
- {logfly-2.0 → logfly-2.2}/setup.cfg +0 -0
- {logfly-2.0 → logfly-2.2}/src/logfly.egg-info/SOURCES.txt +0 -0
- {logfly-2.0 → logfly-2.2}/src/logfly.egg-info/dependency_links.txt +0 -0
- {logfly-2.0 → logfly-2.2}/src/logfly.egg-info/requires.txt +0 -0
- {logfly-2.0 → logfly-2.2}/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.2
|
|
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.2
|
|
19
19
|
### a simple log tool by python.
|
|
20
20
|
|
|
21
21
|
## position
|
|
@@ -25,8 +25,8 @@ if use hidden, log will also appear in user/.1o9f1y folder.
|
|
|
25
25
|
## How to
|
|
26
26
|
### import
|
|
27
27
|
import logfly
|
|
28
|
-
###
|
|
29
|
-
logfly.write_log('name', 'where', 'info', 'message', mode='add', folder_name='
|
|
28
|
+
### write_log
|
|
29
|
+
logfly.write_log('name', 'where', 'info', 'message', mode='add', folder_name='default-log', hidden='no', color='yes', str_message='yes')
|
|
30
30
|
|
|
31
31
|
#### Description
|
|
32
32
|
name: (any str) logfile name, you can use diffrent string to create diffrent logfile.
|
|
@@ -38,12 +38,12 @@ if use hidden, log will also appear in user/.1o9f1y folder.
|
|
|
38
38
|
message: (any str) log message.
|
|
39
39
|
mode: ('add', 'new') default is 'add', means log will add in same day.
|
|
40
40
|
'new' means logfile will create when program every once.
|
|
41
|
-
folder_name: (any str) custom logfly folder name, default is '
|
|
41
|
+
folder_name: (any str) custom logfly folder name, default is 'default-log'.
|
|
42
42
|
hidden: ('yes', 'no') default is 'no', means logfile will save a copy in user/.1o9f1y folder
|
|
43
43
|
color: ('yes', 'no') default is 'yes', means log will with color.
|
|
44
44
|
str_message: ('yes', 'no') default is 'yes', means log will print message with str()
|
|
45
45
|
|
|
46
|
-
###
|
|
46
|
+
### create_or_check_file
|
|
47
47
|
create_or_check_file(pathorfile, name, warning='yes'):
|
|
48
48
|
create or check file.
|
|
49
49
|
pathorfile: ('file', 'path') choose to create file or path.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# logfly 2.
|
|
1
|
+
# logfly 2.2
|
|
2
2
|
### a simple log tool by python.
|
|
3
3
|
|
|
4
4
|
## position
|
|
@@ -8,8 +8,8 @@ if use hidden, log will also appear in user/.1o9f1y folder.
|
|
|
8
8
|
## How to
|
|
9
9
|
### import
|
|
10
10
|
import logfly
|
|
11
|
-
###
|
|
12
|
-
logfly.write_log('name', 'where', 'info', 'message', mode='add', folder_name='
|
|
11
|
+
### write_log
|
|
12
|
+
logfly.write_log('name', 'where', 'info', 'message', mode='add', folder_name='default-log', hidden='no', color='yes', str_message='yes')
|
|
13
13
|
|
|
14
14
|
#### Description
|
|
15
15
|
name: (any str) logfile name, you can use diffrent string to create diffrent logfile.
|
|
@@ -21,12 +21,12 @@ if use hidden, log will also appear in user/.1o9f1y folder.
|
|
|
21
21
|
message: (any str) log message.
|
|
22
22
|
mode: ('add', 'new') default is 'add', means log will add in same day.
|
|
23
23
|
'new' means logfile will create when program every once.
|
|
24
|
-
folder_name: (any str) custom logfly folder name, default is '
|
|
24
|
+
folder_name: (any str) custom logfly folder name, default is 'default-log'.
|
|
25
25
|
hidden: ('yes', 'no') default is 'no', means logfile will save a copy in user/.1o9f1y folder
|
|
26
26
|
color: ('yes', 'no') default is 'yes', means log will with color.
|
|
27
27
|
str_message: ('yes', 'no') default is 'yes', means log will print message with str()
|
|
28
28
|
|
|
29
|
-
###
|
|
29
|
+
### create_or_check_file
|
|
30
30
|
create_or_check_file(pathorfile, name, warning='yes'):
|
|
31
31
|
create or check file.
|
|
32
32
|
pathorfile: ('file', 'path') choose to create file or path.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#####################
|
|
2
2
|
# Author: Yuki Sui
|
|
3
|
-
# Date: 2022-3-
|
|
3
|
+
# Date: 2022-3-16
|
|
4
4
|
#####################
|
|
5
5
|
|
|
6
6
|
import time
|
|
@@ -10,7 +10,7 @@ from pathlib import Path
|
|
|
10
10
|
from colorama import init
|
|
11
11
|
|
|
12
12
|
init(autoreset=True)
|
|
13
|
-
__version__ = '2.
|
|
13
|
+
__version__ = '2.2'
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
def create_or_check_file(pathorfile, name, warning='yes'):
|
|
@@ -38,7 +38,7 @@ def create_or_check_file(pathorfile, name, warning='yes'):
|
|
|
38
38
|
error(e, linenum)
|
|
39
39
|
|
|
40
40
|
|
|
41
|
-
def create_log_folder(folder_name, hidden):
|
|
41
|
+
def create_log_folder(folder_name, hidden='no'):
|
|
42
42
|
dirs = '.\\logs\\'
|
|
43
43
|
dirs2 = '.\\logs\\' + folder_name + '\\' + get_time('date') + '\\'
|
|
44
44
|
dirs3 = str(Path.home()) + '\\.1o9f1y\\' + folder_name + '\\' + get_time('date') + '\\'
|
|
@@ -98,14 +98,17 @@ def time_transfer(time_stamp, flag='timestamp2datetime'):
|
|
|
98
98
|
|
|
99
99
|
# noinspection PyTypeChecker
|
|
100
100
|
def write_log(name, position, level, message, mode='add',
|
|
101
|
-
folder_name='
|
|
101
|
+
folder_name='default-log', hidden='no', color='yes', str_message='yes'):
|
|
102
102
|
global LOGFILE, LOGFILE2, logfolder, logfolder_hidden, LOGFILE_hidden
|
|
103
103
|
try:
|
|
104
|
+
create_log_folder(folder_name)
|
|
104
105
|
if str_message == 'yes':
|
|
105
106
|
message = str(message)
|
|
106
107
|
elif str_message == 'no':
|
|
107
108
|
pass
|
|
108
109
|
else:
|
|
110
|
+
mesg = str(message) + '\r\n\r\n'
|
|
111
|
+
print(mesg)
|
|
109
112
|
raise ParameterERROR('function write_log Parameter error! str_message must be "yes" or "no"! ')
|
|
110
113
|
if hidden == "no":
|
|
111
114
|
logfolder = '.\\logs\\' + folder_name + '\\' + get_time('date') + '\\'
|
|
@@ -114,6 +117,8 @@ def write_log(name, position, level, message, mode='add',
|
|
|
114
117
|
logfolder_hidden = str(Path.home()) + '\\.1o9f1y\\' + folder_name + '\\' + get_time('date') + '\\'
|
|
115
118
|
create_log_folder(folder_name, hidden)
|
|
116
119
|
else:
|
|
120
|
+
mesg = str(message) + '\r\n\r\n'
|
|
121
|
+
print(mesg)
|
|
117
122
|
raise ParameterERROR('function write_log Parameter error! hidden must be "no" or "yes"! ')
|
|
118
123
|
if mode == 'add':
|
|
119
124
|
LOGFILE_hidden = name + '-' + get_time('date') + '.log'
|
|
@@ -122,6 +127,8 @@ def write_log(name, position, level, message, mode='add',
|
|
|
122
127
|
LOGFILE_hidden = name + '-' + get_time('datetimefile') + '.log'
|
|
123
128
|
LOGFILE = logfolder + name + '-' + get_time('datetimefile') + '.log'
|
|
124
129
|
else:
|
|
130
|
+
mesg = str(message) + '\r\n\r\n'
|
|
131
|
+
print(mesg)
|
|
125
132
|
raise ParameterERROR('function write_log Parameter error! mode must be "add" or "new"! ')
|
|
126
133
|
if position == 'CLI':
|
|
127
134
|
if color == 'no':
|
|
@@ -138,6 +145,8 @@ def write_log(name, position, level, message, mode='add',
|
|
|
138
145
|
else:
|
|
139
146
|
print(f'\033[0;37m{LogFlyMessage}\033[0m')
|
|
140
147
|
else:
|
|
148
|
+
mesg = str(message) + '\r\n\r\n'
|
|
149
|
+
print(mesg)
|
|
141
150
|
raise ParameterERROR('function write_log Parameter error! color must be "yes" or "no"! ')
|
|
142
151
|
elif position == 'file':
|
|
143
152
|
if mode == 'add':
|
|
@@ -150,6 +159,8 @@ def write_log(name, position, level, message, mode='add',
|
|
|
150
159
|
File.write(get_time('datetime') + ' ' + '[' + str.upper(level) + ']' + ' ' + message + '\r\n')
|
|
151
160
|
File.close()
|
|
152
161
|
else:
|
|
162
|
+
mesg = str(message) + '\r\n\r\n'
|
|
163
|
+
print(mesg)
|
|
153
164
|
raise ParameterERROR('function write_log Parameter error! hidden must be "no" or "yes"! ')
|
|
154
165
|
elif mode == 'new':
|
|
155
166
|
File = open(LOGFILE, 'w', newline='', encoding='utf-8')
|
|
@@ -163,6 +174,8 @@ def write_log(name, position, level, message, mode='add',
|
|
|
163
174
|
elif hidden == 'no':
|
|
164
175
|
pass
|
|
165
176
|
else:
|
|
177
|
+
mesg = str(message) + '\r\n\r\n'
|
|
178
|
+
print(mesg)
|
|
166
179
|
raise ParameterERROR('function write_log Parameter error! hidden must be "no" or "yes"! ')
|
|
167
180
|
elif position == 'fileCLI':
|
|
168
181
|
if color == 'no':
|
|
@@ -179,6 +192,8 @@ def write_log(name, position, level, message, mode='add',
|
|
|
179
192
|
else:
|
|
180
193
|
print(f'\033[0;37m{LogFlyMessage}\033[0m')
|
|
181
194
|
else:
|
|
195
|
+
mesg = str(message) + '\r\n\r\n'
|
|
196
|
+
print(mesg)
|
|
182
197
|
raise ParameterERROR('function write_log Parameter error! color must be "yes" or "no"! ')
|
|
183
198
|
if mode == 'add':
|
|
184
199
|
File = open(LOGFILE, 'a', newline='', encoding='utf-8')
|
|
@@ -192,6 +207,8 @@ def write_log(name, position, level, message, mode='add',
|
|
|
192
207
|
elif hidden == 'no':
|
|
193
208
|
pass
|
|
194
209
|
else:
|
|
210
|
+
mesg = str(message) + '\r\n\r\n'
|
|
211
|
+
print(mesg)
|
|
195
212
|
raise ParameterERROR('function write_log Parameter error! hidden must be "no" or "yes"! ')
|
|
196
213
|
elif mode == 'new':
|
|
197
214
|
File = open(LOGFILE, 'w', newline='', encoding='utf-8')
|
|
@@ -205,8 +222,12 @@ def write_log(name, position, level, message, mode='add',
|
|
|
205
222
|
elif hidden == 'no':
|
|
206
223
|
pass
|
|
207
224
|
else:
|
|
225
|
+
mesg = str(message) + '\r\n\r\n'
|
|
226
|
+
print(mesg)
|
|
208
227
|
raise ParameterERROR('function write_log Parameter error! mode must be "add" or "new"! ')
|
|
209
228
|
else:
|
|
229
|
+
mesg = str(message) + '\r\n\r\n'
|
|
230
|
+
print(mesg)
|
|
210
231
|
raise ParameterERROR('function write_log Parameter error! position must be "file" or "fileCLI"! ')
|
|
211
232
|
except Exception as e:
|
|
212
233
|
linenum = e.__traceback__.tb_lineno
|
|
@@ -235,3 +256,7 @@ def error(exp,linenum, mode='logfly'):
|
|
|
235
256
|
class ParameterERROR(Exception):
|
|
236
257
|
def __init__(self, message):
|
|
237
258
|
self.message = message
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
if __name__ == '__main__':
|
|
262
|
+
write_log('logfly-log', 'fileCLI', 'error', 'test', hidden='yes')
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: logfly
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.2
|
|
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.2
|
|
19
19
|
### a simple log tool by python.
|
|
20
20
|
|
|
21
21
|
## position
|
|
@@ -25,8 +25,8 @@ if use hidden, log will also appear in user/.1o9f1y folder.
|
|
|
25
25
|
## How to
|
|
26
26
|
### import
|
|
27
27
|
import logfly
|
|
28
|
-
###
|
|
29
|
-
logfly.write_log('name', 'where', 'info', 'message', mode='add', folder_name='
|
|
28
|
+
### write_log
|
|
29
|
+
logfly.write_log('name', 'where', 'info', 'message', mode='add', folder_name='default-log', hidden='no', color='yes', str_message='yes')
|
|
30
30
|
|
|
31
31
|
#### Description
|
|
32
32
|
name: (any str) logfile name, you can use diffrent string to create diffrent logfile.
|
|
@@ -38,12 +38,12 @@ if use hidden, log will also appear in user/.1o9f1y folder.
|
|
|
38
38
|
message: (any str) log message.
|
|
39
39
|
mode: ('add', 'new') default is 'add', means log will add in same day.
|
|
40
40
|
'new' means logfile will create when program every once.
|
|
41
|
-
folder_name: (any str) custom logfly folder name, default is '
|
|
41
|
+
folder_name: (any str) custom logfly folder name, default is 'default-log'.
|
|
42
42
|
hidden: ('yes', 'no') default is 'no', means logfile will save a copy in user/.1o9f1y folder
|
|
43
43
|
color: ('yes', 'no') default is 'yes', means log will with color.
|
|
44
44
|
str_message: ('yes', 'no') default is 'yes', means log will print message with str()
|
|
45
45
|
|
|
46
|
-
###
|
|
46
|
+
### create_or_check_file
|
|
47
47
|
create_or_check_file(pathorfile, name, warning='yes'):
|
|
48
48
|
create or check file.
|
|
49
49
|
pathorfile: ('file', 'path') choose to create file or path.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|