Skip to content

Commit

Permalink
Merge pull request #640 from KristianAN/master
Browse files Browse the repository at this point in the history
Fixes SlackWriter to evaluate the IO.
  • Loading branch information
darkfrog26 authored Oct 19, 2024
2 parents 47d0bf7 + 749b65c commit 5b56d4d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions logstash/src/main/scala/scribe/logstash/LogstashWriter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ case class LogstashWriter(url: URL,
private lazy val client = HttpClient.url(url).post

override def write(record: LogRecord, output: LogOutput, outputFormat: OutputFormat): Unit = {
val io = log(record)
val io = log(record) // Does nothing
if (!asynchronous) {
io.unsafeRunSync()
}
Expand Down Expand Up @@ -57,4 +57,4 @@ case class LogstashWriter(url: URL,
val content = Content.json(json.merge(additional))
client.content(content).send()
}
}
}
7 changes: 5 additions & 2 deletions slack/src/main/scala/scribe/slack/SlackWriter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import scribe.LogRecord
import scribe.output.LogOutput
import scribe.output.format.OutputFormat
import scribe.writer.Writer
import cats.effect.unsafe.implicits.global

/**
* SlackWriter is
Expand All @@ -12,8 +13,10 @@ import scribe.writer.Writer
* @param emojiIcon the emoji to use when sending messages
*/
class SlackWriter(slack: Slack, emojiIcon: String) extends Writer {

override def write(record: LogRecord, output: LogOutput, outputFormat: OutputFormat): Unit = slack.request(
message = output.plainText,
emojiIcon = emojiIcon
)
}
).unsafeRunAndForget()

}

0 comments on commit 5b56d4d

Please sign in to comment.