LogFly 1.9__tar.gz → 2.1__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: 1.9
3
+ Version: 2.1
4
4
  Summary: A simple log tool by python
5
5
  Home-page: https://about.guki.me
6
6
  Author: Yuan Sui
@@ -15,20 +15,20 @@ Requires-Python: >=3.6
15
15
  Description-Content-Type: text/markdown
16
16
  License-File: LICENSE
17
17
 
18
- # logfly 1.9
19
- ### a simple log tool by python
18
+ # logfly 2.1
19
+ ### a simple log tool by python.
20
20
 
21
21
  ## position
22
22
  log will create in ./logs/[folder_name]/[date] folder.
23
- if use hidden, log will also appear in user/.1o9f1y folder
23
+ if use hidden, log will also appear in user/.1o9f1y folder.
24
24
 
25
25
  ## How to
26
26
  ### import
27
27
  import logfly
28
- ### use1
29
- logfly.write_log('name', 'where', 'info', 'message', mode='add', folder_name='logflys', hidden='no', color='yes', str_message='yes')
28
+ ### write_log
29
+ logfly.write_log('name', 'where', 'info', 'message', mode='add', folder_name='default-log', hidden='no', color='yes', str_message='yes')
30
30
 
31
- ## Description
31
+ #### Description
32
32
  name: (any str) logfile name, you can use diffrent string to create diffrent logfile.
33
33
  where: ('CLI', 'fileCLI', 'file') position where log appear.
34
34
  fileCLI means log will appear in command line window and log file.
@@ -38,20 +38,20 @@ if use hidden, log will also appear in user/.1o9f1y folder
38
38
  message: (any str) log message.
39
39
  mode: ('add', 'new') default is 'add', means log will add in same day.
40
40
  'new' means logfile will create when program every once.
41
- folder_name: (any str) custom logfly folder name, default is 'logflys'.
41
+ folder_name: (any str) custom logfly folder name, default is 'default-log'.
42
42
  hidden: ('yes', 'no') default is 'no', means logfile will save a copy in user/.1o9f1y folder
43
43
  color: ('yes', 'no') default is 'yes', means log will with color.
44
44
  str_message: ('yes', 'no') default is 'yes', means log will print message with str()
45
45
 
46
- ###use2
47
- lcreate_or_check_file(pathorfile, name, warning='Yes'):
46
+ ### create_or_check_file
47
+ create_or_check_file(pathorfile, name, warning='yes'):
48
48
  create or check file.
49
- pathorfile: (any str) path or file name.
49
+ pathorfile: ('file', 'path') choose to create file or path.
50
50
  name: (any str) file or path name.
51
- if warning is 'Yes', will print warning message if file is exist.
51
+ if warning is 'yes', will print warning message if file or path is exist.
52
52
 
53
- ##Description
54
- pathfile is the file path that you want to create, must fill with //
55
- filenname is the file name that you want to create, must is with *.*
53
+ #### Description
54
+ pathfile is the file path that you want to create, must fill with '//'
55
+ filenname is the file name that you want to create, must is with '*.*'
56
56
 
57
57
 
@@ -1,17 +1,17 @@
1
- # logfly 1.9
2
- ### a simple log tool by python
1
+ # logfly 2.1
2
+ ### a simple log tool by python.
3
3
 
4
4
  ## position
5
5
  log will create in ./logs/[folder_name]/[date] folder.
6
- if use hidden, log will also appear in user/.1o9f1y folder
6
+ if use hidden, log will also appear in user/.1o9f1y folder.
7
7
 
8
8
  ## How to
9
9
  ### import
10
10
  import logfly
11
- ### use1
12
- logfly.write_log('name', 'where', 'info', 'message', mode='add', folder_name='logflys', hidden='no', color='yes', str_message='yes')
11
+ ### write_log
12
+ logfly.write_log('name', 'where', 'info', 'message', mode='add', folder_name='default-log', hidden='no', color='yes', str_message='yes')
13
13
 
14
- ## Description
14
+ #### Description
15
15
  name: (any str) logfile name, you can use diffrent string to create diffrent logfile.
16
16
  where: ('CLI', 'fileCLI', 'file') position where log appear.
17
17
  fileCLI means log will appear in command line window and log file.
@@ -21,18 +21,18 @@ if use hidden, log will also appear in user/.1o9f1y folder
21
21
  message: (any str) log message.
22
22
  mode: ('add', 'new') default is 'add', means log will add in same day.
23
23
  'new' means logfile will create when program every once.
24
- folder_name: (any str) custom logfly folder name, default is 'logflys'.
24
+ folder_name: (any str) custom logfly folder name, default is 'default-log'.
25
25
  hidden: ('yes', 'no') default is 'no', means logfile will save a copy in user/.1o9f1y folder
26
26
  color: ('yes', 'no') default is 'yes', means log will with color.
27
27
  str_message: ('yes', 'no') default is 'yes', means log will print message with str()
28
28
 
29
- ###use2
30
- lcreate_or_check_file(pathorfile, name, warning='Yes'):
29
+ ### create_or_check_file
30
+ create_or_check_file(pathorfile, name, warning='yes'):
31
31
  create or check file.
32
- pathorfile: (any str) path or file name.
32
+ pathorfile: ('file', 'path') choose to create file or path.
33
33
  name: (any str) file or path name.
34
- if warning is 'Yes', will print warning message if file is exist.
34
+ if warning is 'yes', will print warning message if file or path is exist.
35
35
 
36
- ##Description
37
- pathfile is the file path that you want to create, must fill with //
38
- filenname is the file name that you want to create, must is with *.*
36
+ #### Description
37
+ pathfile is the file path that you want to create, must fill with '//'
38
+ filenname is the file name that you want to create, must is with '*.*'
@@ -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.9",
8
+ version="2.1",
9
9
  author="Yuan Sui",
10
10
  author_email="orisui@icloud.com",
11
11
  description="A simple log tool by python",
@@ -1,6 +1,6 @@
1
1
  #####################
2
2
  # Author: Yuki Sui
3
- # Date: 2022-1-30
3
+ # Date: 2022-3-11
4
4
  #####################
5
5
 
6
6
  import time
@@ -10,10 +10,10 @@ from pathlib import Path
10
10
  from colorama import init
11
11
 
12
12
  init(autoreset=True)
13
- __version__ = '1.9'
13
+ __version__ = '2.1'
14
14
 
15
15
 
16
- def create_or_check_file(pathorfile, name, warning='Yes'):
16
+ def create_or_check_file(pathorfile, name, warning='yes'):
17
17
  try:
18
18
  if pathorfile == 'file':
19
19
  if not os.path.exists(name):
@@ -34,10 +34,11 @@ def create_or_check_file(pathorfile, name, warning='Yes'):
34
34
  else:
35
35
  raise ParameterERROR('function create_or_check_file Parameter error! warning must be "yes" or "no"! ')
36
36
  except Exception as e:
37
- error(e)
37
+ linenum = e.__traceback__.tb_lineno
38
+ error(e, linenum)
38
39
 
39
40
 
40
- def create_log_folder(folder_name, hidden):
41
+ def create_log_folder(folder_name, hidden='no'):
41
42
  dirs = '.\\logs\\'
42
43
  dirs2 = '.\\logs\\' + folder_name + '\\' + get_time('date') + '\\'
43
44
  dirs3 = str(Path.home()) + '\\.1o9f1y\\' + folder_name + '\\' + get_time('date') + '\\'
@@ -72,14 +73,35 @@ def get_time(flag):
72
73
  raise ParameterERROR('function get_time Parameter error! flag must be "datetime", "date", "times", '
73
74
  '"datetimefile","timestamp"! ')
74
75
  except Exception as e:
75
- error(e)
76
+ linenum = e.__traceback__.tb_lineno
77
+ error(e, linenum)
78
+
79
+
80
+ def time_transfer(time_stamp, flag='timestamp2datetime'):
81
+ try:
82
+ if flag == 'timestamp2datetime':
83
+ if len(str(time_stamp)) == 10:
84
+ return time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time_stamp))
85
+ elif len(str(time_stamp)) == 13:
86
+ return time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time_stamp / 1000))
87
+ else:
88
+ raise ParameterERROR('function time_transfer Parameter error! time_stamp must be 10 bits or 13 bits! ')
89
+ elif flag == 'datetime2timestamp':
90
+ return time.mktime(time.strptime(time_stamp, "%Y-%m-%d %H:%M:%S"))
91
+ else:
92
+ raise ParameterERROR('function time_transfer Parameter error! flag must be "timestamp2datetime" or '
93
+ '"datetime2timestamp"! ')
94
+ except Exception as e:
95
+ linenum = e.__traceback__.tb_lineno
96
+ error(e, linenum)
76
97
 
77
98
 
78
99
  # noinspection PyTypeChecker
79
100
  def write_log(name, position, level, message, mode='add',
80
- folder_name='logflys', hidden='no', color='yes', str_message='yes'):
101
+ folder_name='default-log', hidden='no', color='yes', str_message='yes'):
81
102
  global LOGFILE, LOGFILE2, logfolder, logfolder_hidden, LOGFILE_hidden
82
103
  try:
104
+ create_log_folder(folder_name)
83
105
  if str_message == 'yes':
84
106
  message = str(message)
85
107
  elif str_message == 'no':
@@ -188,7 +210,8 @@ def write_log(name, position, level, message, mode='add',
188
210
  else:
189
211
  raise ParameterERROR('function write_log Parameter error! position must be "file" or "fileCLI"! ')
190
212
  except Exception as e:
191
- error(e, 'only print')
213
+ linenum = e.__traceback__.tb_lineno
214
+ error(e, linenum, 'only print')
192
215
 
193
216
 
194
217
  def mv_file(original_file_name, new_file_name, folder_name='mv_file'):
@@ -197,9 +220,9 @@ def mv_file(original_file_name, new_file_name, folder_name='mv_file'):
197
220
  write_log('logfly-log', 'CLI', 'error', message, folder_name=folder_name)
198
221
 
199
222
 
200
- def error(exp, mode='logfly'):
223
+ def error(exp,linenum, mode='logfly'):
201
224
  if mode == 'logfly':
202
- logflyErrorMessage = 'ERROR occurred!\r\n\r\n' + str(
225
+ logflyErrorMessage = 'ERROR occurred! at row ' + str(linenum) + '\r\n\r\n' + str(
203
226
  exp) + "\r\n\r\nplease re-check it! \r\nAnd you can see the " \
204
227
  "manual at " \
205
228
  "https://github.com/tinqlo/logfly "
@@ -214,3 +237,6 @@ class ParameterERROR(Exception):
214
237
  def __init__(self, message):
215
238
  self.message = message
216
239
 
240
+
241
+ if __name__ == '__main__':
242
+ write_log('logfly-log', 'fileCLI', 'error', 'test', hidden='yes')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: logfly
3
- Version: 1.9
3
+ Version: 2.1
4
4
  Summary: A simple log tool by python
5
5
  Home-page: https://about.guki.me
6
6
  Author: Yuan Sui
@@ -15,20 +15,20 @@ Requires-Python: >=3.6
15
15
  Description-Content-Type: text/markdown
16
16
  License-File: LICENSE
17
17
 
18
- # logfly 1.9
19
- ### a simple log tool by python
18
+ # logfly 2.1
19
+ ### a simple log tool by python.
20
20
 
21
21
  ## position
22
22
  log will create in ./logs/[folder_name]/[date] folder.
23
- if use hidden, log will also appear in user/.1o9f1y folder
23
+ if use hidden, log will also appear in user/.1o9f1y folder.
24
24
 
25
25
  ## How to
26
26
  ### import
27
27
  import logfly
28
- ### use1
29
- logfly.write_log('name', 'where', 'info', 'message', mode='add', folder_name='logflys', hidden='no', color='yes', str_message='yes')
28
+ ### write_log
29
+ logfly.write_log('name', 'where', 'info', 'message', mode='add', folder_name='default-log', hidden='no', color='yes', str_message='yes')
30
30
 
31
- ## Description
31
+ #### Description
32
32
  name: (any str) logfile name, you can use diffrent string to create diffrent logfile.
33
33
  where: ('CLI', 'fileCLI', 'file') position where log appear.
34
34
  fileCLI means log will appear in command line window and log file.
@@ -38,20 +38,20 @@ if use hidden, log will also appear in user/.1o9f1y folder
38
38
  message: (any str) log message.
39
39
  mode: ('add', 'new') default is 'add', means log will add in same day.
40
40
  'new' means logfile will create when program every once.
41
- folder_name: (any str) custom logfly folder name, default is 'logflys'.
41
+ folder_name: (any str) custom logfly folder name, default is 'default-log'.
42
42
  hidden: ('yes', 'no') default is 'no', means logfile will save a copy in user/.1o9f1y folder
43
43
  color: ('yes', 'no') default is 'yes', means log will with color.
44
44
  str_message: ('yes', 'no') default is 'yes', means log will print message with str()
45
45
 
46
- ###use2
47
- lcreate_or_check_file(pathorfile, name, warning='Yes'):
46
+ ### create_or_check_file
47
+ create_or_check_file(pathorfile, name, warning='yes'):
48
48
  create or check file.
49
- pathorfile: (any str) path or file name.
49
+ pathorfile: ('file', 'path') choose to create file or path.
50
50
  name: (any str) file or path name.
51
- if warning is 'Yes', will print warning message if file is exist.
51
+ if warning is 'yes', will print warning message if file or path is exist.
52
52
 
53
- ##Description
54
- pathfile is the file path that you want to create, must fill with //
55
- filenname is the file name that you want to create, must is with *.*
53
+ #### Description
54
+ pathfile is the file path that you want to create, must fill with '//'
55
+ filenname is the file name that you want to create, must is with '*.*'
56
56
 
57
57
 
File without changes
File without changes
File without changes