Skip to content

Commit 2d1eb43

Browse files
committed
- Log part started
1 parent a6da125 commit 2d1eb43

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/relatorios
2-
app/__pycache__
2+
app/__pycache__
3+
app/logs

app/__init__.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,20 @@
33
# Inicialização do aplicativo Flask
44
app = Flask(__name__)
55

6+
# Configuração básica do logger
7+
import logging
8+
import os
9+
10+
LOG_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'logs')
11+
LOG_FILE = os.path.join(LOG_DIR, 'app.log')
12+
#LOG_FILE_DEBUG = os.path.join(LOG_DIR, 'debug.log')
13+
14+
15+
if not os.path.exists(LOG_DIR):
16+
os.makedirs(LOG_DIR)
17+
18+
logging.basicConfig(filename=LOG_FILE, level=logging.INFO)
19+
#logging.basicConfig(filename=LOG_FILE_DEBUG, level=logging.DEBUG)
20+
621
# Importação de rotas para registrar rotas
722
from app import routes

app/routes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
@app.route('/')
99
def index():
10+
app.logger.info('Acesso à página inicial')
1011
return render_template('index.html')
1112

1213
@app.route('/login')

0 commit comments

Comments
 (0)