Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot see logger messages in Rails console from own classes #147

Closed
rgaufman opened this issue Dec 21, 2021 · 3 comments
Closed

Cannot see logger messages in Rails console from own classes #147

rgaufman opened this issue Dec 21, 2021 · 3 comments

Comments

@rgaufman
Copy link

rgaufman commented Dec 21, 2021

Environment

Provide at least:

  • Ruby Version - ruby 3.0.3p157
  • Semantic Logger Version. semantic_logger (4.8.2)
  • Application/framework names and versions (e.g. Rails, Sinatra, Puma, etc.). rails (6.1.4.4) puma (5.5.2)
  • Rails Semantic Logger Version, rails_semantic_logger (4.6.1)
  • Rails configuration. Only need the settings related to Rails Semantic Logger and Semantic Logger. Defaults
  • Full Stack Trace, if an exception is being raised. No exception

Expected Behavior

irb(main):002:0> SemanticLogger.default_level = :debug
=> :debug
irb(main):003:0> MyClass.has_logger_warn
=> "This is a test message"
=> "puts works"
irb(main):003:0>

My class has:

class MyClass
  include SemanticLogger::Loggable

  def has_logger_warn
    logger.warn("This is a test message")
    puts "puts works"
  end
end

Actual Behavior

irb(main):002:0> SemanticLogger.default_level = :debug
=> :debug
irb(main):003:0> MyClass.has_logger_warn
=> "puts works"
irb(main):003:0>

Despite having logger.warn('This is a test message') in this method, I am not seeing any output.

Any ideas?

@rgaufman rgaufman changed the title Cannot see logger messages in Rails console Cannot see logger messages in Rails console from own classes Dec 21, 2021
@rgaufman
Copy link
Author

Update, if I add sleep 60 to the method, then I see my warning, it's only if the method exits quickly it appears the log message is suppressed? - any ideas?

@rgaufman
Copy link
Author

Hi sorry, it is my bad, I had a binary in the string. I added this to fix the problem:

string.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')

The binary in question was "\xE2"

@reidmorrison
Copy link
Owner

The above code conversion failure is a broader issue that we need to address in Semantic Logger itself. It has burnt me a few times now, so we need to figure out a complete solution: reidmorrison/semantic_logger#180

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

No branches or pull requests

2 participants