Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out. cannot be used with primitive types

See original GitHub issue


import com.typesafe.scalalogging.StrictLogging

new StrictLogging {"2 + 2 == {}", new Integer(4)) // compiles"2 + 2 == {}", 4)              // fails to compile

The error is:

overloaded method value info with alternatives:
  (marker: org.slf4j.Marker,message: String,args: AnyRef*)Unit <and>
  (marker: org.slf4j.Marker,message: String)Unit <and>
  (message: String,args: AnyRef*)Unit <and>
  (message: String,cause: Throwable)Unit
cannot be applied to (String, Int)

Is there any reason for using AnyRef* instead of Any* in:

class Logger {
  def info(message: String, args: AnyRef*): Unit = macro LoggerMacro.infoMessageArgs

If not, I can fix it and create a PR.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:15

github_iconTop GitHub Comments

ptxmaccommented, Oct 18, 2015

Actually the string interpolation isn’t evaluated unless the logger is enabled! The logger macros converts logger.debug into a if statement that checks if debug is enabled before calling the logger.

stefanvanwouwcommented, Oct 7, 2015

I encountered the same problem and circumvented it by using Scala’s String Interpolation feature . When using sfl4j LoggerFactory’s logger directly similar problems occur as the one you describe above.

Read more comments on GitHub >

github_iconTop Results From Across the Web cannot be used with primitive types #38 - GitHub
I encountered the same problem and circumvented it by using Scala's String Interpolation feature
Read more >
String Format and Logging primative types - Java
The problem is when calling String.format() with callerClass and args, Java Varargs creates a new array containing a string and an array, which ......
Read more >
Logger info(String) method in Java with Examples
The info() method of a Logger class is used to Log an INFO message. This method is used to forward logs to all...
Read more >
Logging HOWTO — Python 3.11.1 documentation
Multiple calls to getLogger() with the same name will return a reference to the same logger object. Loggers that are further down in...
Read more >
Data Types in Java | Primitive and Non-Primitive Data Types
A boolean data type comprises of a bit of information and can store only true or false values. This data type is used...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found