LogFly 0.1__py3-none-any.whl

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/__init__.py ADDED
@@ -0,0 +1,50 @@
1
+ import time
2
+ import os
3
+
4
+
5
+ def create_log_folder():
6
+ dirs = '.\\logs\\'
7
+ dirs2 = '.\\logs\\' + get_time('date')
8
+ if not os.path.exists(dirs):
9
+ os.makedirs(dirs)
10
+ else:
11
+ pass
12
+ if not os.path.exists(dirs2):
13
+ os.makedirs(dirs2)
14
+ else:
15
+ pass
16
+
17
+
18
+ def get_time(flag):
19
+ if flag == 'datetime':
20
+ return time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
21
+ if flag == 'date':
22
+ return time.strftime("%Y-%m-%d", time.localtime())
23
+ if flag == 'times':
24
+ return time.strftime("%H:%M:%S", time.localtime())
25
+
26
+
27
+ def write_log(name, position, level, message):
28
+ logfolder = '.\\logs\\' + get_time('date') + '\\'
29
+ logfile = logfolder + name + '-' + get_time('date') + '.log'
30
+ create_log_folder()
31
+ if position == 'CLI':
32
+ print(name + ' ' + get_time('datetime') + ' ' + '[' + str.upper(level) + ']' + ' ' + message + '\r\n')
33
+ if position == 'file':
34
+ File = open(logfile, 'a', newline='')
35
+ File.write(get_time('datetime') + ' ' + '[' + str.upper(level) + ']' + ' ' + message + '\r\n')
36
+ File.close()
37
+ if position == 'fileCLI':
38
+ print(name + ' ' + get_time('datetime') + ' ' + '[' + str.upper(level) + ']' + ' ' + message + '\r\n')
39
+ File = open(logfile, 'a', newline='')
40
+ File.write(get_time('datetime') + ' ' + '[' + str.upper(level) + ']' + ' ' + message + '\r\n')
41
+ File.close()
42
+
43
+
44
+ if __name__ == '__main__':
45
+ write_log('Doctor Who', 'CLI', 'info', "this is Doctor's log, only in CLI.")
46
+ write_log('Doctor Who', 'fileCLI', 'info', "this is Doctor's log, in file and CLI.")
47
+ write_log('Doctor Who', 'file', 'info', "this is Doctor's log, only in file.")
48
+ write_log('Tardis', 'CLI', 'info', "this is Tardis's log, only in CLI.")
49
+ write_log('Tardis', 'fileCLI', 'info', "this is Tardis's log, in file and CLI.")
50
+ write_log('Tardis', 'file', 'info', "this is Tardis's log, only in file.")
@@ -0,0 +1,13 @@
1
+ Metadata-Version: 2.1
2
+ Name: logfly
3
+ Version: 0.1
4
+ Summary: a simple log tool for python.
5
+ Home-page: https://github.com/TinQlo/LogFly
6
+ Author: Yuan Sui
7
+ Author-email: orisui@icloud.com
8
+ License: MIT Licence
9
+ Platform: UNKNOWN
10
+
11
+ UNKNOWN
12
+
13
+
@@ -0,0 +1,5 @@
1
+ logfly/__init__.py,sha256=OG0ZqRlv_oyGvqKgptj0tfsVlJdm7-DdJ-FlWHB3Xms,1923
2
+ logfly-0.1.dist-info/METADATA,sha256=848oWdzxboH-iFtN6gWWPTN0CwtSWXapW89JuGsDFaU,230
3
+ logfly-0.1.dist-info/WHEEL,sha256=OqRkF0eY5GHssMorFjlbTIq072vpHpF60fIQA6lS9xA,92
4
+ logfly-0.1.dist-info/top_level.txt,sha256=Jq78XcJi-8oeqyDfjhyI6Ek9LQOZG7QhoWa3R4wRC0Y,7
5
+ logfly-0.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: bdist_wheel (0.36.2)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ logfly