Skip to content

Commit

Permalink
fix: zio-http-logging (#1774)
Browse files Browse the repository at this point in the history
* public zio-http-logging

* move zio-http-logging to zio.http.logging

* scalafix
  • Loading branch information
frekw authored Nov 14, 2022
1 parent 0d0f2c0 commit 6229ad8
Show file tree
Hide file tree
Showing 20 changed files with 39 additions and 39 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ lazy val zioHttpBenchmarks = (project in file("zio-http-benchmarks"))

lazy val zioHttpLogging = (project in file("zio-http-logging"))
.settings(stdSettings("zio-http-logging"))
.settings(publishSetting(false))
.settings(publishSetting(true))
.settings(
libraryDependencies ++= {
if (isScala3(scalaVersion.value)) Seq.empty
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package zio.logging.macros
package zio.http.logging.macros

import zio.logging.macros.LoggerMacroImpl._
import zio.http.logging.macros.LoggerMacroImpl._

trait LoggerMacroExtensions { self =>
import scala.language.experimental.macros
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package zio.logging.macros
package zio.http.logging.macros

import zio.logging.{LogLevel, Logger}
import zio.http.logging.{LogLevel, Logger}

import scala.reflect.macros.whitebox

Expand All @@ -25,11 +25,11 @@ private[zio] object LoggerMacroImpl {
val lno: Tree = q"${c.enclosingPosition.line}"
val sourceLocation: Tree =
if (logLevel == LogLevel.Trace)
q"Some(_root_.zio.logging.Logger.SourcePos($cname, $lno))"
q"Some(_root_.zio.http.logging.Logger.SourcePos($cname, $lno))"
else
q"None"
val logLevelName = logLevel.name.toLowerCase.capitalize
val level: Tree = q"_root_.zio.logging.LogLevel.${TermName(logLevelName)}"
val level: Tree = q"_root_.zio.http.logging.LogLevel.${TermName(logLevelName)}"
val isEnabled: Tree = q"""${c.prefix.tree}.${TermName(s"is${logLevelName}Enabled")}"""

// LogLevel Hierarchy: Trace < Debug < Info < Warn < Error
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package zio.logging.macros
package zio.http.logging.macros

import zio.logging.Logger
import zio.logging.macros.LoggerMacroImpl._
import zio.http.logging.Logger
import zio.http.logging.macros.LoggerMacroImpl._

/**
* Core Logger class.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package zio.logging.macros
package zio.http.logging.macros

import zio.logging.Logger.SourcePos
import zio.logging.{LogLevel, Logger}
import zio.http.logging.Logger.SourcePos
import zio.http.logging.{LogLevel, Logger}

import scala.language.experimental.macros
import scala.quoted._
Expand Down
4 changes: 2 additions & 2 deletions zio-http-logging/src/main/scala/zio/logging/Font.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package zio.logging
package zio.http.logging

import zio.logging.Font._
import zio.http.logging.Font._

private[logging] sealed trait Font { self =>
def toAnsiColor: String = self match {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package zio.logging
package zio.http.logging

import java.time.format.DateTimeFormatter

Expand Down
2 changes: 1 addition & 1 deletion zio-http-logging/src/main/scala/zio/logging/LogLevel.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package zio.logging
package zio.http.logging

sealed abstract class LogLevel(val id: Int) extends Product with Serializable { self =>
final def >(other: LogLevel): Boolean = self.id > other.id
Expand Down
4 changes: 2 additions & 2 deletions zio-http-logging/src/main/scala/zio/logging/LogLine.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package zio.logging
package zio.http.logging

import zio.logging.Logger.SourcePos
import zio.http.logging.Logger.SourcePos

import java.time.LocalDateTime

Expand Down
6 changes: 3 additions & 3 deletions zio-http-logging/src/main/scala/zio/logging/Logger.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package zio.logging
package zio.http.logging

import zio.logging.Logger.SourcePos
import zio.logging.macros.LoggerMacroExtensions
import zio.http.logging.Logger.SourcePos
import zio.http.logging.macros.LoggerMacroExtensions

import java.nio.file.Path

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package zio.logging
package zio.http.logging

import zio.logging.Logger.SourcePos
import zio.http.logging.Logger.SourcePos
import zio.{LogLevel => _, _}

import java.io.{PrintWriter, StringWriter}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package zio.logging
package zio.http.logging

import zio.test._

Expand Down
4 changes: 2 additions & 2 deletions zio-http-logging/src/test/scala/zio/logging/LoggerSpec.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package zio.logging
import zio.logging.LoggerTransport.DefaultLoggerTransport
package zio.http.logging
import zio.http.logging.LoggerTransport.DefaultLoggerTransport
import zio.test._

import scala.collection.mutable.ListBuffer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import zio.http.ChannelEvent
import zio.http.ChannelEvent.UserEvent
import zio.http.service.Log
import zio.http.socket.{SocketApp, WebSocketFrame}
import zio.logging.Logger
import zio.http.logging.Logger
import zio.stacktracer.TracingImplicits.disableAutoTrace // scalafix:ok;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import io.netty.handler.logging.LoggingHandler
import io.netty.handler.proxy.HttpProxyHandler
import zio.http.URL.Location
import zio.http._
import zio.http.logging.LogLevel
import zio.http.netty.NettyFutureExecutor
import zio.http.service._
import zio.http.service.logging.LogLevelTransform.LogLevelWrapper
import zio.logging.LogLevel
import zio.{Duration, Scope, ZIO, ZKeyedPool, ZLayer}

import java.net.InetSocketAddress
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import zio.http.netty.Names
import zio.http.netty.server.ServerChannelInitializer.log
import zio.http.service.Log
import zio.http.service.logging.LogLevelTransform._
import zio.logging.LogLevel
import zio.http.logging.LogLevel
import zio.stacktracer.TracingImplicits.disableAutoTrace // scalafix:ok;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import io.netty.handler.codec.http._
import zio._
import zio.http._
import zio.http.netty.{NettyRuntime, _}
import zio.logging.Logger
import zio.http.logging.Logger
import zio.stacktracer.TracingImplicits.disableAutoTrace // scalafix:ok;
import zio.http.model._
import io.netty.util.AttributeKey
Expand Down
2 changes: 1 addition & 1 deletion zio-http/src/main/scala/zio/http/service/Logging.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package zio.http.service

import zio.logging.{LogFormat, Logger}
import zio.http.logging.{LogFormat, Logger}
import zio.stacktracer.TracingImplicits.disableAutoTrace // scalafix:ok;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package zio.http.service.logging

import zio.logging.LogLevel
import zio.http.logging.LogLevel
import zio.stacktracer.TracingImplicits.disableAutoTrace // scalafix:ok;

object LogLevelTransform {
implicit class LogLevelWrapper(level: LogLevel) {
def toNettyLogLevel: io.netty.handler.logging.LogLevel = level match {
case zio.logging.LogLevel.Trace => io.netty.handler.logging.LogLevel.TRACE
case zio.logging.LogLevel.Debug => io.netty.handler.logging.LogLevel.DEBUG
case zio.logging.LogLevel.Info => io.netty.handler.logging.LogLevel.INFO
case zio.logging.LogLevel.Warn => io.netty.handler.logging.LogLevel.WARN
case zio.logging.LogLevel.Error => io.netty.handler.logging.LogLevel.ERROR
case zio.http.logging.LogLevel.Trace => io.netty.handler.logging.LogLevel.TRACE
case zio.http.logging.LogLevel.Debug => io.netty.handler.logging.LogLevel.DEBUG
case zio.http.logging.LogLevel.Info => io.netty.handler.logging.LogLevel.INFO
case zio.http.logging.LogLevel.Warn => io.netty.handler.logging.LogLevel.WARN
case zio.http.logging.LogLevel.Error => io.netty.handler.logging.LogLevel.ERROR
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package zio.http.service.logging

import io.netty.util.internal.logging.{AbstractInternalLogger, InternalLogger, InternalLoggerFactory}
import zio.http.service.logging.NettyLoggerFactory.Live
import zio.logging.{LogLevel, Logger}
import zio.http.logging.{LogLevel, Logger}
import zio.stacktracer.TracingImplicits.disableAutoTrace // scalafix:ok;

/**
Expand Down

0 comments on commit 6229ad8

Please sign in to comment.