Skip to content

Commit 214f09e

Browse files
jameswardzoobestik
authored andcommitted
add gsoc-2023-kflogger
1 parent 9fc97ed commit 214f09e

File tree

1 file changed

+44
-0
lines changed
  • src/pages/news/gsoc-2023-kflogger

1 file changed

+44
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
title: "Google Summer of Code 2023 - KFlogger (Kotlin Multiplatform Flogger)"
3+
date: 2024-01-08 00:02
4+
---
5+
6+
The Kotlin Foundation sponsored 4 projects for the Google Summer of Code 2023 and we are excited to announce the completion of the KFlogger project, an experimental Kotlin Multiplatform version of [Google's Flogger logging library](https://github.com/google/flogger)! The contributor to this project was [Giancarlo Buenaflor](https://www.linkedin.com/in/giancarlo-buenaflor/), a computer science undergraduate and the mentor was Mark Mann, a Kotlin Multiplatform engineer at Google.
7+
8+
## Background
9+
10+
Flogger, Google's default logging framework for JVM projects, opens up new opportunities for efficient cross-platform logging. The KFlogger project aims to enable the integration of Flogger into iOS and JVM, benefitting from the multiplatform capabilities of Kotlin.
11+
12+
KFlogger incorporates the existing JVM Flogger codebase as a Java module, preserving its core functionality. The JVM implementation remains largely untouched and is directly actualized through the actual typealias mechanism. On the iOS side, KFlogger introduces a default logging backend based on OSLog.
13+
14+
Here is a demo of this working on Android and iOS:
15+
<iframe width="560" height="315" src="https://www.youtube.com/embed/hkyL-Lhkla8?si=sC-VNE7s8YTZ673C" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>
16+
17+
## Getting Started
18+
19+
To use KFlogger, add the following dependency to your `commonMain` sourceSet:
20+
```kotlin
21+
// Find the latest version on https://mvnrepository.com/artifact/com.giancarlobuenaflor/kflogger
22+
implementation("com.buenaflor:kflogger:0.0.3")
23+
```
24+
25+
This will allow you to start simple logging.
26+
Add the `KFluentLogger` instance to your class and then you can start logging through your common code:
27+
```kotlin
28+
import com.giancarlobuenaflor.kflogger.KFluentLogger
29+
30+
class LoggingClass {
31+
private val logger = KFluentLogger.forEnclosingClass()
32+
33+
fun log() {
34+
logger.atWarning().log("string: %s“, “example”)
35+
logger.atWarning().log("integer: %d”, 1)
36+
logger.atWarning().log(“float: %f, 1.0f)
37+
logger.atWarning().log(“%d%% %s, 100, “chance”)
38+
}
39+
}
40+
```
41+
42+
The source is in a [GitHub repository](https://github.com/buenaflor/KFlogger) and we'd love your feedback and contributions!
43+
44+
Thank you Giancarlo and Mark for helping make Kotlin Multiplatform even better!

0 commit comments

Comments
 (0)