Skip to content

make scoped logger work with logger objects with non-int level#486

Open
HoneyryderChuck wants to merge 1 commit into
temporalio:mainfrom
persona-id:scoped-logger-non-integer-level
Open

make scoped logger work with logger objects with non-int level#486
HoneyryderChuck wants to merge 1 commit into
temporalio:mainfrom
persona-id:scoped-logger-non-integer-level

Conversation

@HoneyryderChuck

Copy link
Copy Markdown

What was changed

This patch fixes scoped loggers by allowing a escape hatch for logger objects with non-integer levels; just call #upcase (which both strings and symbols support) and pass it to Logger::Severity.const_get.

Why?

Logger#level returns an integer, however many other logger libraries in ruby land don't do that, most notably semantic_logger, which is nowadays recommended by rails for structured logging; SemanticLogger::Logger objects return #level as a symbol (ex: :info).

Checklist

  1. Closes [Bug] Does not support semantic_logger #472

  2. How was this tested:

require "semantic_logger"
require "temporalio"

logger = SemanticLogger["MyApp"]
scoped_logger = ScopedLogger.new(logger)
scoped_logger.level #=> 1, 2 ,3....

3. Any docs updates needed?

Don't think so, temporalio does not document support for logger libs.

@HoneyryderChuck HoneyryderChuck requested a review from a team as a code owner July 13, 2026 18:38
@CLAassistant

CLAassistant commented Jul 13, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@HoneyryderChuck HoneyryderChuck force-pushed the scoped-logger-non-integer-level branch from e7f1c74 to d587d28 Compare July 14, 2026 18:03
`Logger#level` returns an integer, however many other logger libraries
in ruby land don't do that, most notably semantic_logger, which is
nowadays recommended by rails for structured logging;
`SemanticLogger::Logger` objects return `#level` as a symbol (ex:
`:info`).

This patch fixes it by allowing a escape hatch for non-integer levels;
just call `#upcase` (which both strings and symbols support) and pass it
to `Logger::Severity.const_get`.
@HoneyryderChuck HoneyryderChuck force-pushed the scoped-logger-non-integer-level branch from d587d28 to df7793c Compare July 14, 2026 22:04
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.

[Bug] Does not support semantic_logger

2 participants