Skip to content

feat: implement logging throughout the linebot application#5

Merged
yenslife merged 1 commit into
mainfrom
logger-refactor
Apr 18, 2025
Merged

feat: implement logging throughout the linebot application#5
yenslife merged 1 commit into
mainfrom
logger-refactor

Conversation

@yenslife
Copy link
Copy Markdown
Contributor

This commit introduces a centralized logging system. A new module linebot/app/config/logger.py is created to configure and provide logger instances. The logging configuration includes:

  • Log formatting with timestamp, logger name, level, and message.
  • Console output with configurable log level.
  • File output with rotating file handler (max 10MB, 5 backups).
  • A global app_logger instance for general application logging.

The existing print statements in linebot/app/api/vision.py and linebot/app/routers/linebot.py are replaced with calls to the new logging system. This allows for better control and management of application logs.

Additionally, the .gitignore file is updated to ignore the logs/ directory, preventing log files from being committed to the repository.

This commit introduces a centralized logging system. A new module
`linebot/app/config/logger.py` is created to configure and provide
logger instances. The logging configuration includes:

-   Log formatting with timestamp, logger name, level, and message.
-   Console output with configurable log level.
-   File output with rotating file handler (max 10MB, 5 backups).
-   A global `app_logger` instance for general application logging.

The existing `print` statements in `linebot/app/api/vision.py` and
`linebot/app/routers/linebot.py` are replaced with calls to the new
logging system. This allows for better control and management of
application logs.

Additionally, the `.gitignore` file is updated to ignore the `logs/`
directory, preventing log files from being committed to the repository.
@yenslife yenslife requested a review from Copilot April 18, 2025 14:20
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a centralized logging system to replace print statements and standard logger calls with a uniform, configurable logging setup across the application.

  • Introduces a new logger module that configures both console and rotating file handlers
  • Replaces print statements with logger calls in message handling, API, and router modules

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
linebot/app/webhooks/handlers.py Replaced print statements with logger.info calls
linebot/app/services/message_service.py Updated logging initialization to use get_logger
linebot/app/services/handlers/text_handler.py Switched to centralized logger for text message handling
linebot/app/services/handlers/image_handler.py Replaced standard logging with get_logger usage
linebot/app/services/handlers/common.py Updated logger initialization with get_logger
linebot/app/services/handlers/audio_handler.py Replaced print statement with logger.info call
linebot/app/routers/linebot.py Replaced print calls with logger calls for various events
linebot/app/config/logger.py Introduced centralized logging configuration
linebot/app/api/vision.py Replaced print with logger.error for error handling

@yenslife yenslife merged commit caa78f9 into main Apr 18, 2025
1 check passed
MH-limarco added a commit that referenced this pull request May 31, 2025
# This is the 1st commit message:

auto_update activity_KB

# This is the commit message #2:

auto_update activity_KB

# This is the commit message #3:

auto_update activity_KB

debug

debug

debug

debug

debug

debug

debug

debug

debug

debug

debug

debug

debug

debug

debug done

debug done

debug done

tidy up

tidy up

tidy up

tidy up

tidy up

# This is the commit message #4:

tidy up

# This is the commit message #5:

auto_update activity_KB

debug

debug

debug

debug

debug

debug

debug

debug

debug

debug

debug

debug

debug

debug

debug done

debug done

debug done

tidy up

tidy up

tidy up

tidy up

tidy up
@yenslife yenslife deleted the logger-refactor branch June 2, 2025 11:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants