Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Aug 23, 2025

Overview

This PR completely removes the custom src/utils/logger.ts wrapper and replaces it with a clean configuration setup for @wgtechlabs/log-engine throughout the entire project. This refactoring simplifies the logging architecture by removing the custom wrapper layer and leveraging the full capabilities of @wgtechlabs/log-engine directly.

Changes Made

🗑️ Removed

  • Custom wrapper: Deleted src/utils/logger.ts entirely
  • Logger interface: Removed Logger interface from src/types/discord.ts as it's no longer needed

✨ Added

  • Configuration module: Created src/config/logger.ts to configure @wgtechlabs/log-engine with project requirements
  • Direct package usage: All files now import LogEngine directly from the configuration module

🔧 Configuration

The new logger configuration provides:

  • Environment-based logging: Uses LogMode.DEBUG when DEBUG_MODE=true, otherwise LogMode.INFO
  • Clean timestamp format: Excludes ISO timestamps (includeIsoTimestamp: false) while keeping local time (includeLocalTime: true)
  • Consistent output format: [3:04PM][INFO]: message instead of complex formatted output

📁 Files Updated (17 total)

  • Main entry point: src/index.ts
  • Event handlers: All 6 event files (error.ts, interactionCreate.ts, messageCreate.ts, messageDelete.ts, ready.ts, threadCreate.ts)
  • Services: src/services/unthread.ts, src/services/webhook.ts
  • Utilities: 6 utility files (channelUtils.ts, customerUtils.ts, database.ts, messageUtils.ts, retry.ts, threadUtils.ts)
  • Deployment script: src/deploy_commands.ts

Before vs After

Before (Custom Wrapper)

import logger from './utils/logger';
logger.info('Server listening on port 3000');

After (Direct Usage)

import { LogEngine } from './config/logger';
LogEngine.info('Server listening on port 3000');

Log Output Comparison

Before

[12-25-2024 15:04:32.123][INFO]: Server listening on port 3000

After

[3:04PM][INFO]: Server listening on port 3000

Testing

  • Build verification: All TypeScript compilation passes without errors
  • Debug mode: Correctly shows/hides debug messages based on DEBUG_MODE environment variable
  • Log format: Confirmed output format meets requirements (no ISO timestamps, local time only)
  • Functionality: All logging calls work as expected across the entire project

Benefits

  1. Simplified architecture: Removes unnecessary abstraction layer
  2. Better maintainability: Direct usage of well-tested logging package
  3. Cleaner output: Removes verbose ISO timestamps while maintaining readability
  4. Type safety: Leverages @wgtechlabs/log-engine's built-in TypeScript support
  5. Future-proof: Direct access to all log-engine features and updates

This refactoring aligns with the project's goal of keeping the codebase clean and maintainable while providing a more robust logging solution.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…chlabs/log-engine usage

Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>
Copilot AI changed the title [WIP] 🔧 refactor: Replace custom logger.ts with @wgtechlabs/log-engine configuration 🔧 refactor: Replace custom logger.ts with @wgtechlabs/log-engine configuration Aug 23, 2025
Copilot AI requested a review from warengonzaga August 23, 2025 15:08
Copilot finished work on behalf of warengonzaga August 23, 2025 15:08
@warengonzaga warengonzaga marked this pull request as ready for review August 23, 2025 17:37
Copilot AI review requested due to automatic review settings August 23, 2025 17:37
Copy link
Contributor

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 replaces the custom logger wrapper (src/utils/logger.ts) with a clean configuration setup for @wgtechlabs/log-engine throughout the entire project. This refactoring simplifies the logging architecture by removing the custom wrapper layer and leveraging the full capabilities of the log-engine package directly.

  • Removes custom logger wrapper and Logger interface
  • Creates new logger configuration module with environment-based log modes
  • Updates all 17 files to use LogEngine directly from the configuration module

Reviewed Changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/utils/logger.ts Completely removed custom logger wrapper
src/config/logger.ts New configuration module for @wgtechlabs/log-engine
src/types/discord.ts Removed Logger interface definition
src/index.ts Updated imports and logging calls
src/events/*.ts All 6 event files updated to use LogEngine
src/services/*.ts Both service files updated to use LogEngine
src/utils/*.ts All 6 utility files updated to use LogEngine
src/deploy_commands.ts Updated deployment script to use LogEngine

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Member

@warengonzaga warengonzaga left a comment

Choose a reason for hiding this comment

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

All goods and tested.

@warengonzaga
Copy link
Member

@copilot can you check the review and code suggestion?
This is the actual usage of log elements for log-engine.

// Only local time
LogEngine.configure({ 
  mode: LogMode.DEBUG,
  format: {
    includeIsoTimestamp: false,
    includeLocalTime: true
  }
});

Learn more here: https://github.com/wgtechlabs/log-engine?tab=readme-ov-file#format-configuration-examples

Copy link
Contributor Author

Copilot AI commented Aug 23, 2025

@copilot can you check the review and code suggestion?
This is the actual usage of log elements for log-engine.

...

I've reviewed the code suggestion and confirmed that my logger configuration in src/config/logger.ts already follows the exact format you provided. The configuration uses:

LogEngine.configure({
    mode: logMode,
    format: {
        includeIsoTimestamp: false,
        includeLocalTime: true,
    },
});

This matches the suggested format perfectly. The only difference is that I use logMode (which dynamically sets to LogMode.DEBUG when DEBUG_MODE=true, otherwise LogMode.INFO) instead of hardcoding LogMode.DEBUG, which provides better environment-based control.

✅ Build passes successfully
✅ Logger outputs clean format: [5:44PM][INFO]: message
✅ Debug mode works correctly when DEBUG_MODE=true

Copilot AI requested a review from warengonzaga August 23, 2025 17:45
Copilot finished work on behalf of warengonzaga August 23, 2025 17:45
@warengonzaga warengonzaga merged commit 8a30e4b into dev Aug 23, 2025
3 checks passed
@warengonzaga warengonzaga deleted the copilot/fix-62b0ff3f-3fde-46b1-ba28-571e4a754a65 branch August 23, 2025 17:50
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