Skip to content

Commit 4d28523

Browse files
committed
replace sbt-release with sbt-ci-release
includes adopting sbt-dynver (to set `version`) and sbt-travisci (to set `scalaVersion` and `crossScalaVersions`) fixes #254
1 parent cedbc55 commit 4d28523

File tree

6 files changed

+62
-103
lines changed

6 files changed

+62
-103
lines changed

.travis.yml

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,30 @@ import: scala/scala-dev:travis/default.yml
33
language: scala
44

55
scala:
6-
- 2.12.13
7-
- 2.11.12
8-
- 2.13.4
6+
- 2.11.12
7+
- 2.12.13
8+
- 2.13.4
99

1010
env:
1111
- ADOPTOPENJDK=8
1212
- ADOPTOPENJDK=11
1313

14+
before_install:
15+
- git fetch --tags
16+
1417
script:
15-
- sbt "++ ${TRAVIS_SCALA_VERSION}!" test
16-
- git diff --exit-code # check scalariform
18+
- sbt "++${TRAVIS_SCALA_VERSION}" test
19+
- git diff --exit-code # check scalariform
20+
21+
stages:
22+
- name: release
23+
if: (tag IS present) AND NOT fork
24+
25+
jobs:
26+
include:
27+
- stage: release
28+
script: sbt ci-release
29+
30+
notifications:
31+
email:
32+
- seth.tisue@lightbend.com

README.md

Lines changed: 23 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# scala-logging [![Build Status](https://travis-ci.org/lightbend/scala-logging.svg?branch=master)](https://travis-ci.org/lightbend/scala-logging)
1+
# scala-logging [![Build Status](https://travis-ci.com/lightbend/scala-logging.svg?branch=master)](https://travis-ci.com/lightbend/scala-logging)
22

33
Scala Logging is a **convenient** and **fast** logging library wrapping [SLF4J](http://www.slf4j.org).
44

@@ -14,9 +14,9 @@ It's fast, because thanks to Scala macros the *check-enabled-idiom* is applied a
1414
if (logger.isDebugEnabled) logger.debug(s"Some $expensive message!")
1515
```
1616

17-
## Prerequisites ##
17+
## Prerequisites
1818

19-
* Java 6 or higher
19+
* Java 8 or higher
2020
* Scala 2.11, 2.12 or 2.13
2121
* Logging backend compatible with SLF4J
2222

@@ -28,21 +28,20 @@ libraryDependencies += "ch.qos.logback" % "logback-classic" % "1.2.3"
2828

2929
If you are looking for a version compatible with Scala 2.10, check out Scala Logging 2.x.
3030

31-
## Getting Scala Logging ##
31+
## Getting Scala Logging
3232

3333
Scala Logging is published to Sonatype OSS and Maven Central:
3434

3535
- Group id / organization: *com.typesafe.scala-logging*
3636
- Artifact id / name: *scala-logging*
37-
- Latest version is 3.9.2
3837

39-
Usage with SBT, adding a dependency to the latest version of Scala Logging to your sbt build definition file:
38+
sbt users may add this to their `build.sbt`:
4039

4140
```scala
4241
libraryDependencies += "com.typesafe.scala-logging" %% "scala-logging" % "3.9.2"
4342
```
4443

45-
## Using Scala Logging ##
44+
## Using Scala Logging
4645

4746
The `Logger` class from the `com.typesafe.scalalogging` package wraps an underlying SLF4J logger.
4847
In order to create a `Logger`, you pass a name to the `apply` factory method defined in the `Logger` companion object:
@@ -76,7 +75,7 @@ these traits are mixed:
7675
```scala
7776
class MyClass extends LazyLogging {
7877
logger.debug("This is very convenient ;-)")
79-
78+
8079
logger.whenDebugEnabled {
8180
println("This would only execute when the debug level is enabled.")
8281
(1 to 10).foreach(x => println("Scala logging is great!"))
@@ -87,19 +86,19 @@ class MyClass extends LazyLogging {
8786
`LoggerTakingImplicit` provides the same methods as `Logger` class, but with additional implicit parameter `A`.
8887
During creation of the `LoggerTakingImplicit` evidence `CanLog[A]` is required.
8988
It may be useful when contextual parameter (e.g. _Correlation ID_) is being passed around and you would like to include it in the log messages:
90-
89+
9190
```scala
9291
case class CorrelationId(value: String)
9392
implicit case object CanLogCorrelationId extends CanLog[CorrelationId] {
9493
override def logMessage(originalMsg: String, a: CorrelationId): String = s"${a.value} $originalMsg"
9594
}
96-
97-
implicit val correlationId = CorrelationId("ID")
98-
95+
96+
implicit val correlationId = CorrelationId("ID")
97+
9998
val logger = Logger.takingImplicit[CorrelationId]("test")
10099
logger.info("Test") // takes implicit correlationId and logs "ID Test"
101100
```
102-
101+
103102
It's possible to use `MDC` through `CanLog` without any troubles with execution context.
104103

105104
```scala
@@ -109,60 +108,26 @@ implicit case object CanLogCorrelationId extends CanLog[CorrelationId] {
109108
MDC.put("correlationId", a.value)
110109
originalMsg
111110
}
112-
111+
113112
override def afterLog(a: CorrelationId): Unit = {
114113
MDC.remove("correlationId")
115114
}
116115
}
117-
118-
implicit val correlationId = CorrelationId("ID")
119-
116+
117+
implicit val correlationId = CorrelationId("ID")
118+
120119
val logger = Logger.takingImplicit[CorrelationId]("test")
121120

122121
def serviceMethod(implicit correlationId: CorrelationId): Future[Result] = {
123-
dbCall.map { value =>
122+
dbCall.map { value =>
124123
logger.trace(s"Received value $value from db") // takes implicit correlationId
125124
toResult(value)
126125
}
127126
}
128127
```
129128

130-
### What's new?
131-
132-
### 3.9.2
133-
- Use marker inside macros in is*Enabled methods
134-
135-
### 3.9.0
136-
- Functions for on demand code execution added in Logger class
137-
138-
#### 3.8.0
139-
- Added LoggerTakingImplicit, bugfixes.
140-
141-
#### 3.7.2
142-
- Make logger to consume args of type `Any` with slf4 interpolator.
143-
144-
#### 3.7.1
145-
- Remove @volatile from lazy logger, failing with strict compiler settings
146-
147-
##### 3.7.0
148-
- Deconstruct Scala's string interpolation into SLF4J string interpolation.
149-
150-
##### 3.6.0 - flawed release
151-
152-
##### 3.5.0
153-
- More Logger factory methods, bugfixes and upgrades, published for Scala 2.12.0-M5, 2.12.0-RC1, 2.12.0-RC2 and 2.12.0.
154-
155-
##### 3.4.0
156-
- Fixes #38 - Logger.info() cannot be used with primitive types.
157-
158-
##### 3.3.0
159-
- Fixes #42 - Request: Add Logger(class). README changes.
160-
161-
##### 3.2.0
162-
- SLF4J loggers and our Logger now survive serialization. By survive serialization, we mean that the
163-
deserialized logger instances are fully functional.
164-
165129
## String Interpolation
130+
166131
It is idiomatic to use Scala's string interpolation `logger.error(s"log $value")` instead of SLF4J string interpolation `logger.error("log {}", value)`.
167132
However there are some tools (such as [Sentry](https://sentry.io)) that use the log message format as grouping key. Therefore they do not work well with
168133
Scala's string interpolation.
@@ -180,6 +145,7 @@ logger.error("my log message: {} {} {}", arg1, arg2, arg3)
180145
This has no effect on behavior and performace should be comparable (depends on the underlying logging library).
181146

182147
### Limitations
148+
183149
- Works only when string interpolation is directly used inside the logging statement. That is when the log message is static (available at compile time).
184150
- Works only for the `logger.<level>(message)` and `logger.<level>(marker, message)` logging methods. It does not work if you want to log an exception and
185151
use string interpolation too (this is a limitation of the SLF4J API).
@@ -198,10 +164,10 @@ def foo(arg: String)(implicit line: sourcecode.Line, file: sourcecode.File) = {
198164
foo("hello") // the implicit sourcecode.File is filled in automatically
199165
```
200166

201-
## Contribution policy ##
167+
## Maintenance status
202168

203-
Contributions via GitHub pull requests are gladly accepted from their original author. Before we can accept pull requests, you will need to agree to the [Typesafe Contributor License Agreement](http://www.typesafe.com/contribute/cla) online, using your GitHub account.
169+
This library is community-maintained. It is not supported under the Lightbend subscription.
204170

205-
## License ##
171+
## Contribution policy
206172

207-
This code is open source software licensed under the [Apache 2.0 License](http://www.apache.org/licenses/LICENSE-2.0.html).
173+
Contributions via GitHub pull requests are gladly accepted from their original author. Before we can accept pull requests, you will need to agree to the [Lightbend Contributor License Agreement](https://www.lightbend.com/contribute/cla) online, using your GitHub account.

build.sbt

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,37 @@
1-
import com.typesafe.sbt.osgi.SbtOsgi
2-
import sbt._
3-
4-
enablePlugins(SbtOsgi)
1+
// basics
52

6-
organization := "com.typesafe.scala-logging"
73
name := "scala-logging"
8-
licenses := Seq("Apache 2.0 License" -> url("http://www.apache.org/licenses/LICENSE-2.0.html"))
9-
homepage := Some(url("https://github.com/lightbend/scala-logging"))
10-
incOptions := incOptions.value.withLogRecompileOnMacro(false)
11-
scalaVersion := Version.scala
12-
crossScalaVersions := Version.crossScala
13-
scalacOptions ++= List(
4+
scalacOptions ++= Seq(
145
"-unchecked",
156
"-deprecation",
167
"-language:_",
178
"-encoding", "UTF-8",
189
"-Ywarn-unused"
1910
)
11+
incOptions := incOptions.value.withLogRecompileOnMacro(false)
12+
libraryDependencies ++= Dependencies.scalaLogging(scalaVersion.value)
13+
initialCommands := """|import com.typesafe.scalalogging._
14+
|import org.slf4j.{ Logger => Underlying, _ }""".stripMargin
2015

21-
osgiSettings
16+
// OSGi
2217

18+
import com.typesafe.sbt.osgi.SbtOsgi
19+
enablePlugins(SbtOsgi)
20+
osgiSettings
2321
OsgiKeys.bundleSymbolicName := "com.typesafe.scala-logging"
2422
OsgiKeys.privatePackage := Seq()
2523
OsgiKeys.exportPackage := Seq("com.typesafe.scalalogging*")
2624

27-
releaseVersionBump := sbtrelease.Version.Bump.Minor
28-
releaseCrossBuild := true
29-
releasePublishArtifactsAction := PgpKeys.publishSigned.value
30-
31-
libraryDependencies ++= Dependencies.scalaLogging(scalaVersion.value)
32-
33-
initialCommands := """|import com.typesafe.scalalogging._
34-
|import org.slf4j.{ Logger => Underlying, _ }""".stripMargin
25+
// publishing
3526

36-
publishTo := {
37-
if (isSnapshot.value)
38-
Some(Opts.resolver.sonatypeSnapshots)
39-
else
40-
Some(Opts.resolver.sonatypeStaging)
41-
}
42-
publishArtifact in Test := false
27+
organization := "com.typesafe.scala-logging"
28+
licenses := Seq("Apache 2.0 License" -> url("http://www.apache.org/licenses/LICENSE-2.0.html"))
29+
homepage := Some(url("https://github.com/lightbend/scala-logging"))
30+
Test / publishArtifact := false
4331
pomIncludeRepository := (_ => false)
44-
4532
scmInfo := Some(
4633
ScmInfo(url("https://github.com/lightbend/scala-logging"), "scm:git:git@github.com:lightbend/scala-logging.git")
4734
)
48-
4935
developers := List(
5036
Developer(
5137
id = "hseeberger",
@@ -59,4 +45,4 @@ developers := List(
5945
email = "",
6046
url = url("http://twitter.com/analytically")
6147
)
62-
)
48+
)

project/Dependencies.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import sbt._
33
object Version {
44
val logback = "1.2.3"
55
val mockito = "1.16.23"
6-
val scala = "2.13.4"
7-
val crossScala = List(scala, "2.11.12", "2.12.13")
86
val scalaTest = "3.2.3"
97
val slf4j = "1.7.30"
108
}

project/plugins.sbt

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
1-
resolvers += Resolver.typesafeRepo("releases")
2-
3-
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.1.1")
4-
51
addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.8.3")
6-
7-
addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.13")
8-
92
addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.9.6")
10-
113
addSbtPlugin("com.scalapenos" % "sbt-prompt" % "1.0.2")
4+
addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.5")
5+
addSbtPlugin("com.dwijnand" % "sbt-travisci" % "1.2.0")

version.sbt

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)