Skip to content

Commit

Permalink
Revert "Removing Logger from sample"
Browse files Browse the repository at this point in the history
This reverts commit 1c97ee6.
  • Loading branch information
KevinSchildhorn committed Nov 15, 2024
1 parent 1c97ee6 commit 6ea15ab
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ import shared

struct ContentView: View {

let common: CommonMobile
let common: SampleMobile

init() {
let filePath = NSHomeDirectory() + "/Documents/"
let fileName = "KermitSampleLogs"
ContentView.createLoggingFile(withName: fileName, atPath: filePath)

self.common = CommonMobile()
self.common = SampleMobile(filePathString: filePath, logFileName: fileName)
}

private static func createLoggingFile(withName name:String, atPath filePath: String){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import android.view.View
import androidx.fragment.app.Fragment
import co.touchlab.KermitSample.databinding.FragmentFirstBinding
import co.touchlab.kermit.Logger
import co.touchlab.kermitsample.SampleCommon
import co.touchlab.kermitsample.SampleMobile

/**
* A simple [Fragment] subclass as the default destination in the navigation.
Expand All @@ -25,7 +25,7 @@ class FirstFragment : Fragment(R.layout.fragment_first) {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
Logger.withTag("FirstFragment").v("First fragment loaded")
val sample = SampleCommon()
val sample = SampleMobile(context?.filesDir?.path ?: "")
val binding = FragmentFirstBinding.bind(view)
binding.btnClickCount.setOnClickListener { sample.onClickI() }
binding.btnException.setOnClickListener { sample.logException() }
Expand Down
21 changes: 18 additions & 3 deletions samples/sample/shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,24 @@ kotlin {

implementation("co.touchlab:kermit-test:${KERMIT_VERSION}")
}
iosMain.dependencies {
// Only if you want to talk to Kermit from Swift
api("co.touchlab:kermit-simple:${KERMIT_VERSION}")
val mobileMain by creating {
dependsOn(commonMain.get())
dependencies {
implementation("co.touchlab:kermit-io:${KERMIT_VERSION}")
}
}
androidMain {
dependsOn(mobileMain)
}
iosMain {
dependsOn(mobileMain)
iosX64Main.get().dependsOn(this)
iosArm64Main.get().dependsOn(this)
iosSimulatorArm64Main.get().dependsOn(this)
dependencies {
// Only if you want to talk to Kermit from Swift
api("co.touchlab:kermit-simple:${KERMIT_VERSION}")
}
}
}
cocoapods {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright (c) 2024 Touchlab
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/

package co.touchlab.kermitsample

import co.touchlab.kermit.Logger
import co.touchlab.kermit.io.RollingFileLogWriter
import co.touchlab.kermit.io.RollingFileLogWriterConfig
import kotlinx.io.files.Path

class SampleMobile(filePathString: String, logFileName: String = "KermitSampleLogs") : SampleCommon() {
init {
Logger.addLogWriter(
RollingFileLogWriter(
config = RollingFileLogWriterConfig(
logFileName = logFileName,
logFilePath = Path(filePathString),
)
)
)
}
}

0 comments on commit 6ea15ab

Please sign in to comment.