LogFly 1.1__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,7 +1,7 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: logfly
3
- Version: 1.1
4
- Summary: Aa simple log tool by python
3
+ Version: 1.3
4
+ Summary: Aa 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
@@ -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,10 +5,10 @@ with open("README.md", "r", encoding="utf-8") as fh:
5
5
 
6
6
  setuptools.setup(
7
7
  name="logfly",
8
- version="1.1",
8
+ version="1.3",
9
9
  author="Yuan Sui",
10
10
  author_email="orisui@icloud.com",
11
- description="Aa simple log tool by python ",
11
+ description="Aa simple log tool by python",
12
12
  long_description=long_description,
13
13
  long_description_content_type="text/markdown",
14
14
  url="https://about.guki.me",
@@ -20,7 +20,7 @@ setuptools.setup(
20
20
  "License :: OSI Approved :: MIT License",
21
21
  "Operating System :: OS Independent",
22
22
  ],
23
- package_dir={"": "srcc"},
24
- packages=setuptools.find_packages(where="srcc"),
23
+ package_dir={"": "src"},
24
+ packages=setuptools.find_packages(where="src"),
25
25
  python_requires=">=3.6",
26
- )
26
+ )
@@ -0,0 +1,161 @@
1
+ #####################
2
+ # Author: Yuki Sui
3
+ # Date: 2021-12-05
4
+ # Version: 1.3
5
+ #####################
6
+
7
+ import time
8
+ import os
9
+ from pathlib import Path
10
+ from colorama import init
11
+
12
+ init(autoreset=True)
13
+
14
+
15
+ def create_log_folder(folder_name, hidden):
16
+ dirs = '.\\logs\\'
17
+ dirs2 = '.\\logs\\' + folder_name + '\\' + get_time('date') + '\\'
18
+ dirs3 = str(Path.home()) + '\\.1o9f1y\\' + folder_name + '\\' + get_time('date') + '\\'
19
+ if not os.path.exists(dirs):
20
+ os.makedirs(dirs)
21
+ else:
22
+ pass
23
+ if not os.path.exists(dirs2):
24
+ os.makedirs(dirs2)
25
+ if hidden == 'yes':
26
+ if not os.path.exists(dirs3):
27
+ os.makedirs(dirs3)
28
+ else:
29
+ pass
30
+ else:
31
+ pass
32
+
33
+
34
+ def get_time(flag):
35
+ if flag == 'datetime':
36
+ return time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
37
+ if flag == 'date':
38
+ return time.strftime("%Y-%m-%d", time.localtime())
39
+ if flag == 'times':
40
+ return time.strftime("%H:%M:%S", time.localtime())
41
+ if flag == 'datetimefile':
42
+ return time.strftime("%Y%m%d%H%M%S", time.localtime())
43
+
44
+
45
+ def write_log(name, position, level, message, mode='add', folder_name='logflys', hidden='no', color='yes'):
46
+ global LOGFILE, LOGFILE2, logfolder, logfolder_hidden, LOGFILE_hidden
47
+ if hidden == "no":
48
+ logfolder = '.\\logs\\' + folder_name + '\\' + get_time('date') + '\\'
49
+ elif hidden == 'yes':
50
+ logfolder = '.\\logs\\' + folder_name + '\\' + get_time('date') + '\\'
51
+ logfolder_hidden = str(Path.home()) + '\\.1o9f1y\\' + folder_name + '\\' + get_time('date') + '\\'
52
+ if mode == 'add':
53
+ LOGFILE_hidden = name + '-' + get_time('date') + '.log'
54
+ LOGFILE = logfolder + name + '-' + get_time('date') + '.log'
55
+ elif mode == 'new':
56
+ LOGFILE_hidden = name + '-' + get_time('datetimefile') + '.log'
57
+ LOGFILE = logfolder + name + '-' + get_time('datetimefile') + '.log'
58
+ else:
59
+ error()
60
+ create_log_folder(folder_name, hidden)
61
+ if position == 'CLI':
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':
78
+ if mode == 'add':
79
+ File = open(LOGFILE, 'a', newline='')
80
+ File.write(get_time('datetime') + ' ' + '[' + str.upper(level) + ']' + ' ' + message + '\r\n')
81
+ File.close()
82
+ if hidden == 'yes':
83
+ LOGFILE2 = logfolder_hidden + LOGFILE_hidden
84
+ File = open(LOGFILE2, 'a', newline='')
85
+ File.write(get_time('datetime') + ' ' + '[' + str.upper(level) + ']' + ' ' + message + '\r\n')
86
+ File.close()
87
+ elif mode == 'new':
88
+ File = open(LOGFILE, 'w', newline='')
89
+ File.write(get_time('datetime') + ' ' + '[' + str.upper(level) + ']' + ' ' + message + '\r\n')
90
+ File.close()
91
+ if hidden == 'yes':
92
+ LOGFILE2 = logfolder_hidden + LOGFILE_hidden
93
+ File = open(LOGFILE2, 'a', newline='')
94
+ File.write(get_time('datetime') + ' ' + '[' + str.upper(level) + ']' + ' ' + message + '\r\n')
95
+ File.close()
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()
114
+ if mode == 'add':
115
+ File = open(LOGFILE, 'a', newline='')
116
+ File.write(get_time('datetime') + ' ' + '[' + str.upper(level) + ']' + ' ' + message + '\r\n')
117
+ File.close()
118
+ if hidden == 'yes':
119
+ LOGFILE2 = logfolder_hidden + LOGFILE_hidden
120
+ File = open(LOGFILE2, 'a', newline='')
121
+ File.write(get_time('datetime') + ' ' + '[' + str.upper(level) + ']' + ' ' + message + '\r\n')
122
+ File.close()
123
+ elif mode == 'new':
124
+ File = open(LOGFILE, 'w', newline='')
125
+ File.write(get_time('datetime') + ' ' + '[' + str.upper(level) + ']' + ' ' + message + '\r\n')
126
+ File.close()
127
+ if hidden == 'yes':
128
+ LOGFILE2 = logfolder_hidden + LOGFILE_hidden
129
+ File = open(LOGFILE2, 'a', newline='')
130
+ File.write(get_time('datetime') + ' ' + '[' + str.upper(level) + ']' + ' ' + message + '\r\n')
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)
141
+
142
+
143
+ if __name__ == '__main__':
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.")
147
+ write_log('Doctor Who', 'fileCLI', 'info', "this is Doctor's log, in file and CLI.", mode='add')
148
+ write_log('Doctor Who', 'file', 'info', "this is Doctor's log, only in file.")
149
+ write_log('Tardis', 'CLI', 'info', "this is Tardis's log, only in CLI.")
150
+ write_log('Tardis', 'fileCLI', 'info', "this is Tardis's log, in file and CLI.")
151
+ write_log('Tardis', 'file', 'info', "this is Tardis's log, only in file.")
152
+ write_log('Death', 'fileCLI', 'info', "this is Death's log, in file and CLI.", mode='add', folder_name='death')
153
+
154
+ write_log('Doctor Who', 'CLI', 'info', "this is Doctor's log, only in CLI.", hidden='yes')
155
+ write_log('Doctor Who', 'fileCLI', 'info', "this is Doctor's log, in file and CLI.", mode='add', hidden='yes')
156
+ write_log('Doctor Who', 'file', 'info', "this is Doctor's log, only in file.", hidden='yes')
157
+ write_log('Tardis', 'CLI', 'info', "this is Tardis's log, only in CLI.", hidden='yes')
158
+ write_log('Tardis', 'fileCLI', 'info', "this is Tardis's log, in file and CLI.", hidden='yes')
159
+ write_log('Tardis', 'file', 'info', "this is Tardis's log, only in file.", hidden='yes')
160
+ write_log('Death', 'fileCLI', 'info', "this is Death's log, in file and CLI.",
161
+ mode='add', folder_name='death', hidden='yes')
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: logfly
3
- Version: 1.1
4
- Summary: Aa simple log tool by python
3
+ Version: 1.3
4
+ Summary: Aa 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
@@ -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
 
@@ -0,0 +1,9 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ setup.py
5
+ src/logfly/__init__.py
6
+ src/logfly.egg-info/PKG-INFO
7
+ src/logfly.egg-info/SOURCES.txt
8
+ src/logfly.egg-info/dependency_links.txt
9
+ src/logfly.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ logfly
@@ -1,7 +0,0 @@
1
- README.md
2
- pyproject.toml
3
- setup.py
4
- srcc/logfly.egg-info/PKG-INFO
5
- srcc/logfly.egg-info/SOURCES.txt
6
- srcc/logfly.egg-info/dependency_links.txt
7
- srcc/logfly.egg-info/top_level.txt
@@ -1 +0,0 @@
1
-
File without changes
File without changes