Skip to content
This repository has been archived by the owner on Jul 29, 2021. It is now read-only.

Commit

Permalink
Merge pull request #10 from writeonly/logging
Browse files Browse the repository at this point in the history
Logging
  • Loading branch information
kamil-adam committed Jan 9, 2019
2 parents 87372e8 + 6988a9b commit 3453b4d
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 16 deletions.
31 changes: 20 additions & 11 deletions README.md
Expand Up @@ -9,37 +9,37 @@ cd resentiment

Refactor and reformat:
```bash
sbt scalafix test:scalafix it:scalafix && \
sbt scalafix test:scalafix it:scalafix &&
sbt scalafmtSbt scalafmt test:scalafmt it:scalafmt
```

Check lint and format:
```bash
sbt 're/scalafix --check' 're/test:scalafix --check' 're/it:scalafix --check' && \
sbt 're/scalafix --check' 're/test:scalafix --check' 're/it:scalafix --check' &&
sbt scalafmtSbtCheck re/scalafmtCheck re/test:scalafmtCheck re/it:scalafmtCheck
```

Compile, test and generate coverage report:
```bash
sbt clean compile test:compile it:compile re/test && \
sbt coverage reJS/test reJVM/test reJS/it:test reJVM/it:test coverageReport &&
sbt clean compile test:compile it:compile re/test &&
sbt coverage reJS/test reJVM/test reJS/it:test reJVM/it:test coverageReport &&
sbt coverageAggregate
```

Check:
```bash
sbt scalastyle test:scalastyle it:scalastyle && \
sbt scalastyle test:scalastyle it:scalastyle &&
sbt scapegoat cpd stats
```

All:
```bash
sbt re/scalafix re/test:scalafix re/it:scalafix && \
sbt re/scalafmtSbt re/scalafmt re/test:scalafmt re/it:scalafmt && \
sbt clean re/compile re/test:compile re/it:compile re/test && \
sbt coverage reJS/test reJVM/test reJS/it:test reJVM/it:test coverageReport && \
sbt coverageAggregate && \
sbt scalastyle test:scalastyle it:scalastyle && \
sbt re/scalafix re/test:scalafix re/it:scalafix &&
sbt re/scalafmtSbt re/scalafmt re/test:scalafmt re/it:scalafmt &&
sbt clean re/compile re/test:compile re/it:compile re/test &&
sbt coverage reJS/test reJVM/test reJS/it:test reJVM/it:test coverageReport &&
sbt coverageAggregate &&
sbt scalastyle test:scalastyle it:scalastyle &&
sbt scapegoat cpd stats
```

Expand All @@ -53,3 +53,12 @@ sbt coverageAggregate &&
sbt scalastyle test:scalastyle it:scalastyle &&
sbt scapegoat cpd stats
```

Only Scala Native
```bash
sbt re/scalafix re/test:scalafix re/it:scalafix &&
sbt re/scalafmtSbt re/scalafmt re/test:scalafmt re/it:scalafmt &&
sbt clean re/compile re/test:compile re/it:compile re/test &&
sbt scalastyle test:scalastyle it:scalastyle &&
sbt scapegoat cpd stats
```
17 changes: 16 additions & 1 deletion build.sbt
Expand Up @@ -19,6 +19,7 @@ scalaVersion := "2.11.12"
scapegoatVersion in ThisBuild := "1.3.8"
scalacOptions ++= scalacOptionsFor(scalaVersion.value)
val ScalaPropsVersion = "0.5.5"
val SloggingVersion = "0.6.1"

val SharedSettings = Seq(
scalaVersion := "2.11.12",
Expand All @@ -33,6 +34,9 @@ val SharedSettings = Seq(
"com.github.scalaprops" %%% "scalaprops" % ScalaPropsVersion % "test,it",
"com.github.scalaprops" %%% "scalaprops-scalazlaws" % ScalaPropsVersion % "test,it",
),
libraryDependencies ++= Seq(
"biz.enef" %%% "slogging" % SloggingVersion,
),
scalaJSUseMainModuleInitializer := true,
scalaJSMainModuleInitializer := Some(
ModuleInitializer.mainMethod(mainClassString, "main")
Expand All @@ -46,15 +50,26 @@ val jsSettings = Seq(
mainClass in Compile := mainClassSome,
scalaJSUseMainModuleInitializer := true,
coverageEnabled := true,
libraryDependencies ++= Seq(
"biz.enef" %%% "slogging-winston" % SloggingVersion,
),
)

val jvmSettings = Seq(
mainClass in Compile := mainClassSome,
scalaJSUseMainModuleInitializer := true,
coverageEnabled := true,
libraryDependencies ++= Seq(
"ch.qos.logback" % "logback-classic" % "1.2.3",
),
)

val nativeSettings = Seq(nativeLinkStubs := true)
val nativeSettings = Seq(
nativeLinkStubs := true,
libraryDependencies ++= Seq(
"biz.enef" %%% "slogging-syslog" % SloggingVersion,
),
)

lazy val re = crossProject(JSPlatform, JVMPlatform, NativePlatform)
.withoutSuffixFor(NativePlatform)
Expand Down
11 changes: 8 additions & 3 deletions re/shared/src/main/scala/pl/writeonly/re/shared/Core.scala
@@ -1,7 +1,12 @@
package pl.writeonly.re.shared

object Core {
def apply(arg: String): Unit = {
println(s"Hello Scala $arg!")
trait Core {
def apply(arg: String): Unit
}

object Core extends Core {
override def apply(arg: String): Unit = {
StrictLoggingCore(arg)
LazyLoggingCore(arg)
}
}
@@ -0,0 +1,9 @@
package pl.writeonly.re.shared

import slogging.LazyLogging

object LazyLoggingCore extends Core with LazyLogging {
def apply(arg: String): Unit = {
logger.info(s"Hello Scala $arg!")
}
}
@@ -0,0 +1,9 @@
package pl.writeonly.re.shared

import slogging.StrictLogging

object StrictLoggingCore extends Core with StrictLogging {
def apply(arg: String): Unit = {
logger.info(s"Hello Scala $arg!")
}
}
11 changes: 11 additions & 0 deletions re/shared/src/test/scala/pl/writeonly/re/shared/CoreTest.scala
@@ -0,0 +1,11 @@
package pl.writeonly.re.shared

import utest._

object CoreTest extends TestSuite {
override val tests: Tests = Tests {
'core - {
Core("Awesome")
}
}
}
2 changes: 1 addition & 1 deletion scalastyle-config.xml
Expand Up @@ -55,7 +55,7 @@
<check level="error" class="org.scalastyle.scalariform.NoFinalizeChecker" enabled="true"></check>
<check level="error" class="org.scalastyle.scalariform.CovariantEqualsChecker" enabled="true"></check>
<check level="error" class="org.scalastyle.scalariform.StructuralTypeChecker" enabled="true"></check>
<check level="warning" class="org.scalastyle.file.RegexChecker" enabled="true">
<check level="error" class="org.scalastyle.file.RegexChecker" enabled="true">
<parameters>
<parameter name="regex"><![CDATA[println]]></parameter>
</parameters>
Expand Down

0 comments on commit 3453b4d

Please sign in to comment.