Logging

ldbc can export execution and error logs of database connections in any format using any logging library.

The standard logger using Cats Effect's Console is provided and can be used during development.

given LogHandler[IO] = LogHandler.console[IO]

Use ldbc.dsl.logging.LogHandler to customize logging using any logging library.

The following is the standard implementation of logging. ldbc generates the following three types of events on database connection

Each event is sorted by pattern matching to determine what kind of log to write.

def console[F[_]: Console: Sync]: LogHandler[F] =
  case LogEvent.Success(sql, args) =>
    Console[F].println(
      s"""Successful Statement Execution:
         |  $sql
         |
         | arguments = [${ args.mkString(",") }]
         |""".stripMargin
    )
  case LogEvent.ProcessingFailure(sql, args, failure) =>
    Console[F].errorln(
      s"""Failed ResultSet Processing:
         |  $sql
         |
         | arguments = [${ args.mkString(",") }]
         |""".stripMargin
    ) >> Console[F].printStackTrace(failure)
  case LogEvent.ExecFailure(sql, args, failure) =>
    Console[F].errorln(
      s"""Failed Statement Execution:
         |  $sql
         |
         | arguments = [${ args.mkString(",") }]
         |""".stripMargin
    ) >> Console[F].printStackTrace(failure)