@@ -10,16 +10,19 @@ The FileLogger is a library for saving logs on Files with custom-formatter on ba
10
10
- Working on I/O thread
11
11
- Using java FastDateTime
12
12
- Support INFO, ERROR, DEBUG, WARNING logging level
13
+ - Compress and send logs(Email and messengers)
13
14
14
15
## TODO
15
16
1 . Add C++ NDK support
16
- 2 . Mail logs
17
+ 2 . Mail logs ✅
17
18
3 . Upload on http server
18
19
4 . Encrypt important logs
20
+ 5 . Retrofit/OkHttp Interceptor
21
+ 6 . Startup log
19
22
20
23
## Usage
21
24
22
- Init:
25
+ ** Init:**
23
26
``` kotlin
24
27
val config = Config .Builder (it.path)
25
28
.setDefaultTag(" TAG" )
@@ -29,7 +32,7 @@ val config = Config.Builder(it.path)
29
32
30
33
FileLogger .init (config)
31
34
```
32
- Log:
35
+ ** Log:**
33
36
``` kotlin
34
37
FileLogger .i(" TAG" , " This is normal Log with custom TAG" )
35
38
FileLogger .i(msg = " This is normal Info Log" )
@@ -38,7 +41,7 @@ FileLogger.w(msg = "This is normal Warning Log")
38
41
FileLogger .e(msg = " This is normal Error Log" )
39
42
```
40
43
41
- Exception:
44
+ ** Exception:**
42
45
``` kotlin
43
46
try {
44
47
// ...
@@ -47,12 +50,48 @@ try {
47
50
}
48
51
```
49
52
50
- Delete log files:
53
+ ** Compress to Zip file and Email logs:**
54
+ ``` kotlin
55
+ FileLogger .compressLogsInZipFile(" my_files" ) { zipFile ->
56
+ zipFile?.let {
57
+ FileIntent .fromFile(this @MainActivity, zipFile, BuildConfig .APPLICATION_ID )?.let { intent ->
58
+ intent.putExtra(Intent .EXTRA_SUBJECT , " Email Subject" )
59
+ try {
60
+ startActivity(Intent .createChooser(intent, " Email App..." ))
61
+ } catch (e: java.lang.Exception ) {
62
+ FileLogger .e(throwable = e)
63
+ }
64
+ }
65
+ }
66
+ }
67
+ ```
68
+ for share file with email or etc add this provider in the AndroidManifest.xml file:
69
+ ``` xml
70
+ <provider
71
+ android : name =" androidx.core.content.FileProvider"
72
+ android : authorities =" ${applicationId}.provider"
73
+ android : exported =" false"
74
+ android : grantUriPermissions =" true" >
75
+ <meta-data
76
+ android : name =" android.support.FILE_PROVIDER_PATHS"
77
+ android : resource =" @xml/provider_paths" />
78
+ </provider >
79
+ ```
80
+ And this one in resource/xml/provider_paths:
81
+ ``` xml
82
+ <?xml version =" 1.0" encoding =" utf-8" ?>
83
+ <paths >
84
+ <external-path name =" media" path =" ." />
85
+ <root-path name =" external_files" path =" /storage/" />
86
+ </paths >
87
+ ```
88
+
89
+ ** Delete log files:**
51
90
``` kotlin
52
91
FileLogger .deleteFiles()
53
92
```
54
93
55
- Enable and disable logging:
94
+ ** Enable and disable logging:**
56
95
``` kotlin
57
96
FileLogger .setEnable(boolean)
58
97
```
0 commit comments