blindsight icon indicating copy to clipboard operation
blindsight copied to clipboard

Wrong line numbers

Open kamilkloch opened this issue 2 years ago • 3 comments

Blindsight logs wrong line numbers. Source file

package testing

import ch.qos.logback.classic.LoggerContext
import com.tersesystems.blindsight.LoggerFactory


class A {
  private val log = LoggerFactory.getLogger
  
  def f(): Unit = {
    log.info("Hello from blindsight")
  }
}
object BlindsightTest extends App {
  
  val a = new A
  a.f()

  org.slf4j.LoggerFactory.getILoggerFactory.asInstanceOf[LoggerContext].stop()
}

Log message:

​[2023-08-03 23:27:51,668] INFO  [main] t.A:251 - Hello from blindsight

kamilkloch avatar Aug 03 '23 21:08 kamilkloch

logger.info(s"${implicitly[sourcecode.Line]}")

prints

15:33:49.585 [INFO ] e.R.SimpleExample:251 -  Line(43)

How are the captured implicit parameters (implicit line: Line, file: File, enclosing: Enclosing) further utilized in org.slf4j.Logger:info?

https://github.com/tersesystems/blindsight/blob/8bd69d5a164420dece13809049d10f4401453dad/api/src/main/scala/com/tersesystems/blindsight/core/ParameterList.scala#L250

EDIT: Is line perhaps logging restricted only to logstash encoder?

kamilkloch avatar Aug 04 '23 13:08 kamilkloch

Source code is enabled by setting <property name="blindsight.source.enabled" value="true" scope="context"/> in a logback.xml file https://tersesystems.github.io/blindsight/usage/sourcecode.html

wsargent avatar Aug 10 '23 00:08 wsargent

I did try all the things you mentioned - still no luck with proper line numbers in the console / text file. (JSON is OK) Also, uniqueId does not work anywhere (json / console). I distilled the full example in thge following repo: https://github.com/kamilkloch/blindsight-tests

Here is the console output:

null 11:31:02.898 [INFO ] e.R.SimpleExample:275 -  Line(45)
null 11:31:02.916 [INFO ] e.R.SimpleExample:275 -  This is an info statement
null 11:31:02.926 [INFO ] e.R.SimpleExample:293 -  Using args {name=will, age=12} 1691659862917 2023-08-10T09:31:02.917175Z
null 11:31:02.927 [INFO ] e.R.SimpleExample:293 -  Using Arguments({name=will, age=12} 1691659862927 2023-08-10T09:31:02.927509Z)
null 11:31:02.942 [INFO ] e.R.SimpleExample:293 -  1691659862935

kamilkloch avatar Aug 10 '23 09:08 kamilkloch