https://github.com/scala-js/scala-js-logging
Tiny logging API for use by the Scala.js linker and JS envs.
https://github.com/scala-js/scala-js-logging
Last synced: 7 months ago
JSON representation
Tiny logging API for use by the Scala.js linker and JS envs.
- Host: GitHub
- URL: https://github.com/scala-js/scala-js-logging
- Owner: scala-js
- License: apache-2.0
- Created: 2020-06-12T07:34:43.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2023-07-30T09:36:35.000Z (over 2 years ago)
- Last Synced: 2024-03-27T01:12:52.001Z (over 1 year ago)
- Language: Scala
- Size: 15.6 KB
- Stars: 1
- Watchers: 4
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# scalajs-logging
`scalajs-logging` is a tiny logging API for use by the Scala.js linker and JS environments.
It is not a general-purpose logging library, and you should probably not use it other than to interface with the Scala.js linker API and the `JSEnv` API.
## Setup
Normally you should receive the dependency on scalajs-logging through scalajs-linker or scalajs-js-envs.
If you really want to use it somewhere else, add the following line to your settings:
```scala
libraryDependencies += "org.scala-js" %% "scalajs-logging" % "1.1.1"
```
## Usage
```scala
import org.scalajs.logging._
// get a logger that discards all logs
val logger = NullLogger // discard all logs
// or get a logger that prints all logs of severity Warn and above to the console
val logger = new ScalaConsoleLogger(Level.Error)
// or create your own Logger:
val logger = new Logger {
def log(level: Level, message: => String): Unit = ???
def trace(t: => Throwable): Unit = ???
}
```
then give your logger instance to an API.
Available severity levels are `Debug`, `Info`, `Warn` and `Error`.
For more details, consult [the Scaladoc of scalajs-logging](https://javadoc.io/doc/org.scala-js/scalajs-logging_2.13/latest/org/scalajs/logging/index.html).