Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Sep 30 17:39

    darkfrog26 on master

    Updated dependencies and added … Release 2.7.13 Merge remote-tracking branch 'o… (compare)

  • Sep 30 17:38

    darkfrog26 on 2.7.13

    Updated dependencies and added … Release 2.7.13 (compare)

  • Jul 27 15:39
    darkfrog26 commented #123
  • Jul 27 15:39

    darkfrog26 on master

    Fix Travis CI - Change jdk to … Merge pull request #123 from lo… (compare)

  • Jul 27 15:39
    darkfrog26 closed #123
  • Jul 25 13:53
    lolgab commented #123
  • Jul 25 13:50
    lolgab ready_for_review #123
  • Jul 25 13:49
    lolgab opened #123
  • May 22 15:16
    darkfrog26 opened #122
  • May 13 13:37
    darkfrog26 commented #79
  • May 12 23:52
    jvican commented #79
  • Mar 02 15:33
    david-bouyssie closed #120
  • Mar 02 15:33
    david-bouyssie commented #120
  • Mar 02 14:35
    darkfrog26 commented #120
  • Mar 02 08:28
    david-bouyssie commented #120
  • Feb 29 22:24

    darkfrog26 on 2.7.12

    (compare)

  • Feb 29 22:24

    darkfrog26 on master

    Release 2.7.12 (compare)

  • Feb 29 22:07

    darkfrog26 on master

    Update Scala.js to 1.0.0 - Cle… Fix travis deprecations Merge pull request #121 from lo… (compare)

  • Feb 29 22:07
    darkfrog26 closed #121
  • Feb 29 16:46
    lolgab synchronize #121
Sivakumar Rallabhandi
@siva538
No Problem Matt. Thanks for your response. Is there anywhere we can track how many number of active projects running using Scribe? Reason for asking this is, to make sure there is good amount of support available for any questions, without bothering you on this. Thanks again ! @darkfrog26
Matt Hicks
@darkfrog26
@siva538 honestly not sure how many projects use Scribe, but I know there are a lot
it just tends to "work", so most of the time there's not a great need for support
and if you find something you need that doesn't exist, it's trivial to add it yourself since Scribe is incredibly easy to extend
Sherif Mohamed
@sherifkandeel
Hi guys, Just started using scribe for a little gatling project to see how it performs. currently I am having trouble setting the log level. it seems that debug("message") doesn't go through. but info and error do. I couldn't find a reference somewhere on how to set it.
Sherif Mohamed
@sherifkandeel
Basically what I want to know is that is there's a way to set a simple log level to the default root logger, so that I can still simply use it by importing scribe._ and still be able to log debug and trace logs?
Matt Hicks
@darkfrog26
@sherifkandeel sorry for the late reply, the reason is that the default logging level if Info and above
Here's the default config: https://github.com/outr/scribe/blob/master/core/shared/src/main/scala/scribe/Logger.scala#L68
If you want to log everything you can just do: scribe.Logger.root.clearHandlers().withHandler().replace()
That will remove all default handlers off the root logger and add a new default handler. The replace() line is for inline replacement of an existing logger since Scribe loggers are immutable those builder pattern calls are deriving a new logger, not mutating the existing.
I'd highly recommend enabling enhanced logging though: scribe.Logger.root.clearHandlers().withHandler(Formatter.enhanced).replace()
FYI, the default logger is the console logging
you can easily add another withHandler to that to add a file logger
Matt Hicks
@darkfrog26
like:
.withHandler(
        minimumLevel = Some(scribe.Level.Info),
        writer = FileWriter().path(LogPath.daily("myapp"))
)
Sherif Mohamed
@sherifkandeel
@darkfrog26 perfect, yes, I eventually found how to do that, thank you very much.
Another question about the Formatter part, we use datadog for collecting logs. and I was wondeirng if I can use a formatter to wrap things in a json format before being logged, I assume that's somehow possible with the custom formatters, is that correct? I haven't explored it yet :)
Matt Hicks
@darkfrog26
@sherifkandeel, I'd take a look at the LogstashWriter as a simple example of writing JSON: https://github.com/outr/scribe/blob/master/logstash/src/main/scala/scribe/logstash/LogstashWriter.scala
Note that it's the Writer you want to implement, not the Formatter
Sherif Mohamed
@sherifkandeel
ah I see, and I just attach the writer to the handler same way you showed before, got it :) thank you for the immense help :)
Matt Hicks
@darkfrog26
@sherifkandeel no problem, just let me know if you find anything that is confusing or could be improved.
Sivakumar Rallabhandi
@siva538

Hello Matt (@darkfrog26), have seen the lists above, but I couldn't see an example of the rolling file. Is that still possible with a formatter?

Am looking something similar to - https://www.codejava.net/coding/configure-log4j-for-creating-daily-rolling-log-files

Thanks in advance.

Sivakumar Rallabhandi
@siva538
Sorry another question.. do we have the support for the Splunk logging? Thanks a lot
Matt Hicks
@darkfrog26
If you want a consistent "current" file you can use rolling (https://github.com/outr/scribe/blob/master/core/jvm/src/test/scala/spec/FileLoggingSpec.scala#L210) and if you want a standardized daily log you can use FileWriter().path(LogPath.daily("myapp"))
@siva538 as for Splunk, I don't believe you'll need special support since it's meant to process log files, not be written to directly...unless things have changed since the last time I used it.
Sherif Mohamed
@sherifkandeel
@darkfrog26 I followed your advice for writing a json logger, but I don't like that I am using println, is there a better way to make use of ConsoleWriter for example?
object Logging {
  val handler: LogHandler = scribe.handler.LogHandler(minimumLevel = Some(Level.Trace), writer = JsonWriter)
  scribe.Logger.root.clearHandlers().withHandler(handler).replace()
  val logger: Logger = scribe.Logger.root

  case class DataDogRecord(`@timestamp`: Long,
                           message: String,
                           level: String,
                           methodName: Option[String],
                           line: Option[Int],
                           sourceThread: String)

  object DataDogFormat extends DefaultJsonProtocol {
    implicit val DataDogRecordFormat = jsonFormat(DataDogRecord, "timestamp", "message", "level", "methodName", "line", "sourceThread")
  }

  object JsonWriter extends Writer with DefaultJsonProtocol {
    import DataDogFormat._

    override def write[M](record: LogRecord[M], output: LogOutput): Unit = {
      val timestamp = record.timeStamp
      val r = DataDogRecord(
        message = record.message.plainText,
        level = record.level.name,
        methodName = record.methodName,
        line = record.line,
        sourceThread = record.thread.getName,
        `@timestamp` = timestamp
      )

      val jsonObj = r.toJson
      println(jsonObj)
    }
  }
}
Matt Hicks
@darkfrog26
@sherifkandeel, you could do something like:
import scribe.output._
ConsoleWriter.write(record, text(jsonObject.toString()))
That should do what you want I think. Sorry, in the process of moving across the country, so my availability isn't great.
Sherif Mohamed
@sherifkandeel

@darkfrog26 good luck with moving :) it works thank you!

Now I wonder if there's a way to define the loglevel as env variable? right now I can only see it works by defining one of Level case objects. but for example I want to be able to define it as env variable, is there a way to import that directly without having to match on the String value from the env variable?

Matt Hicks
@darkfrog26
@sherifkandeel, that's actually a really good point. I keep meaning to take some time to add a scribe-config module to simplify things, but if you'll create a ticket on GitHub for that I'll make sure it gets case class representation to make sure it can be persisted.
mickymiek
@mickymiek

Hi everyone, I'm stumbling on a weird issue here and I was wondering if you guys knew why my code has this behavior.

I have a scribe logger, with a verbosity of info:

  val handler = LogHandler(
    writer = new MyWriter(),
    minimumLevel = Some(Level.Info)
  )
  var logger = scribe.Logger.empty.withHandler(handler)

I have a function to change the verbosity of the logger, which is basically:

    val handler = logger.handlers(0)
    handler.withMinimumLevel(Level.Error)
    logger.clearHandlers().withHandler(handler).replace()

but when I log something after calling this function, my logger is still in info.
The only way i've found to make it work is to redefine the logger in my setVerbosity function:

    val newHandler = LogHandler(
      writer = logger.handlers(0).writer,
      minimumLevel = Some(Level.Error)
    )
    logger = scribe.Logger.empty.withHandler(newHandler)

Hope you can help :) thanks

Matt Hicks
@darkfrog26
@mickymiek realize that loggers are immutable in Scribe. So, you need to re-assign to logger. The replace() method is for named loggers, which it doesn't appear you are using here.
the withSomething methodology, it follows a builder pattern that creates a new instance of the logger "with" that change.
This is meant to allow you to create multiple loggers easily and even build off existing loggers to create new ones as needed.
mickymiek
@mickymiek
@darkfrog26 thanks for the answer ! It's mostly clear now :)
However I can't seem to find how to define a named logger, maybe I'm missing something?
Matt Hicks
@darkfrog26
@mickymiek, just call Logger("myLoggerNameHere") to get a named logger and call replace() to set the changes back.
mickymiek
@mickymiek
Alright perfect ! Thanks a lot
Matt Hicks
@darkfrog26
No problem. Let me know if you run into any other issues. If you find something that could be made less confusing, please let me know.
mickymiek
@mickymiek
Sure thing
Joan Goyeau
@joan38
Hey,
I'm trying to use scribe in a Flink app with some custom config via Logger.root.withHandler(writer = fileWriter).replace().
This statement is currently in the main and it works for the logging in the job manager.
But it doesn't work for the logs executed on the workers because functions get serialized/deserialized and run without going through the main.
So where do you recommend to put the config?
Matt Hicks
@darkfrog26

@joan38 hmmm, that's a good question. What you might do is define a lazily loaded root (or your own) logger reference that sets this up like:

object MyApplication {
  lazy val logger: Logger = Logger.root.withHandler(writer = fileWriter).replace()
}

and then instead of using scribe.info execute MyApplication.logger.info or import MyApplication.logger._?

This will allow you to guarantee that the logger will be properly configured before it's used.
Joan Goyeau
@joan38
I ended up doing that actrually thanks @darkfrog26
I didn't use lazy actually, does it change much?
Matt Hicks
@darkfrog26
@joan38 I guess not really, the only major benefit is that if you have instantiations of the application that aren't using logging, it wouldn't need to do anything there.
Joan Goyeau
@joan38
:thumbsup: thanks for the help
Joan Goyeau
@joan38
I get an issue with scribe and http4s client where after an http call if I log it hangs for ever in the IO monad.
Anybody got the same issue?
Matt Hicks
@darkfrog26
@joan38 is the code public?
It might be worth trying with YouI's HttpClient to see if it's a specific bug on Http4s: https://github.com/outr/youi/blob/master/client/jvm/src/test/scala/spec/HttpClientSpec.scala
that's some example code on how easy it is to use.
you just need the youi-client dependency
Joan Goyeau
@joan38
@darkfrog26 It's private but I ended up making it work, so I must have done something wrong.