Skip to content

Add per-call emoji override to prevent duplicate emoji rendering#31

Merged
warengonzaga merged 7 commits intodevfrom
copilot/add-per-call-emoji-override
Feb 14, 2026
Merged

Add per-call emoji override to prevent duplicate emoji rendering#31
warengonzaga merged 7 commits intodevfrom
copilot/add-per-call-emoji-override

Conversation

Copy link
Contributor

Copilot AI commented Feb 14, 2026

  • Add LogCallOptions interface to types/index.ts with emoji?: string field
  • Update log method signatures in Logger class (debug, info, warn, error, log) to accept optional options parameter
  • Update formatMessage method to accept and pass through options
  • Modify MessageFormatter.format to accept options and use override emoji if provided
  • Update raw logging methods (debugRaw, infoRaw, etc.) with same signature changes
  • Add tests for per-call emoji override functionality (28 tests total, all passing)
  • Add tests for LogEngine wrapper methods (8 new tests covering all wrapper methods)
  • Update LogEngine wrapper to pass through options parameter
  • Export LogCallOptions type for external use
  • Enhanced JSDoc for LogCallOptions with detailed behavior and examples
  • Replace magic numbers with LogMode enum constants for better readability
  • Run all tests to ensure backward compatibility (366 passed, 10 pre-existing failures)
  • Run linting to ensure code quality (passed with no issues)
  • Address all code review feedback

Summary

Replaced all magic number literals (0, 1) with LogMode enum constants (LogMode.DEBUG, LogMode.INFO) throughout the emoji-override test file for improved readability and consistency with the rest of the test suite. Also fixed comment accuracy regarding log level filtering.

Original prompt

This section details on the original issue you should resolve

<issue_title>Feature: per-call emoji override in log methods</issue_title>
<issue_description>## Summary

Add support for an optional per-call emoji override in log methods (debug, info, warn, error, log) so callers can specify an exact emoji for a specific log statement without relying on keyword-based auto-detection.

Problem

Currently, the log method signatures are:

debug(message: string, data?: LogData): void;
info(message: string, data?: LogData): void;
// ...etc

The emoji element is determined automatically via EmojiSelector keyword matching against the message text. This creates a duplicate emoji problem when the caller wants a specific emoji and embeds it in the message string — the formatter also auto-selects an emoji from keyword matching, resulting in output like:

[11:14AM][INFO][✅]: ✅ Config engine initialized
[11:14AM][INFO][🤖]: 🤖 Heartware initialized

The emoji appears twice: once from the auto-selected emoji element [✅] and once from the manually embedded emoji in the message ✅ Config engine initialized.

Callers currently have no way to:

  1. Override the auto-selected emoji element for a specific log call
  2. Suppress the emoji element for a single call without disabling it globally

Proposed Solution

Extend the log method signatures to accept an optional options object that includes an emoji field:

interface LogCallOptions {
  emoji?: string;  // Override the auto-detected emoji for this call
}

// Updated signatures (backwards compatible)
debug(message: string, data?: LogData, options?: LogCallOptions): void;
info(message: string, data?: LogData, options?: LogCallOptions): void;
warn(message: string, data?: LogData, options?: LogCallOptions): void;
error(message: string, data?: LogData, options?: LogCallOptions): void;
log(message: string, data?: LogData, options?: LogCallOptions): void;

Usage Example

// Before (duplicate emoji):
logger.info('✅ Database initialized');  
// Output: [11:14AM][INFO][✅]: ✅ Database initialized

// After (clean, override emoji element):
logger.info('Database initialized', undefined, { emoji: '✅' });
// Output: [11:14AM][INFO][✅]: Database initialized

This would allow callers to set a precise emoji for the log element without embedding it in the message content, eliminating the duplication issue.

Alternatives Considered

  • Strip leading emoji from message text: Fragile, depends on emoji detection regex
  • Disable emoji globally: Loses the useful visual context for all other messages
  • Accept current behavior: Results in cluttered, redundant log output

Environment

  • @wgtechlabs/log-engine: v2.3.0</issue_description>

<agent_instructions>PR the changes to dev branch</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 4 commits February 14, 2026 03:49
Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>
Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>
Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>
Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>
Copilot AI changed the title [WIP] Add per-call emoji override in log methods Add per-call emoji override to prevent duplicate emoji rendering Feb 14, 2026
Copilot AI requested a review from warengonzaga February 14, 2026 04:07
@warengonzaga warengonzaga marked this pull request as ready for review February 14, 2026 04:07
@warengonzaga warengonzaga requested review from Copilot and removed request for warengonzaga February 14, 2026 04:08
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 pull request adds per-call emoji override functionality to prevent duplicate emoji rendering when callers embed emoji in their log messages. The feature extends all log method signatures with an optional third parameter options?: LogCallOptions that includes an emoji field for specifying, overriding, or suppressing emoji on individual log calls.

Changes:

  • Added LogCallOptions interface with optional emoji field to enable per-call emoji customization
  • Updated all log methods (debug, info, warn, error, log) and their Raw variants across Logger class and LogEngine wrapper to accept options parameter
  • Modified emoji resolution logic in MessageFormatter to check for options.emoji override before falling back to auto-detection
  • Added comprehensive test coverage for the new feature across all log levels and methods

Reviewed changes

Copilot reviewed 5 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/types/index.ts Defines new LogCallOptions interface and updates all logging interface signatures to include optional options parameter
src/logger/core.ts Updates Logger class methods to accept and pass through options parameter to MessageFormatter
src/index.ts Updates LogEngine wrapper methods and withoutRedaction() to accept and forward options parameter
src/formatter/message-formatter.ts Implements emoji override logic that checks options.emoji before auto-detection
src/tests/emoji-override.test.ts Comprehensive test suite covering emoji override functionality for all log methods and use cases
.gitignore Adds manual-test.cjs to ignored files for temporary testing artifacts

@warengonzaga
Copy link
Member

@copilot apply changes based on the comments in this thread

Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 14, 2026

@copilot apply changes based on the comments in this thread

All changes from the review thread have been applied:

  1. Enhanced LogCallOptions JSDoc with detailed behavior and examples
  2. Added 8 new tests for LogEngine wrapper methods

All 28 tests in emoji-override.test.ts now pass. (commit 0286b12)

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • api.example.com
    • Triggering command: /opt/hostedtoolcache/node/24.13.0/x64/bin/node /opt/hostedtoolcache/node/24.13.0/x64/bin/node /home/REDACTED/work/log-engine/log-engine/node_modules/jest-worker/build/workers/processChild.js (dns block)
  • downloads.snyk.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node wrapper_dist/bootstrap.js exec (dns block)
  • o30291.ingest.sentry.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node wrapper_dist/bootstrap.js exec (dns block)
  • static.snyk.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node wrapper_dist/bootstrap.js exec (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

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

Copilot reviewed 5 out of 7 changed files in this pull request and generated 4 comments.

@warengonzaga
Copy link
Member

@copilot apply changes based on the comments in this thread

Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 14, 2026

@copilot apply changes based on the comments in this thread

All changes from the review thread have been applied:

  • Replaced all magic numbers (0, 1) with LogMode enum constants (LogMode.DEBUG, LogMode.INFO)
  • Updated comment accuracy regarding log level filtering
  • Imported LogMode in dynamic imports for LogEngine wrapper tests

All 28 tests continue to pass. (commit f0098d7)

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • downloads.snyk.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node wrapper_dist/bootstrap.js exec (dns block)
  • o30291.ingest.sentry.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node wrapper_dist/bootstrap.js exec (dns block)
  • static.snyk.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node wrapper_dist/bootstrap.js exec (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@codecov
Copy link

codecov bot commented Feb 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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

Copilot reviewed 5 out of 7 changed files in this pull request and generated no new comments.

@warengonzaga warengonzaga merged commit aafa39c into dev Feb 14, 2026
15 checks passed
@warengonzaga warengonzaga deleted the copilot/add-per-call-emoji-override branch February 14, 2026 06:05
@warengonzaga warengonzaga linked an issue Feb 14, 2026 that may be closed by this pull request
warengonzaga added a commit that referenced this pull request Feb 14, 2026
* 📦 new: add bundle size checker with tests and workflow (#27)

* Initial plan

* 📦 new: add bundle size checker with tests and workflow

Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>

* 📖 docs: add bundle size checker to documentation

Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>

* 🧪 test: fix inverted logic in size checker test

Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>

* 🔒 security: add permissions block to size-check workflow

Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>

* ⚙️ setup: fix linting issues in size-checker test

Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>

* 🔧 update: address PR review feedback

Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>

* 🔧 update: improve error handling and validation

Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>

* 🔒 security: fix shell injection and improve error visibility

Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>

* 🔒 security: fix non-literal require in tests

Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>

* 📦 new (emoji): add emoji selector and context-aware logic (#26)

* Initial plan

* 📦 new (emoji): add emoji selector and context-aware logic

Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>

* 📖 docs: add comprehensive emoji feature documentation

Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>

* 🔧 update: fix linting issues in emoji feature

Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>

* 🔧 update (emoji): address code review feedback

Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>

* 🔧 update: enable emoji by default and move toggle to format.includeEmoji

Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>

* 📖 docs: update README for new emoji configuration pattern

Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>

* 🔧 update: fix trailing spaces in tests

Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>

* 🔧 update (emoji): address code review feedback on performance and state management

Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>

* 🔧 update (emoji): move config to Logger.configure() to preserve regex cache

Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>

* 🔧 update: fix eslint errors by removing invalid security rule comments

Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>

* 🔒 security: add eslint-disable comments for safe code patterns

Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>

* � test: improve patch coverage for emoji feature

- Remove deprecated dead-code methods (getMappings, matchesKeywords) from EmojiSelector
- Add tests for unknown log level edge case in EmojiSelector
- Add tests for Logger.configure emoji configuration path
- Add tests for numeric and boolean data edge cases

* 🧪 test: improve patch coverage for emoji feature

- Remove deprecated dead-code methods (getMappings, matchesKeywords) from EmojiSelector
- Add tests for unknown log level edge case in EmojiSelector
- Add tests for Logger.configure emoji configuration path
- Add tests for numeric and boolean data edge cases

* 🗑️ remove: delete outdated Snyk security instructions

* 🔧 update: address code review feedback on performance and safety

Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>
Co-authored-by: Waren Gonzaga <opensource@warengonzaga.com>

* 🚀 release: bump version to 2.3.0

* 🗑️ remove: delete repository banner image

* 📖 docs: update README with new features and improved descriptions

* 📖 docs: update README to format code blocks for emoji log examples

* 🔧 update: add LogCallOptions interface and update signatures (#31)

* Initial plan

* 🔧 update: add LogCallOptions interface and update signatures

Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>

* 🧪 test: add comprehensive tests for emoji override

Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>

* 🔧 update: add options parameter to LogEngine wrapper

Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>

* 🔧 update: address code review feedback

Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>

* 📖 docs: enhance LogCallOptions JSDoc and add LogEngine wrapper tests

Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>

* 🔧 update: replace magic numbers with LogMode enum constants

Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>

* 🚀 release: bump version to 2.3.1

---------

Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: warengonzaga <15052701+warengonzaga@users.noreply.github.com>
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.

Feature: per-call emoji override in log methods

3 participants