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

[DEBUG PR] Added debug logs to check why the spy doesn't work #2

Draft
wants to merge 10 commits into
base: feature/string_setting_to_java
Choose a base branch
from

Conversation

andsel
Copy link
Owner

@andsel andsel commented Nov 8, 2024

Run with

SPEC_OPTS="-fd -P logstash-core/spec/logstash/settings/setting_with_deprecated_alias_spec.rb" ./gradlew --rerun-tasks :logstash-core:rubyTests

It produces a console output like:

    DNADBG>> before - outer
    DNADBG>> log spy in before ListAppender [
        events=[], 
        messages=[INFO  [RSPEC Example LogStash::Setting::SettingWithDeprecatedAlias when only the deprecated alias is set logs a deprecation warning (from: `./logstash-core/spec/logstash/settings/setting_with_deprecated_alias_spec.rb:124`)]: DNADBG>> Rspec test direct log
    ], 
       data=[], 
       newLine=false, 
       raw=false, 
       countDownLatch=null, 
       getHandler()=org.apache.logging.log4j.core.appender.DefaultErrorHandler@7faaa21f, 
       getLayout()=%-5p [%t]: %m%n, 
       getName()=LOG_SPY, 
       ignoreExceptions()=true, 
       getFilter()=null, 
       getState()=STARTED]
    DNADBG>> observePostProcess invoked on DeprecatedAlias: legacy.setting
    DNADBG>> spy from DeprecatedAlias.observePostProcess is: ListAppender [events=[], messages=[], data=[], newLine=false, raw=false, countDownLatch=null, getHandler()=org.apache.logging.log4j.core.appender.DefaultErrorHandler@7faaa21f, getLayout()=%-5p [%t]: %m%n, getName()=LOG_SPY, ignoreExceptions()=true, getFilter()=null, getState()=STARTED]
    DNADBG>> after - outer all appenders {LOG_SPY=ListAppender [events=[], messages=[], data=[], newLine=false, raw=false, countDownLatch=null, getHandler()=org.apache.logging.log4j.core.appender.DefaultErrorHandler@7faaa21f, getLayout()=%-5p [%t]: %m%n, getName()=LOG_SPY, ignoreExceptions()=true, getFilter()=null, getState()=STARTED]}
        logs a deprecation warning (FAILED - 2)

...
2) LogStash::Setting::SettingWithDeprecatedAlias when only the deprecated alias is set logs a deprecation warning
         Failure/Error: expect(log_spy.messages[0]).to include(deprecated_setting_name)
           expected nil to include "legacy.setting", but it does not respond to `include?`
         # ./logstash-core/spec/logstash/settings/setting_with_deprecated_alias_spec.rb:125:in `block in <main>'
         # ./spec/spec_helper.rb:84:in `block in <main>'
         # ./logstash-core/lib/logstash/util.rb:43:in `set_thread_name'
         # ./spec/spec_helper.rb:83:in `block in <main>'
         # ./spec/spec_helper.rb:76:in `block in <main>'
         # ./vendor/bundle/jruby/3.1.0/gems/logstash-devutils-2.6.2-java/lib/logstash/devutils/rspec/spec_helper.rb:47:in `block in <main>'
         # ./lib/bootstrap/rspec.rb:36:in `<main>'
...
rspec ./logstash-core/spec/logstash/settings/setting_with_deprecated_alias_spec.rb:124 # LogStash::Setting::SettingWithDeprecatedAlias when only the deprecated alias is set logs a deprecation warning

Problem statement

While in the setup section of the test the ListAppender (in state STARTED) works, grabbing the artificial log line, it doesn't catch any log that is created in the DeprecatedAlias,

@andsel andsel self-assigned this Nov 8, 2024
@andsel andsel force-pushed the feature/string_setting_to_java branch from 91e2048 to 180d597 Compare November 12, 2024 16: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.

1 participant