-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
100 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
app/src/main/java/abbasi/android/filelogger/sample/MainActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,47 @@ | ||
package abbasi.android.filelogger.sample | ||
|
||
import abbasi.android.filelogger.FileLogger | ||
import abbasi.android.filelogger.config.Config | ||
import android.os.Bundle | ||
import android.widget.Button | ||
import android.widget.ImageView | ||
import androidx.appcompat.app.AppCompatActivity | ||
|
||
class MainActivity : AppCompatActivity() { | ||
override fun onCreate(savedInstanceState: Bundle?) { | ||
super.onCreate(savedInstanceState) | ||
setContentView(R.layout.activity_main) | ||
|
||
findViewById<Button>(R.id.init).setOnClickListener { | ||
applicationContext.getExternalFilesDir(null)?.let { | ||
val config = Config.Builder(it.path) | ||
.setDefaultTag("TAG") | ||
.setLogcatEnable(true) | ||
.build() | ||
|
||
FileLogger.init(config) | ||
} | ||
} | ||
|
||
findViewById<Button>(R.id.writeNormalLog).setOnClickListener { | ||
FileLogger.i("Custom", "This is normal Log with custom TAG") | ||
FileLogger.i(msg = "This is normal Info Log") | ||
FileLogger.d(msg = "This is normal Debug Log") | ||
FileLogger.w(msg = "This is normal Warning Log") | ||
FileLogger.e(msg = "This is normal Error Log") | ||
} | ||
|
||
findViewById<Button>(R.id.writeExceptionLog).setOnClickListener { | ||
try { | ||
findViewById<ImageView>(R.id.writeNormalLog).imageAlpha // just for happening exception | ||
} catch (e: Exception) { | ||
FileLogger.e(msg = "This is normal Log with custom TAG", throwable = e) | ||
} | ||
} | ||
|
||
findViewById<Button>(R.id.deleteLogs).setOnClickListener { | ||
FileLogger.deleteFiles() | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters