-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from llfrometa89/master
Refactoring structure in modules [core|cats|scalaz]
- Loading branch information
Showing
20 changed files
with
601 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
style = defaultWithAlign | ||
maxColumn = 120 | ||
|
||
continuationIndent.callSite = 2 | ||
|
||
newlines { | ||
sometimesBeforeColonInMethodReturnType = false | ||
} | ||
|
||
align { | ||
arrowEnumeratorGenerator = false | ||
ifWhileOpenParen = false | ||
openParenCallSite = false | ||
openParenDefnSite = false | ||
} | ||
|
||
docstrings = JavaDoc | ||
|
||
rewrite { | ||
rules = [SortImports, RedundantBraces, RedundantParens] | ||
redundantBraces.maxLines = 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 0 additions & 13 deletions
13
core/shared/src/main/scala/org/pure4s/logger4s/GLogger.scala
This file was deleted.
Oops, something went wrong.
49 changes: 6 additions & 43 deletions
49
core/shared/src/main/scala/org/pure4s/logger4s/Logger.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,9 @@ | ||
package org.pure4s.logger4s | ||
|
||
import cats.Show | ||
import cats.effect.Sync | ||
import org.slf4j | ||
import org.slf4j.LoggerFactory | ||
import cats.implicits._ | ||
|
||
trait Logger[F[_]] extends SLogger[F] with GLogger[F] | ||
|
||
object Logger { | ||
|
||
def apply[F[_]](implicit F: Logger[F]): Logger[F] = F | ||
|
||
def instance[F[_] : Sync](clazz: Class[_]) | ||
(implicit logger: slf4j.Logger = LoggerFactory.getLogger(clazz)): Logger[F] = new Logger[F] { | ||
|
||
def error(msg: String): F[Unit] = Sync[F].delay(logger.error(msg)) | ||
def error(msg: String, err: Throwable): F[Unit] = Sync[F].delay(logger.error(msg, err)) | ||
def warn(msg: String): F[Unit] = Sync[F].delay(logger.warn(msg)) | ||
def info(msg: String): F[Unit] = Sync[F].delay(logger.info(msg)) | ||
def debug(msg: String): F[Unit] = Sync[F].delay(logger.debug(msg)) | ||
|
||
def error[A: Show](msg: A): F[Unit] = error(msg.show) | ||
def error[A: Show](msg: A, err: Throwable): F[Unit] = error(msg.show, err) | ||
def warn[A: Show](msg: A): F[Unit] = warn(msg.show) | ||
def info[A: Show](msg: A): F[Unit] = info(msg.show) | ||
def debug[A: Show](msg: A): F[Unit] = debug(msg.show) | ||
|
||
} | ||
|
||
implicit def instance[F[_] : Sync](implicit logger: slf4j.Logger): Logger[F] = new Logger[F] { | ||
|
||
def error(msg: String): F[Unit] = Sync[F].delay(logger.error(msg)) | ||
def error(msg: String, err: Throwable): F[Unit] = Sync[F].delay(logger.error(msg, err)) | ||
def warn(msg: String): F[Unit] = Sync[F].delay(logger.warn(msg)) | ||
def info(msg: String): F[Unit] = Sync[F].delay(logger.info(msg)) | ||
def debug(msg: String): F[Unit] = Sync[F].delay(logger.debug(msg)) | ||
|
||
def error[A: Show](msg: A): F[Unit] = error(msg.show) | ||
def error[A: Show](msg: A, err: Throwable): F[Unit] = error(msg.show, err) | ||
def warn[A: Show](msg: A): F[Unit] = warn(msg.show) | ||
def info[A: Show](msg: A): F[Unit] = info(msg.show) | ||
def debug[A: Show](msg: A): F[Unit] = debug(msg.show) | ||
} | ||
trait Logger[F[_]] { | ||
def error(msg: String): F[Unit] | ||
def error(msg: String, err: Throwable): F[Unit] | ||
def warn(msg: String): F[Unit] | ||
def info(msg: String): F[Unit] | ||
def debug(msg: String): F[Unit] | ||
} |
11 changes: 0 additions & 11 deletions
11
core/shared/src/main/scala/org/pure4s/logger4s/SLogger.scala
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import cats.effect.IO | ||
import org.pure4s.logger4s.LazyLogging | ||
import org.pure4s.logger4s.cats.Logger | ||
import org.pure4s.logger4s.cats.Logger._ | ||
|
||
object BasicExampleMain extends App with LazyLogging { | ||
Logger[IO].info(s"Hello word, purely functional logger").unsafeRunSync() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.