LogFly 1.2__tar.gz → 1.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-1.3/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Yukikawa
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: logfly
3
- Version: 1.2
3
+ Version: 1.3
4
4
  Summary: Aa simple log tool by python
5
5
  Home-page: https://about.guki.me
6
6
  Author: Yuan Sui
@@ -13,8 +13,9 @@ Classifier: License :: OSI Approved :: MIT License
13
13
  Classifier: Operating System :: OS Independent
14
14
  Requires-Python: >=3.6
15
15
  Description-Content-Type: text/markdown
16
+ License-File: LICENSE
16
17
 
17
- # logfly 1.1
18
+ # logfly 1.3
18
19
  ### a simple log tool by python
19
20
 
20
21
  ## position
@@ -25,7 +26,7 @@ if use hidden, log will also appear in user/.1o9f1y folder
25
26
  ### import
26
27
  import logfly
27
28
  ### use
28
- logfly.write_log('name', 'where', 'info', 'message', mode='add', folder_name='logflys', hidden='no')
29
+ logfly.write_log('name', 'where', 'info', 'message', mode='add', folder_name='logflys', hidden='no', color='yes')
29
30
 
30
31
  ## Description
31
32
  name: (any str) logfile name, you can use diffrent string to create diffrent logfile.
@@ -39,6 +40,7 @@ if use hidden, log will also appear in user/.1o9f1y folder
39
40
  'new' means logfile will create when program every once.
40
41
  folder_name: (any str) custom logfly folder name, default is 'logflys'.
41
42
  hidden: ('yes', 'no') default is 'no', means logfile will save a copy in user/.1o9f1y folder
43
+ color: ('yes', 'no') default is 'yes', means log will with color.
42
44
 
43
45
  ## Example:
44
46
 
@@ -1,4 +1,4 @@
1
- # logfly 1.1
1
+ # logfly 1.3
2
2
  ### a simple log tool by python
3
3
 
4
4
  ## position
@@ -9,7 +9,7 @@ if use hidden, log will also appear in user/.1o9f1y folder
9
9
  ### import
10
10
  import logfly
11
11
  ### use
12
- logfly.write_log('name', 'where', 'info', 'message', mode='add', folder_name='logflys', hidden='no')
12
+ logfly.write_log('name', 'where', 'info', 'message', mode='add', folder_name='logflys', hidden='no', color='yes')
13
13
 
14
14
  ## Description
15
15
  name: (any str) logfile name, you can use diffrent string to create diffrent logfile.
@@ -23,6 +23,7 @@ if use hidden, log will also appear in user/.1o9f1y folder
23
23
  'new' means logfile will create when program every once.
24
24
  folder_name: (any str) custom logfly folder name, default is 'logflys'.
25
25
  hidden: ('yes', 'no') default is 'no', means logfile will save a copy in user/.1o9f1y folder
26
+ color: ('yes', 'no') default is 'yes', means log will with color.
26
27
 
27
28
  ## Example:
28
29
 
@@ -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="1.2",
8
+ version="1.3",
9
9
  author="Yuan Sui",
10
10
  author_email="orisui@icloud.com",
11
11
  description="Aa simple log tool by python",
@@ -1,12 +1,15 @@
1
1
  #####################
2
2
  # Author: Yuki Sui
3
- # Date: 2021-11-14
4
- # Version: 1.2
3
+ # Date: 2021-12-05
4
+ # Version: 1.3
5
5
  #####################
6
6
 
7
7
  import time
8
8
  import os
9
9
  from pathlib import Path
10
+ from colorama import init
11
+
12
+ init(autoreset=True)
10
13
 
11
14
 
12
15
  def create_log_folder(folder_name, hidden):
@@ -39,7 +42,7 @@ def get_time(flag):
39
42
  return time.strftime("%Y%m%d%H%M%S", time.localtime())
40
43
 
41
44
 
42
- def write_log(name, position, level, message, mode='add', folder_name='logflys', hidden='no'):
45
+ def write_log(name, position, level, message, mode='add', folder_name='logflys', hidden='no', color='yes'):
43
46
  global LOGFILE, LOGFILE2, logfolder, logfolder_hidden, LOGFILE_hidden
44
47
  if hidden == "no":
45
48
  logfolder = '.\\logs\\' + folder_name + '\\' + get_time('date') + '\\'
@@ -52,10 +55,26 @@ def write_log(name, position, level, message, mode='add', folder_name='logflys',
52
55
  elif mode == 'new':
53
56
  LOGFILE_hidden = name + '-' + get_time('datetimefile') + '.log'
54
57
  LOGFILE = logfolder + name + '-' + get_time('datetimefile') + '.log'
58
+ else:
59
+ error()
55
60
  create_log_folder(folder_name, hidden)
56
61
  if position == 'CLI':
57
- print(name + ' ' + get_time('datetime') + ' ' + '[' + str.upper(level) + ']' + ' ' + message + '\r\n')
58
- if position == 'file':
62
+ if color == 'no':
63
+ print(name + ' ' + get_time('datetime') + ' ' + '[' + str.upper(level) + ']' + ' ' + message + '\r\n')
64
+ elif color == 'yes':
65
+ LogFlyMessage = name + ' ' + get_time('datetime') + ' ' + '[' + str.upper(level) + ']' + ' ' + message + \
66
+ '\r\n '
67
+ if level == 'info':
68
+ print(f'\033[0;34m{LogFlyMessage}\033[0m')
69
+ elif level == 'warning':
70
+ print(f'\033[0;33m{LogFlyMessage}\033[0m')
71
+ elif level == 'error':
72
+ print(f'\033[0;31m{LogFlyMessage}\033[0m')
73
+ else:
74
+ print(f'\033[0;37m{LogFlyMessage}\033[0m')
75
+ else:
76
+ error()
77
+ elif position == 'file':
59
78
  if mode == 'add':
60
79
  File = open(LOGFILE, 'a', newline='')
61
80
  File.write(get_time('datetime') + ' ' + '[' + str.upper(level) + ']' + ' ' + message + '\r\n')
@@ -74,8 +93,24 @@ def write_log(name, position, level, message, mode='add', folder_name='logflys',
74
93
  File = open(LOGFILE2, 'a', newline='')
75
94
  File.write(get_time('datetime') + ' ' + '[' + str.upper(level) + ']' + ' ' + message + '\r\n')
76
95
  File.close()
77
- if position == 'fileCLI':
78
- print(name + ' ' + get_time('datetime') + ' ' + '[' + str.upper(level) + ']' + ' ' + message + '\r\n')
96
+ else:
97
+ error()
98
+ elif position == 'fileCLI':
99
+ if color == 'no':
100
+ print(name + ' ' + get_time('datetime') + ' ' + '[' + str.upper(level) + ']' + ' ' + message + '\r\n')
101
+ elif color == 'yes':
102
+ LogFlyMessage = name + ' ' + get_time('datetime') + ' ' + '[' + str.upper(level) + ']' + ' ' + message + \
103
+ '\r\n '
104
+ if level == 'info':
105
+ print(f'\033[0;34m{LogFlyMessage}\033[0m')
106
+ elif level == 'warning':
107
+ print(f'\033[0;33m{LogFlyMessage}\033[0m')
108
+ elif level == 'error':
109
+ print(f'\033[0;31m{LogFlyMessage}\033[0m')
110
+ else:
111
+ print(f'\033[0;37m{LogFlyMessage}\033[0m')
112
+ else:
113
+ error()
79
114
  if mode == 'add':
80
115
  File = open(LOGFILE, 'a', newline='')
81
116
  File.write(get_time('datetime') + ' ' + '[' + str.upper(level) + ']' + ' ' + message + '\r\n')
@@ -94,10 +129,21 @@ def write_log(name, position, level, message, mode='add', folder_name='logflys',
94
129
  File = open(LOGFILE2, 'a', newline='')
95
130
  File.write(get_time('datetime') + ' ' + '[' + str.upper(level) + ']' + ' ' + message + '\r\n')
96
131
  File.close()
132
+ else:
133
+ error()
134
+ else:
135
+ error()
136
+
137
+
138
+ def error():
139
+ logflyErrorMessage = 'your parameter is wrong, please re-check it!'
140
+ write_log('logfly-log', 'CLI', 'error', logflyErrorMessage)
97
141
 
98
142
 
99
143
  if __name__ == '__main__':
100
144
  write_log('Doctor Who', 'CLI', 'info', "this is Doctor's log, only in CLI.")
145
+ write_log('Doctor Who', 'CLI', 'warning', "this is Doctor's log, only in CLI.")
146
+ write_log('Doctor Who', 'CLI', 'error', "this is Doctor's log, only in CLI.")
101
147
  write_log('Doctor Who', 'fileCLI', 'info', "this is Doctor's log, in file and CLI.", mode='add')
102
148
  write_log('Doctor Who', 'file', 'info', "this is Doctor's log, only in file.")
103
149
  write_log('Tardis', 'CLI', 'info', "this is Tardis's log, only in CLI.")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: logfly
3
- Version: 1.2
3
+ Version: 1.3
4
4
  Summary: Aa simple log tool by python
5
5
  Home-page: https://about.guki.me
6
6
  Author: Yuan Sui
@@ -13,8 +13,9 @@ Classifier: License :: OSI Approved :: MIT License
13
13
  Classifier: Operating System :: OS Independent
14
14
  Requires-Python: >=3.6
15
15
  Description-Content-Type: text/markdown
16
+ License-File: LICENSE
16
17
 
17
- # logfly 1.1
18
+ # logfly 1.3
18
19
  ### a simple log tool by python
19
20
 
20
21
  ## position
@@ -25,7 +26,7 @@ if use hidden, log will also appear in user/.1o9f1y folder
25
26
  ### import
26
27
  import logfly
27
28
  ### use
28
- logfly.write_log('name', 'where', 'info', 'message', mode='add', folder_name='logflys', hidden='no')
29
+ logfly.write_log('name', 'where', 'info', 'message', mode='add', folder_name='logflys', hidden='no', color='yes')
29
30
 
30
31
  ## Description
31
32
  name: (any str) logfile name, you can use diffrent string to create diffrent logfile.
@@ -39,6 +40,7 @@ if use hidden, log will also appear in user/.1o9f1y folder
39
40
  'new' means logfile will create when program every once.
40
41
  folder_name: (any str) custom logfly folder name, default is 'logflys'.
41
42
  hidden: ('yes', 'no') default is 'no', means logfile will save a copy in user/.1o9f1y folder
43
+ color: ('yes', 'no') default is 'yes', means log will with color.
42
44
 
43
45
  ## Example:
44
46
 
@@ -1,3 +1,4 @@
1
+ LICENSE
1
2
  README.md
2
3
  pyproject.toml
3
4
  setup.py
File without changes
File without changes