Skip to content

Commit

Permalink
Merge pull request #82 from AAkira/dev/2.0.0
Browse files Browse the repository at this point in the history
Napier 2.0.0 🎉
  • Loading branch information
AAkira authored Aug 22, 2021
2 parents a06a4c4 + 9f77226 commit 5ac3ab6
Show file tree
Hide file tree
Showing 171 changed files with 6,818 additions and 311 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ jobs:
run: ./gradlew :napier:iosX64Test --stacktrace
- name: Run jvm tests
run: ./gradlew :napier:jvmTest --stacktrace
- name: Run macos tests
run: ./gradlew :napier:macosX64Test --stacktrace
- name: Run watchos tests
run: ./gradlew :napier:watchosX64Test --stacktrace
- name: Run tvos tests
run: ./gradlew :napier:tvosX64Test --stacktrace

- name: Bundle the build report
if: failure()
Expand Down
50 changes: 44 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,36 @@
![logo][logo]

Napier is a logger library for Kotlin Multiplatform.
It supports for the android, ios, jvm, js.
It supports for the Android, Darwin(iOS, macOS, watchOS, tvOS), JVM, JavaScript.
Logs written in common module are displayed on logger viewer of each platform.

* Android
## Preview

### Android

format: `[Class name]$[Method name]: [Your log]`

uses the `android.util.Log`(Logcat)

![preview-android][preview-android]

* ios
### Darwin(iOS, macOS, watchOS, tvOS)

format: `[Date time][Symbol][Log level][Class name].[Method name] - [Your log]`

Added `[async]` label at the end, if it is called from suspend functions.

uses the `print`

![preview-ios][preview-ios]

* js
### JavaScript

uses the `console.log`

![preview-js][preview-js]

* jvm
### JVM

uses the `java.util.logging.Logger`

Expand Down Expand Up @@ -73,7 +77,7 @@ You can download this library from MavenCentral or jCenter repository.

* Maven central

You can download this from `1.4.1`.
You can download this from `2.0.0`.
Package name is `io.github.aakira`

```groovy
Expand Down Expand Up @@ -175,6 +179,10 @@ fun debugBuild() {
}
```

|argument|type|description|
|-|-|
|coroutinesSuffix|Boolean|Added `[async]` label at the end, if it is called from suspend functions|

* Call initialize code from ios project.

```swift
Expand All @@ -198,6 +206,36 @@ Napier.takeLogarithm()
| ERROR | Napier.e() |
| ASSERT | Napier.wtf()|

## Run background thread

You can use this library on the background thread on iOS using [Kotlin.coroutines](https://github.com/Kotlin/kotlinx.coroutines) as native-mt.

* Define scope

```kotlin
internal val mainScope = SharedScope(Dispatchers.Main)

internal val backgroundScope = SharedScope(Dispatchers.Default)

internal class SharedScope(private val context: CoroutineContext) : CoroutineScope {
private val job = Job()
private val exceptionHandler = CoroutineExceptionHandler { _, throwable ->
println("[Coroutine Exception] $throwable")
}

override val coroutineContext: CoroutineContext
get() = context + job + exceptionHandler
}
```

* Usage

```kotlin
backgroundScope.launch {
suspendFunction()
}
```

## Advancement

You can inject custom `Antilog`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ package io.github.aakira.napier.sample
import android.content.Context
import com.google.firebase.crashlytics.FirebaseCrashlytics
import io.github.aakira.napier.Antilog
import io.github.aakira.napier.Napier
import io.github.aakira.napier.LogLevel

class CrashlyticsAntilog(private val context: Context) : Antilog() {

override fun performLog(
priority: Napier.Level,
priority: LogLevel,
tag: String?,
throwable: Throwable?,
message: String?
) {
// send only error log
if (priority < Napier.Level.ERROR) return
if (priority < LogLevel.ERROR) return

throwable?.let {
when (it) {
Expand Down
Binary file added arts/screen-shot-ios.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/dependencies/Dep.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package dependencies

object Dep {

private const val kotlin = "1.5.0"
private const val kotlin = "1.5.21"

object GradlePlugin {
const val kotlin = "org.jetbrains.kotlin:kotlin-gradle-plugin:${Dep.kotlin}"
Expand All @@ -20,7 +20,7 @@ object Dep {
}

object Coroutines {
private const val version = "1.5.0-RC"
private const val version = "1.5.1-native-mt"

const val core = "org.jetbrains.kotlinx:kotlinx-coroutines-core:$version"
}
Expand Down
5 changes: 2 additions & 3 deletions buildSrc/src/main/kotlin/dependencies/Versions.kt
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package dependencies

object Versions {
const val versionCode = 15
const val versionName = "1.5.0"
const val versionCode = 18
const val versionName = "2.0.0"

// android
const val androidVersionCode = 1
const val androidVersionName = "1.0.0"
const val compileSdkVersion = 30
const val buildToolsVersion = "29.0.3"
const val minSdkVersion = 16
const val instantAppMinSdkVersion = 23
const val targetSdkVersion = 28
}
62 changes: 22 additions & 40 deletions ios/Napier.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,23 @@
archiveVersion = 1;
classes = {
};
objectVersion = 51;
objectVersion = 50;
objects = {

/* Begin PBXBuildFile section */
3B3988B1264ADA500055407D /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3988B0264ADA500055407D /* GoogleService-Info.plist */; };
3B3988B3264AE4F50055407D /* Common.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B3988B2264AE4F40055407D /* Common.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
74AC91897E121EEADF59069F /* Pods_Napier.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 236CB35798B6FF37795E2A6A /* Pods_Napier.framework */; };
625D2A51333F356CAFD0D528 /* Pods_Napier.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 236CB35798B6FF37795E2A6A /* Pods_Napier.framework */; };
7CFB659A22013CF600BD05FC /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7CFB659922013CF600BD05FC /* AppDelegate.swift */; };
7CFB659C22013CF600BD05FC /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7CFB659B22013CF600BD05FC /* ViewController.swift */; };
7CFB659F22013CF600BD05FC /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7CFB659D22013CF600BD05FC /* Main.storyboard */; };
7CFB65A122013CF900BD05FC /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 7CFB65A022013CF900BD05FC /* Assets.xcassets */; };
7CFB65A422013CF900BD05FC /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7CFB65A222013CF900BD05FC /* LaunchScreen.storyboard */; };
/* End PBXBuildFile section */

/* Begin PBXCopyFilesBuildPhase section */
7CFB65CA22013D5200BD05FC /* Embed Frameworks */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 10;
files = (
3B3988B3264AE4F50055407D /* Common.framework in Embed Frameworks */,
);
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
14D73DDEDA418BBBD3C23B9B /* Pods-Napier.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Napier.release.xcconfig"; path = "Target Support Files/Pods-Napier/Pods-Napier.release.xcconfig"; sourceTree = "<group>"; };
236CB35798B6FF37795E2A6A /* Pods_Napier.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Napier.framework; sourceTree = BUILT_PRODUCTS_DIR; };
3B3988B0264ADA500055407D /* GoogleService-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "GoogleService-Info.plist"; sourceTree = "<group>"; };
3B3988B2264AE4F40055407D /* Common.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Common.framework; path = "../mpp-sample/build/xcode-frameworks/Common.framework"; sourceTree = "<group>"; };
6F88F8388EB37A3B9C7069DF /* Pods-Napier.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Napier.debug.xcconfig"; path = "Target Support Files/Pods-Napier/Pods-Napier.debug.xcconfig"; sourceTree = "<group>"; };
7CFB659622013CF500BD05FC /* Napier.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Napier.app; sourceTree = BUILT_PRODUCTS_DIR; };
7CFB659922013CF600BD05FC /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
Expand All @@ -51,7 +35,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
74AC91897E121EEADF59069F /* Pods_Napier.framework in Frameworks */,
625D2A51333F356CAFD0D528 /* Pods_Napier.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -78,7 +62,6 @@
7CFB658D22013CF500BD05FC = {
isa = PBXGroup;
children = (
3B3988B2264AE4F40055407D /* Common.framework */,
7CFB659822013CF500BD05FC /* Napier */,
7CFB659722013CF500BD05FC /* Products */,
10E92F91406E001698737DB9 /* Pods */,
Expand Down Expand Up @@ -120,9 +103,8 @@
7CFB659222013CF500BD05FC /* Sources */,
7CFB659322013CF500BD05FC /* Frameworks */,
7CFB659422013CF500BD05FC /* Resources */,
7CFB65CA22013D5200BD05FC /* Embed Frameworks */,
7C44D7BC221548AD002EEF8F /* Crashlytics */,
9440D0487B4C902A85F73734 /* [CP] Embed Pods Frameworks */,
095E9721F85EF8B8A60C2E7E /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
Expand Down Expand Up @@ -181,6 +163,23 @@
/* End PBXResourcesBuildPhase section */

/* Begin PBXShellScriptBuildPhase section */
095E9721F85EF8B8A60C2E7E /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Napier/Pods-Napier-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Napier/Pods-Napier-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Napier/Pods-Napier-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
55963836C9E5F6516FE3DBE8 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -238,24 +237,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "cd $SRCROOT/..\n./gradlew :mpp-sample:packForXcode -PXCODE_CONFIGURATION=${CONFIGURATION}\n";
};
9440D0487B4C902A85F73734 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Napier/Pods-Napier-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Napier/Pods-Napier-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Napier/Pods-Napier-frameworks.sh\"\n";
showEnvVarsInLog = 0;
shellScript = "cd $SRCROOT/..\n./gradlew :mpp-sample:compileKotlinIosX64\n";
};
/* End PBXShellScriptBuildPhase section */

Expand Down
2 changes: 1 addition & 1 deletion ios/Napier/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import UIKit
import Firebase
import Common
import mpp_sample

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
Expand Down
2 changes: 1 addition & 1 deletion ios/Napier/ViewController.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import UIKit
import Common
import mpp_sample

final class ViewController: UIViewController {
override func viewDidLoad() {
Expand Down
1 change: 1 addition & 0 deletions ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ target 'Napier' do
use_frameworks!

pod 'Firebase/Crashlytics'
pod 'mpp_sample', :path => '../mpp-sample'
end
11 changes: 9 additions & 2 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ PODS:
- GoogleUtilities/Environment
- GoogleUtilities/UserDefaults (7.3.1):
- GoogleUtilities/Logger
- mpp_sample (1.0.0)
- nanopb (2.30908.0):
- nanopb/decode (= 2.30908.0)
- nanopb/encode (= 2.30908.0)
Expand All @@ -43,6 +44,7 @@ PODS:

DEPENDENCIES:
- Firebase/Crashlytics
- mpp_sample (from `../mpp-sample`)

SPEC REPOS:
trunk:
Expand All @@ -56,6 +58,10 @@ SPEC REPOS:
- nanopb
- PromisesObjC

EXTERNAL SOURCES:
mpp_sample:
:path: "../mpp-sample"

SPEC CHECKSUMS:
Firebase: fffddd0bab8677d07376538365faa93ff3889b39
FirebaseCore: ec566d917b2195fc2610aeb148dae99f57a788f9
Expand All @@ -64,9 +70,10 @@ SPEC CHECKSUMS:
FirebaseInstallations: bf2ec8dbf36ff4c91af6b9a003d15855757680c1
GoogleDataTransport: cd9db2180fcecd8da1b561aea31e3e56cf834aa7
GoogleUtilities: e1d9ed4e544fc32a93e00e721400cbc3f377200d
mpp_sample: 07fdbc60934b60a9bbfb833df6298899fe345026
nanopb: a0ba3315591a9ae0a16a309ee504766e90db0c96
PromisesObjC: 3113f7f76903778cf4a0586bd1ab89329a0b7b97

PODFILE CHECKSUM: 2822d85bb609b66f886d949716d5f863dc426322
PODFILE CHECKSUM: 441ae05d1695723ea9a68d3223ef8b6460bbec0f

COCOAPODS: 1.10.0
COCOAPODS: 1.10.1
10 changes: 5 additions & 5 deletions js/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ dependencies {
}

kotlin {
target {
js {
browser {
// execute :js:browserRun to launch dev server
runTask {
devServer = KotlinWebpackConfig.DevServer(
true, false, true, true, false,
8080,
null,
listOf("${projectDir}/src/main/resources".toString())
open = true,
port = 8080,
proxy = null,
contentBase = mutableListOf("${projectDir}/src/main/resources")
)
outputFileName = "main.js"
}
Expand Down
10 changes: 10 additions & 0 deletions macOS/Podfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'

target 'macOS (macOS)' do
# Comment the next line if you don't want to use dynamic frameworks
use_frameworks!

# Pods for macOS (macOS)
pod 'mpp_sample', :path => '../mpp-sample'
end
16 changes: 16 additions & 0 deletions macOS/Podfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
PODS:
- mpp_sample (1.0.0)

DEPENDENCIES:
- mpp_sample (from `../mpp-sample`)

EXTERNAL SOURCES:
mpp_sample:
:path: "../mpp-sample"

SPEC CHECKSUMS:
mpp_sample: 07fdbc60934b60a9bbfb833df6298899fe345026

PODFILE CHECKSUM: bc4ce6f8ddff432aa3bca804121efe1d46ba7a07

COCOAPODS: 1.10.1
Loading

0 comments on commit 5ac3ab6

Please sign in to comment.