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

Wrong Log Level when writing json file #10

Closed
serinth opened this issue Feb 9, 2017 · 4 comments
Closed

Wrong Log Level when writing json file #10

serinth opened this issue Feb 9, 2017 · 4 comments

Comments

@serinth
Copy link

serinth commented Feb 9, 2017

Running on Mac OS the Pact daemon with no arguments we get this output:

2017/02/09 15:33:14 [ERROR] 
2017/02/09 15:33:14 [ERROR] Writing pact for <SERVICE> to /Users/<OMITTED>/go/src/<FILE>.json

I've replaced some sensitive info with , and .
The json file gets written properly so functionally it's fine. The [ERROR] is probably just the wrong log level.

@mefellows
Copy link
Member

Unfortunately this is just how the underlying Ruby process works, it was certainly confusing to me at first (also requiring some coding gymnastics to interpret actual errors!). This seems to be a common thing in other Pact implementations also (at least in Java). I'll ask some others in the Pact community to get a better understanding.

@bethesque
Copy link
Member

I don't think it's the ruby. Here's the code.

https://github.com/pact-foundation/pact-mock_service/blob/master/lib/pact/mock_service/app.rb#L49

def write_pact_if_configured
        consumer_contract_writer = ConsumerContractWriter.new(@session.consumer_contract_details, StdoutLogger.new)
        consumer_contract_writer.write if consumer_contract_writer.can_write?
      end

    # Can't write to a file in a TRAP, might deadlock
    class StdoutLogger
      def info message
        $stdout.puts "\n#{message}"
      end
    end
  end

https://github.com/pact-foundation/pact-mock_service/blob/master/lib/pact/consumer_contract/consumer_contract_writer.rb#L56

def update_pactfile
      logger.info log_message

      ...
    end

    def log_message
      if updating?
        "Updating pact for #{provider_name} at #{pactfile_path}"
      else
        "Writing pact for #{provider_name} to #{pactfile_path}"
      end
    end

@mefellows
Copy link
Member

Thanks Beth, I'm digging into this again just now.

@mefellows
Copy link
Member

That fix now does imply that we get an ERROR when the Ruby process shuts down (WEBrick seems to write to stderror) but it fixes the problem - simple mistake, sorry team!

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

3 participants