Skip to content

Commit 55b229e

Browse files
committed
Add Project Structure section to README
1 parent 4cf16df commit 55b229e

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

README.md

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Logging library for Kotlin JVM, that thinly wraps SLF4J and Logback to provide a
1212
- [Usage](#usage)
1313
- [Adding to your project](#adding-to-your-project)
1414
- [Implementation](#implementation)
15+
- [Project Structure](#project-structure)
1516
- [Credits](#credits)
1617

1718
## Usage
@@ -192,8 +193,43 @@ For more configuration options, see:
192193
it's actually logged.
193194
- `Logger`'s methods are also `inline`, so we avoid the cost of allocating a function object for the
194195
lambda argument.
195-
- Elsewhere in the library, we use inline value classes when wrapping Logback APIs, to get as close
196-
as possible to a zero-cost abstraction.
196+
- Elsewhere in the library, we use inline value classes when wrapping SLF4J/Logback APIs, to get as
197+
close as possible to a zero-cost abstraction.
198+
199+
## Project Structure
200+
201+
`devlog-kotlin` is structured as a Kotlin Multiplatform project, although currently the only
202+
supported platform is JVM. The library has been designed to keep as much code as possible in the
203+
common (platform-neutral) module, to make it easier to add support for other platforms in the
204+
future.
205+
206+
Directory structure:
207+
208+
- `src/commonMain` contains common, platform-neutral implementations
209+
- This module implements the surface API of `devlog-kotlin`, namely `Logger`, `LogBuilder` and
210+
`LogField`
211+
- It declares `expect` classes and functions for the underlying APIs that must be implemented by
212+
each platform, namely `PlatformLogger`, `LogEvent` and `LoggingContext`
213+
- `src/jvmMain` implements platform-specific APIs for the JVM
214+
- It uses SLF4J, the de-facto standard JVM logging library, with extra optimizations for Logback
215+
- It implements:
216+
- `PlatformLogger` as a typealias for `org.slf4j.Logger`
217+
- `LoggingContext` using SLF4J's `MDC` (Mapped Diagnostic Context)
218+
- `LogEvent` with an SLF4J `DefaultLoggingEvent`, or a special-case optimization using
219+
Logback's `LoggingEvent` if Logback is on the classpath
220+
- `src/commonTest` contains the library's tests that apply to all platforms
221+
- In order to keep as many tests as possible in the common module, we write most of our tests
222+
here, and delegate to platform-specific `expect` utilities where needed. This allows us to
223+
define a common test suite for all platforms, just switching out the parts where we need
224+
platform-specific implementations
225+
- `src/jvmTest` contains JVM-specific tests, and implements the test utilities expected by
226+
`commonTest`
227+
for the JVM
228+
- `integration-tests` contains Gradle subprojects that load various SLF4J logger backends (Logback,
229+
Log4j and `java.util.logging`, a.k.a. `jul`), and verify that they all work as expected with
230+
`devlog-kotlin`
231+
- Since we do some special-case optimizations if Logback is loaded, this lets us test that these
232+
Logback-specific optimizations do not interfere with other logger backends
197233

198234
## Credits
199235

0 commit comments

Comments
 (0)