Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Napier 2.0.0 🎉 #82

Merged
merged 52 commits into from
Aug 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
e0d569e
Define a separate LogLevel from nested in the Napier class.
AAkira Sep 9, 2020
5a7e89f
Bump up the version code and name.
AAkira Sep 9, 2020
8875164
Merge pull request #53 from AAkira/feature/separate-napier-loglevel
AAkira Sep 9, 2020
42a1ef9
baseArray replaced with atomic - fix logging from another thread on i…
PhilipDukhov Mar 29, 2021
5690b41
Merge remote-tracking branch 'original/dev/2.0.0'
PhilipDukhov Aug 11, 2021
17a3d4b
@ThreadLocal removed to fix iOS work from coroutines
PhilipDukhov Aug 11, 2021
ec4906d
Merge pull request #61 from PhilipDukhov/master
AAkira Aug 11, 2021
32873b5
Fix package name.
AAkira Aug 11, 2021
6b7547b
Merge pull request #70 from AAkira/fix-package-name
AAkira Aug 11, 2021
8dfa73e
Update kotlin 1.5.21 and coroutines 1.5.1-native-mt.
AAkira Aug 11, 2021
023b974
Fix test.
AAkira Aug 11, 2021
c1a6e69
Merge pull request #71 from AAkira/update-kotlin
AAkira Aug 11, 2021
30f3e48
Modify coroutines proxy using background thread.
AAkira Aug 11, 2021
a932b6e
Update README.
AAkira Aug 11, 2021
1587c27
Merge pull request #72 from AAkira/native-coroutines
AAkira Aug 11, 2021
c8dd489
Bump up the version code and name.
AAkira Aug 11, 2021
51252e1
Merge branch 'dev/2.0.0' of github.com:AAkira/Napier into dev/2.0.0
AAkira Aug 11, 2021
04237c1
Add macOS project.
AAkira Aug 15, 2021
813f964
Replace cocoa pods and rename nativeMain.
AAkira Aug 15, 2021
feb546c
Replace pod in the iOS project.
AAkira Aug 15, 2021
4bcb4e2
Add macOS in Napier.
AAkira Aug 15, 2021
7ec2261
Merge pull request #73 from AAkira/support-macos
AAkira Aug 15, 2021
3832682
Refactoring macOS.
AAkira Aug 16, 2021
71c1d54
Add watchOS project.
AAkira Aug 16, 2021
218e132
Add watchOS.
AAkira Aug 16, 2021
bdd5140
Native test on pull request.
AAkira Aug 16, 2021
7cb8e9b
Merge pull request #74 from AAkira/watchOS
AAkira Aug 16, 2021
9aea0e3
Add tvOS.
AAkira Aug 16, 2021
6bbfaf8
Refactoring gradle and directory name.
AAkira Aug 16, 2021
45f719c
Bump up the version code and name.
AAkira Aug 16, 2021
4497796
Merge pull request #75 from AAkira/tvOS
AAkira Aug 16, 2021
310dc3c
Merge branch 'dev/2.0.0' into refactoring-apple
AAkira Aug 16, 2021
3580d91
Refactoring tvos.
AAkira Aug 16, 2021
2913d6d
Merge pull request #76 from AAkira/refactoring-apple
AAkira Aug 16, 2021
e2efb73
Modify debug antilog in kotlin/native on darwin.
AAkira Aug 18, 2021
71747df
Add [async] suffix if it's called from suspend functions.
AAkira Aug 18, 2021
5b25d6b
Update readme.
AAkira Aug 18, 2021
8c51174
Restore debugAntilog initializer in ios.
AAkira Aug 18, 2021
7513836
Merge pull request #77 from AAkira/modify-ios-log
AAkira Aug 18, 2021
c0f99e4
Merge branch 'dev/1.5.0' into merge-1.5.0
AAkira Aug 18, 2021
33b383e
Merge pull request #78 from AAkira/merge-1.5.0
AAkira Aug 18, 2021
7878946
Refactoring gradle.
AAkira Aug 19, 2021
4c5da36
Rename darwin.
AAkira Aug 19, 2021
5a4fad8
Fix idea active.
AAkira Aug 19, 2021
92ba769
Merge pull request #79 from AAkira/refactoring-gradle
AAkira Aug 19, 2021
0a18a7c
Support IR compiler(experimental).
AAkira Aug 19, 2021
43b615f
Merge pull request #80 from AAkira/support-ir-compiler
AAkira Aug 19, 2021
775862a
DebugAntilog made common class with expect/actual
PhilipDukhov Aug 20, 2021
0010460
imports updated to fix build
PhilipDukhov Aug 20, 2021
32b5f69
Merge pull request #81 from PhilipDukhov/dev/2.0.0
AAkira Aug 22, 2021
221563a
Format files.
AAkira Aug 22, 2021
9f77226
Dev 2.0.0
AAkira Aug 22, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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