Commit f20d5d4ed92b5091a12325a440d9a3cee10ebae1
1 parent
deffe59d
Exists in
master
Modifica função de exibição de exceção. Adiciona ao git ignore arquivos com extenção .log
Showing
3 changed files
with
10 additions
and
33 deletions
Show diff stats
.gitignore
events.log
@@ -1,27 +0,0 @@ | @@ -1,27 +0,0 @@ | ||
1 | -[2015-04-17 02:57:36.024] INFO: 12 | ||
2 | -[2015-04-17 02:59:01.672] INFO: 12 | ||
3 | -[2015-04-17 02:59:04.960] WARNING: 12 | ||
4 | -[2015-04-17 02:59:11.521] ERROR: 12 | ||
5 | -[2015-04-17 02:59:15.105] CRITICAL: 12 | ||
6 | -[2015-04-17 02:59:30.056] CRITICAL: 12 | ||
7 | -[2015-04-17 02:59:35.104] ERROR: 12 | ||
8 | -[2015-04-17 03:01:28.624] INFO: This is a messageInfo | ||
9 | -[2015-04-17 03:01:28.624] WARNING: This is a messageWarn | ||
10 | -[2015-04-17 03:01:28.625] ERROR: This is a messageError | ||
11 | -[2015-04-17 03:01:28.625] CRITICAL: This is a messageCritical | ||
12 | -[2015-04-17 03:02:18.703] INFO: This is a messageInfo | ||
13 | -[2015-04-17 03:02:18.704] WARNING: This is a messageWarn | ||
14 | -[2015-04-17 03:02:18.704] ERROR: This is a messageError | ||
15 | -[2015-04-17 03:02:18.705] CRITICAL: This is a messageCritical | ||
16 | -[2015-04-17 03:02:37.855] INFO: This is a messageInfo | ||
17 | -[2015-04-17 03:02:37.856] WARNING: This is a messageWarn | ||
18 | -[2015-04-17 03:02:37.856] ERROR: This is a messageError | ||
19 | -[2015-04-17 03:02:37.856] CRITICAL: This is a messageCritical | ||
20 | -[2015-04-17 03:02:56.543] INFO: This is a messageInfo | ||
21 | -[2015-04-17 03:02:56.543] WARNING: This is a messageWarn | ||
22 | -[2015-04-17 03:02:56.544] ERROR: This is a messageError | ||
23 | -[2015-04-17 03:02:56.544] CRITICAL: This is a messageCritical | ||
24 | -[2015-04-17 03:02:57.951] INFO: This is a messageInfo | ||
25 | -[2015-04-17 03:02:57.952] WARNING: This is a messageWarn | ||
26 | -[2015-04-17 03:02:57.952] ERROR: This is a messageError | ||
27 | -[2015-04-17 03:02:57.952] CRITICAL: This is a messageCritical |
pyutil.py
@@ -58,21 +58,24 @@ def test_log(): | @@ -58,21 +58,24 @@ def test_log(): | ||
58 | log(msg + "Warn", 3) | 58 | log(msg + "Warn", 3) |
59 | log(msg + "Error", 4) | 59 | log(msg + "Error", 4) |
60 | log(msg + "Critical", 5) | 60 | log(msg + "Critical", 5) |
61 | - log(msg + "Critical", 6) | ||
62 | 61 | ||
63 | # test_log() | 62 | # test_log() |
64 | 63 | ||
65 | -def printStackTrace(filename): | 64 | +# @def Função para exibir exceção |
65 | +# @param string deve ser passado: "__file__" para identificar em qual arquivo ocorreu a exceção | ||
66 | +# @return int Retorna 1 | ||
67 | +def printStackTrace(fromFile): | ||
66 | from sys import exc_info | 68 | from sys import exc_info |
67 | from os.path import basename | 69 | from os.path import basename |
68 | - print("\n[Exception begin]\n File: %s\n Name: %s\n Line: %s\n Type: %s\n Message: %s\n[Exception end]\n" % ( | ||
69 | - basename(filename), # basename(exc_info()[2].tb_frame.f_code.co_filename), | 70 | + error = "\n File name: %s\n Function name: %s\n Line code: %s\n Type exception: %s\n Message: %s" % ( |
71 | + basename(fromFile), # basename(exc_info()[2].tb_frame.f_code.co_filename), | ||
70 | exc_info()[2].tb_frame.f_code.co_name, | 72 | exc_info()[2].tb_frame.f_code.co_name, |
71 | exc_info()[2].tb_lineno, | 73 | exc_info()[2].tb_lineno, |
72 | exc_info()[0].__name__, | 74 | exc_info()[0].__name__, |
73 | - exc_info()[1], | ||
74 | - ) | 75 | + exc_info()[1] |
75 | ) | 76 | ) |
77 | + log(error, 4) | ||
78 | + return 1 | ||
76 | 79 | ||
77 | def file_rename(filename, fromfile): | 80 | def file_rename(filename, fromfile): |
78 | from shutil import move | 81 | from shutil import move |