<configuration scan="true" scanPeriod="5 seconds">
  <timestamp key="bySecond" datePattern="yyyy-MM-dd_HH-mm-ss"/>

  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <encoder>
      <pattern>[%highlight(%5level)] %logger{35} - %msg%n</pattern>
    </encoder>
    <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
      <level>INFO</level>
    </filter>
  </appender>

  <appender name="FILE-GENERAL" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>logs/psforever-general_${bySecond}.log</file>
    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
      <fileNamePattern>logs/psforever-general_%d{yyyy-MM-dd}.gz</fileNamePattern>
      <maxHistory>60</maxHistory>
      <totalSizeCap>10GB</totalSizeCap>
    </rollingPolicy>
    <encoder>
      <pattern>%date{ISO8601} %5level %logger{35} - %msg%n</pattern>
    </encoder>
    <filter class="net.psforever.filter.MsgRegexFilter">
      <!-- occurs during latency or relogging complications; the messages are useless -->
      <regex>Unexpected packet type EncryptedPacket</regex>
    </filter>
    <filter class="net.psforever.filters.LoggerPrefixFilter">
      <!--
       c.g.j.s.d.p.c.PostgreSQLConnectionHandler
      -->
      <prefix>com.github.jasync.sql.db.postgresql.codec</prefix>
    </filter>
    <filter class="net.psforever.filters.LoggerPrefixFilter">
      <!--
       i.s.c.AbstractConnection.lockdown
       i.sentry.connection.AsyncConnection
      -->
      <prefix>io.sentry.connection</prefix>
    </filter>
    <filter class="net.psforever.filters.LoggerPrefixFilter">
      <!-- damage log -->
      <prefix>DamageResolution</prefix>
    </filter>
    <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
      <level>INFO</level>
    </filter>
    <filter class="net.psforever.filters.ApplyCooldownToDuplicateLoggingFilter">
      <cooldown>5000</cooldown>
    </filter>
  </appender>

  <appender name="FILE-DEBUG" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>logs/psforever-debug_${bySecond}.log</file>
    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
      <fileNamePattern>logs/psforever-debug_%d{yyyy-MM-dd}.gz</fileNamePattern>
      <maxHistory>60</maxHistory>
      <totalSizeCap>10GB</totalSizeCap>
    </rollingPolicy>
    <encoder>
      <pattern>%date{ISO8601} [%thread] %5level "%X" %logger{35} - %msg%n</pattern>
    </encoder>
    <filter class="net.psforever.filters.LoggerPrefixFilter">
      <!--
       c.g.j.s.d.p.e.CloseStatementEncoder
       c.g.j.s.d.p.e.PreparedStatementEncoderHelper
       c.g.j.s.d.p.e.PreparedStatementOpeningEncoder
       c.g.j.s.d.p.e.QueryMessageEncoder
       -->
      <prefix>com.github.jasync.sql.db.postgresql.encoders</prefix>
    </filter>
    <filter class="net.psforever.filters.LoggerPrefixFilter">
      <!--
       c.g.j.s.d.p.c.PostgreSQLConnectionHandler
       consider: c.g.j.s.d.p.PostgreSQLConnection?
      -->
      <prefix>com.github.jasync.sql.db.postgresql.codec</prefix>
    </filter>
    <filter class="net.psforever.filters.LoggerPrefixFilter">
      <!-- i.g.context.jasync.JAsyncContext -->
      <prefix>io.getquill.context.jasync</prefix>
    </filter>
    <filter class="ch.qos.logback.classic.filter.LevelFilter">
      <level>DEBUG</level>
      <onMatch>ACCEPT</onMatch>
      <onMismatch>DENY</onMismatch>
    </filter>
    <!-- <filter class="ch.qos.logback.classic.filter.LevelFilter">
      <level>TRACE</level>
      <onMatch>ACCEPT</onMatch>
      <onMismatch>DENY</onMismatch>
    </filter> -->
  </appender>

  <appender name="Sentry" class="io.sentry.logback.SentryAppender">
    <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
      <level>WARN</level>
    </filter>
    <filter class="net.psforever.filters.MsgRegexFilter">
      <!-- occurs during logging or relogging complications; the messages are useless -->
      <regex>Unexpected packet type EncryptedPacket</regex>
    </filter>
  </appender>

  <root level="TRACE">
    <appender-ref ref="STDOUT"/>
    <appender-ref ref="FILE-GENERAL"/>
    <appender-ref ref="FILE-DEBUG"/>
    <appender-ref ref="Sentry"/>
  </root>

  <!-- Logger specific overrides -->
  <logger name="oshi" level="OFF"/>
</configuration>
