Skip to content

Commit 7eb5ffd

Browse files
author
Mathias Bogaert
committed
Extra tests. README changes.
1 parent 0e4ad46 commit 7eb5ffd

File tree

2 files changed

+43
-16
lines changed

2 files changed

+43
-16
lines changed

README.md

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,31 +43,31 @@ Usage with SBT, adding a dependency to the latest version of Scala Logging to yo
4343
libraryDependencies += "com.typesafe.scala-logging" %% "scala-logging" % "3.5.0"
4444
```
4545

46-
### What's new?
47-
48-
#### 3.5.0
49-
50-
- Bugfixes and upgrades, published for Scala 2.12.0-M5 and 2.12.0-RC1.
51-
52-
#### 3.4.0
46+
## Using Scala Logging ##
5347

54-
- Fixes #38 - Logger.info() cannot be used with primitive types.
48+
The `Logger` class from the `com.typesafe.scalalogging` package wraps an underlying SLF4J logger.
49+
In order to create a `Logger`, you pass a name to the `apply` factory method defined in the `Logger` companion object:
5550

56-
#### 3.3.0
51+
```scala
52+
val logger = Logger("name")
53+
```
5754

58-
- Fixes #42 - Request: Add Logger(class). README changes.
55+
Or, you pass in a SLF4J logger instance:
5956

60-
#### 3.2.0
57+
```scala
58+
val logger = Logger(LoggerFactory.getLogger("name"))
59+
```
6160

62-
- SLF4J loggers and our Logger now survive serialization. By survive serialization, we mean that the
63-
deserialized logger instances are fully functional.
61+
Or, you pass in a class:
6462

65-
## Using Scala Logging ##
63+
```scala
64+
val logger = Logger(classOf[MyClass])
65+
```
6666

67-
The `Logger` class from the `com.typesafe.scalalogging` package wraps an underlying SLF4J logger. Hence, in order to create a `Logger`, you have to pass a SLF4J logger to the `apply` factory method defined in the `Logger` companion object:
67+
Or, using the runtime class wrapped by the implicit class tag parameter:
6868

6969
```scala
70-
val logger = Logger(LoggerFactory.getLogger("name"))
70+
val logger = Logger[MyClass]
7171
```
7272

7373
The `LazyLogging` and `StrictLogging` traits from the `com.typesafe.scalalogging` package define the `logger` member as
@@ -80,6 +80,21 @@ class MyClass extends LazyLogging {
8080
}
8181
```
8282

83+
### What's new?
84+
85+
##### 3.5.0
86+
- More Logger factory methods, bugfixes and upgrades, published for Scala 2.12.0-M5 and 2.12.0-RC1.
87+
88+
##### 3.4.0
89+
- Fixes #38 - Logger.info() cannot be used with primitive types.
90+
91+
##### 3.3.0
92+
- Fixes #42 - Request: Add Logger(class). README changes.
93+
94+
##### 3.2.0
95+
- SLF4J loggers and our Logger now survive serialization. By survive serialization, we mean that the
96+
deserialized logger instances are fully functional.
97+
8398
## Line numbers in log message?
8499

85100
Using the [sourcecode](https://github.com/lihaoyi/sourcecode#logging) library, it's possible to add line number

src/test/scala/com/typesafe/scalalogging/LoggerSpec.scala

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,18 @@ class LoggerSpec extends WordSpec with Matchers with MockitoSugar {
360360

361361
logger.trace("Back from deserialization")
362362
}
363+
364+
"constructed by explicit class and be usable after deserialization" in {
365+
val logger = deserialize(serialize(Logger(classOf[LoggerSpec])))
366+
367+
logger.trace("Back from deserialization")
368+
}
369+
370+
"constructed by implicit class tag and be usable after deserialization" in {
371+
val logger = deserialize(serialize(Logger[LoggerSpec]))
372+
373+
logger.trace("Back from deserialization")
374+
}
363375
}
364376

365377
def fixture(p: Underlying => Boolean, isEnabled: Boolean) =

0 commit comments

Comments
 (0)