1

I am able to log things with things like

logger.debug "This is a logged string"

but when I try to do something like

logger.debug "This is the object: " + object_name

it doesn't like that and gives an error. How do I concatinate the object into a string and output it together with whatever I want to label that debug line?

Thanks!

1
  • try using parentheses... Commented Apr 18, 2012 at 19:58

2 Answers 2

5

You can probably do something like:

logger.debug "This is the object: #{object_name.inspect}"
Sign up to request clarification or add additional context in comments.

2 Comments

yes that was it. StackOverflow says I can accept your answer in 10 min, and I'll do that then :) need 15 karma points to upvote answers :)
Using string interpolation (with inspect) is more idiomatic.
1

You could use Ruby's string interpolation.

logger.debug "This is the object: #{object_name}"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.