LogFly 2.2__tar.gz → 2.4__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: logfly
3
- Version: 2.2
3
+ Version: 2.4
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.2
18
+ # logfly 2.4
19
19
  ### a simple log tool by python.
20
20
 
21
21
  ## position
@@ -1,4 +1,4 @@
1
- # logfly 2.2
1
+ # logfly 2.4
2
2
  ### a simple log tool by python.
3
3
 
4
4
  ## position
@@ -5,7 +5,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
5
5
 
6
6
  setuptools.setup(
7
7
  name="logfly",
8
- version="2.2",
8
+ version="2.4",
9
9
  author="Yuan Sui",
10
10
  author_email="orisui@icloud.com",
11
11
  description="A simple log tool by python",
@@ -1,16 +1,25 @@
1
1
  #####################
2
2
  # Author: Yuki Sui
3
- # Date: 2022-3-16
3
+ # Date: 2022-5-1
4
4
  #####################
5
5
 
6
6
  import time
7
7
  import shutil
8
8
  import os
9
9
  from pathlib import Path
10
- from colorama import init
10
+ try:
11
+ from colorama import init
12
+ __colorama_init__ = True
13
+ except ModuleNotFoundError:
14
+ __colorama_init__ = False
15
+ pass
11
16
 
12
- init(autoreset=True)
13
- __version__ = '2.2'
17
+ if __colorama_init__:
18
+ init(autoreset=True)
19
+ else:
20
+ pass
21
+
22
+ __version__ = '2.4'
14
23
 
15
24
 
16
25
  def create_or_check_file(pathorfile, name, warning='yes'):
@@ -136,14 +145,19 @@ def write_log(name, position, level, message, mode='add',
136
145
  elif color == 'yes':
137
146
  LogFlyMessage = name + ' ' + get_time('datetime') + ' ' + '[' + str.upper(level) + ']' + ' ' + message + \
138
147
  '\r\n '
139
- if str.upper(level) == 'INFO':
140
- print(f'\033[0;34m{LogFlyMessage}\033[0m')
141
- elif str.upper(level) == 'WARNING':
142
- print(f'\033[0;33m{LogFlyMessage}\033[0m')
143
- elif str.upper(level) == 'ERROR':
144
- print(f'\033[0;31m{LogFlyMessage}\033[0m')
148
+ if __colorama_init__:
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
+ elif str.upper(level) == 'PASS':
156
+ print(f'\033[0;32m{LogFlyMessage}\033[0m')
157
+ else:
158
+ print(f'\033[0;37m{LogFlyMessage}\033[0m')
145
159
  else:
146
- print(f'\033[0;37m{LogFlyMessage}\033[0m')
160
+ print(LogFlyMessage)
147
161
  else:
148
162
  mesg = str(message) + '\r\n\r\n'
149
163
  print(mesg)
@@ -183,14 +197,19 @@ def write_log(name, position, level, message, mode='add',
183
197
  elif color == 'yes':
184
198
  LogFlyMessage = name + ' ' + get_time('datetime') + ' ' + '[' + str.upper(level) + ']' + ' ' + message + \
185
199
  '\r\n '
186
- if str.upper(level) == 'INFO':
187
- print(f'\033[0;34m{LogFlyMessage}\033[0m')
188
- elif str.upper(level) == 'WARNING':
189
- print(f'\033[0;33m{LogFlyMessage}\033[0m')
190
- elif str.upper(level) == 'ERROR':
191
- print(f'\033[0;31m{LogFlyMessage}\033[0m')
200
+ if __colorama_init__:
201
+ if str.upper(level) == 'INFO':
202
+ print(f'\033[0;34m{LogFlyMessage}\033[0m')
203
+ elif str.upper(level) == 'WARNING':
204
+ print(f'\033[0;33m{LogFlyMessage}\033[0m')
205
+ elif str.upper(level) == 'ERROR':
206
+ print(f'\033[0;31m{LogFlyMessage}\033[0m')
207
+ elif str.upper(level) == 'PASS':
208
+ print(f'\033[0;32m{LogFlyMessage}\033[0m')
209
+ else:
210
+ print(f'\033[0;37m{LogFlyMessage}\033[0m')
192
211
  else:
193
- print(f'\033[0;37m{LogFlyMessage}\033[0m')
212
+ print(LogFlyMessage)
194
213
  else:
195
214
  mesg = str(message) + '\r\n\r\n'
196
215
  print(mesg)
@@ -259,4 +278,4 @@ class ParameterERROR(Exception):
259
278
 
260
279
 
261
280
  if __name__ == '__main__':
262
- write_log('logfly-log', 'fileCLI', 'error', 'test', hidden='yes')
281
+ write_log('logfly-log', 'CLI', 'pass', 'test', hidden='yes')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: logfly
3
- Version: 2.2
3
+ Version: 2.4
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.2
18
+ # logfly 2.4
19
19
  ### a simple log tool by python.
20
20
 
21
21
  ## position
File without changes
File without changes
File without changes