LogFly 1.1__tar.gz → 1.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-1.1 → logfly-1.2}/PKG-INFO +2 -2
- {logfly-1.1 → logfly-1.2}/setup.py +5 -5
- logfly-1.2/src/logfly/__init__.py +115 -0
- {logfly-1.1/srcc → logfly-1.2/src}/logfly.egg-info/PKG-INFO +2 -2
- logfly-1.2/src/logfly.egg-info/SOURCES.txt +8 -0
- logfly-1.2/src/logfly.egg-info/top_level.txt +1 -0
- logfly-1.1/srcc/logfly.egg-info/SOURCES.txt +0 -7
- logfly-1.1/srcc/logfly.egg-info/top_level.txt +0 -1
- {logfly-1.1 → logfly-1.2}/README.md +0 -0
- {logfly-1.1 → logfly-1.2}/pyproject.toml +0 -0
- {logfly-1.1 → logfly-1.2}/setup.cfg +0 -0
- {logfly-1.1/srcc → logfly-1.2/src}/logfly.egg-info/dependency_links.txt +0 -0
|
@@ -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.
|
|
8
|
+
version="1.2",
|
|
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={"": "
|
|
24
|
-
packages=setuptools.find_packages(where="
|
|
23
|
+
package_dir={"": "src"},
|
|
24
|
+
packages=setuptools.find_packages(where="src"),
|
|
25
25
|
python_requires=">=3.6",
|
|
26
|
-
)
|
|
26
|
+
)
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
#####################
|
|
2
|
+
# Author: Yuki Sui
|
|
3
|
+
# Date: 2021-11-14
|
|
4
|
+
# Version: 1.2
|
|
5
|
+
#####################
|
|
6
|
+
|
|
7
|
+
import time
|
|
8
|
+
import os
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def create_log_folder(folder_name, hidden):
|
|
13
|
+
dirs = '.\\logs\\'
|
|
14
|
+
dirs2 = '.\\logs\\' + folder_name + '\\' + get_time('date') + '\\'
|
|
15
|
+
dirs3 = str(Path.home()) + '\\.1o9f1y\\' + folder_name + '\\' + get_time('date') + '\\'
|
|
16
|
+
if not os.path.exists(dirs):
|
|
17
|
+
os.makedirs(dirs)
|
|
18
|
+
else:
|
|
19
|
+
pass
|
|
20
|
+
if not os.path.exists(dirs2):
|
|
21
|
+
os.makedirs(dirs2)
|
|
22
|
+
if hidden == 'yes':
|
|
23
|
+
if not os.path.exists(dirs3):
|
|
24
|
+
os.makedirs(dirs3)
|
|
25
|
+
else:
|
|
26
|
+
pass
|
|
27
|
+
else:
|
|
28
|
+
pass
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def get_time(flag):
|
|
32
|
+
if flag == 'datetime':
|
|
33
|
+
return time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
|
|
34
|
+
if flag == 'date':
|
|
35
|
+
return time.strftime("%Y-%m-%d", time.localtime())
|
|
36
|
+
if flag == 'times':
|
|
37
|
+
return time.strftime("%H:%M:%S", time.localtime())
|
|
38
|
+
if flag == 'datetimefile':
|
|
39
|
+
return time.strftime("%Y%m%d%H%M%S", time.localtime())
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def write_log(name, position, level, message, mode='add', folder_name='logflys', hidden='no'):
|
|
43
|
+
global LOGFILE, LOGFILE2, logfolder, logfolder_hidden, LOGFILE_hidden
|
|
44
|
+
if hidden == "no":
|
|
45
|
+
logfolder = '.\\logs\\' + folder_name + '\\' + get_time('date') + '\\'
|
|
46
|
+
elif hidden == 'yes':
|
|
47
|
+
logfolder = '.\\logs\\' + folder_name + '\\' + get_time('date') + '\\'
|
|
48
|
+
logfolder_hidden = str(Path.home()) + '\\.1o9f1y\\' + folder_name + '\\' + get_time('date') + '\\'
|
|
49
|
+
if mode == 'add':
|
|
50
|
+
LOGFILE_hidden = name + '-' + get_time('date') + '.log'
|
|
51
|
+
LOGFILE = logfolder + name + '-' + get_time('date') + '.log'
|
|
52
|
+
elif mode == 'new':
|
|
53
|
+
LOGFILE_hidden = name + '-' + get_time('datetimefile') + '.log'
|
|
54
|
+
LOGFILE = logfolder + name + '-' + get_time('datetimefile') + '.log'
|
|
55
|
+
create_log_folder(folder_name, hidden)
|
|
56
|
+
if position == 'CLI':
|
|
57
|
+
print(name + ' ' + get_time('datetime') + ' ' + '[' + str.upper(level) + ']' + ' ' + message + '\r\n')
|
|
58
|
+
if position == 'file':
|
|
59
|
+
if mode == 'add':
|
|
60
|
+
File = open(LOGFILE, 'a', newline='')
|
|
61
|
+
File.write(get_time('datetime') + ' ' + '[' + str.upper(level) + ']' + ' ' + message + '\r\n')
|
|
62
|
+
File.close()
|
|
63
|
+
if hidden == 'yes':
|
|
64
|
+
LOGFILE2 = logfolder_hidden + LOGFILE_hidden
|
|
65
|
+
File = open(LOGFILE2, 'a', newline='')
|
|
66
|
+
File.write(get_time('datetime') + ' ' + '[' + str.upper(level) + ']' + ' ' + message + '\r\n')
|
|
67
|
+
File.close()
|
|
68
|
+
elif mode == 'new':
|
|
69
|
+
File = open(LOGFILE, 'w', newline='')
|
|
70
|
+
File.write(get_time('datetime') + ' ' + '[' + str.upper(level) + ']' + ' ' + message + '\r\n')
|
|
71
|
+
File.close()
|
|
72
|
+
if hidden == 'yes':
|
|
73
|
+
LOGFILE2 = logfolder_hidden + LOGFILE_hidden
|
|
74
|
+
File = open(LOGFILE2, 'a', newline='')
|
|
75
|
+
File.write(get_time('datetime') + ' ' + '[' + str.upper(level) + ']' + ' ' + message + '\r\n')
|
|
76
|
+
File.close()
|
|
77
|
+
if position == 'fileCLI':
|
|
78
|
+
print(name + ' ' + get_time('datetime') + ' ' + '[' + str.upper(level) + ']' + ' ' + message + '\r\n')
|
|
79
|
+
if mode == 'add':
|
|
80
|
+
File = open(LOGFILE, 'a', newline='')
|
|
81
|
+
File.write(get_time('datetime') + ' ' + '[' + str.upper(level) + ']' + ' ' + message + '\r\n')
|
|
82
|
+
File.close()
|
|
83
|
+
if hidden == 'yes':
|
|
84
|
+
LOGFILE2 = logfolder_hidden + LOGFILE_hidden
|
|
85
|
+
File = open(LOGFILE2, 'a', newline='')
|
|
86
|
+
File.write(get_time('datetime') + ' ' + '[' + str.upper(level) + ']' + ' ' + message + '\r\n')
|
|
87
|
+
File.close()
|
|
88
|
+
elif mode == 'new':
|
|
89
|
+
File = open(LOGFILE, 'w', newline='')
|
|
90
|
+
File.write(get_time('datetime') + ' ' + '[' + str.upper(level) + ']' + ' ' + message + '\r\n')
|
|
91
|
+
File.close()
|
|
92
|
+
if hidden == 'yes':
|
|
93
|
+
LOGFILE2 = logfolder_hidden + LOGFILE_hidden
|
|
94
|
+
File = open(LOGFILE2, 'a', newline='')
|
|
95
|
+
File.write(get_time('datetime') + ' ' + '[' + str.upper(level) + ']' + ' ' + message + '\r\n')
|
|
96
|
+
File.close()
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
if __name__ == '__main__':
|
|
100
|
+
write_log('Doctor Who', 'CLI', 'info', "this is Doctor's log, only in CLI.")
|
|
101
|
+
write_log('Doctor Who', 'fileCLI', 'info', "this is Doctor's log, in file and CLI.", mode='add')
|
|
102
|
+
write_log('Doctor Who', 'file', 'info', "this is Doctor's log, only in file.")
|
|
103
|
+
write_log('Tardis', 'CLI', 'info', "this is Tardis's log, only in CLI.")
|
|
104
|
+
write_log('Tardis', 'fileCLI', 'info', "this is Tardis's log, in file and CLI.")
|
|
105
|
+
write_log('Tardis', 'file', 'info', "this is Tardis's log, only in file.")
|
|
106
|
+
write_log('Death', 'fileCLI', 'info', "this is Death's log, in file and CLI.", mode='add', folder_name='death')
|
|
107
|
+
|
|
108
|
+
write_log('Doctor Who', 'CLI', 'info', "this is Doctor's log, only in CLI.", hidden='yes')
|
|
109
|
+
write_log('Doctor Who', 'fileCLI', 'info', "this is Doctor's log, in file and CLI.", mode='add', hidden='yes')
|
|
110
|
+
write_log('Doctor Who', 'file', 'info', "this is Doctor's log, only in file.", hidden='yes')
|
|
111
|
+
write_log('Tardis', 'CLI', 'info', "this is Tardis's log, only in CLI.", hidden='yes')
|
|
112
|
+
write_log('Tardis', 'fileCLI', 'info', "this is Tardis's log, in file and CLI.", hidden='yes')
|
|
113
|
+
write_log('Tardis', 'file', 'info', "this is Tardis's log, only in file.", hidden='yes')
|
|
114
|
+
write_log('Death', 'fileCLI', 'info', "this is Death's log, in file and CLI.",
|
|
115
|
+
mode='add', folder_name='death', hidden='yes')
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
logfly
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|