-
Notifications
You must be signed in to change notification settings - Fork 237
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
79 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from flask import render_template | ||
|
||
|
||
class ErrorHandlerManager: | ||
def __init__(self, app): | ||
self.app = app | ||
|
||
def register_error_handlers(self): | ||
@self.app.errorhandler(500) | ||
def internal_error(e): | ||
self.app.logger.error('Internal Server Error: %s', str(e)) | ||
return render_template('500.html'), 500 | ||
|
||
@self.app.errorhandler(404) | ||
def not_found_error(e): | ||
self.app.logger.warning('Page Not Found: %s', str(e)) | ||
return render_template('404.html'), 404 | ||
|
||
@self.app.errorhandler(401) | ||
def unauthorized_error(e): | ||
self.app.logger.warning('Unauthorized Access: %s', str(e)) | ||
return render_template('401.html'), 401 | ||
|
||
@self.app.errorhandler(400) | ||
def bad_request_error(e): | ||
self.app.logger.warning('Bad Request: %s', str(e)) | ||
return render_template('400.html'), 400 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import logging | ||
from logging.handlers import RotatingFileHandler | ||
|
||
|
||
class LoggingManager: | ||
def __init__(self, app): | ||
self.app = app | ||
|
||
def setup_logging(self): | ||
# Configure log format | ||
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') | ||
|
||
# Configure the log file with file rotation | ||
file_handler = RotatingFileHandler('app.log', maxBytes=10240, backupCount=10) | ||
file_handler.setLevel(logging.ERROR) | ||
file_handler.setFormatter(formatter) | ||
|
||
# Add handler to app logger | ||
self.app.logger.addHandler(file_handler) | ||
|
||
# Configure console log if necessary | ||
if self.app.debug: | ||
stream_handler = logging.StreamHandler() | ||
stream_handler.setLevel(logging.INFO) | ||
stream_handler.setFormatter(formatter) | ||
self.app.logger.addHandler(stream_handler) | ||
|
||
# Set the overall log level | ||
self.app.logger.setLevel(logging.INFO) |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters