This repository has been archived by the owner on Feb 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 492
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #274 from svga/2.5.7-feature_logger
增加日志接口
- Loading branch information
Showing
8 changed files
with
205 additions
and
10 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
library/src/main/java/com/opensource/svgaplayer/utils/log/DefaultLogCat.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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.opensource.svgaplayer.utils.log | ||
|
||
import android.util.Log | ||
|
||
/** | ||
* 内部默认 ILogger 接口实现 | ||
*/ | ||
class DefaultLogCat : ILogger { | ||
override fun verbose(tag: String, msg: String) { | ||
Log.v(tag, msg) | ||
} | ||
|
||
override fun info(tag: String, msg: String) { | ||
Log.i(tag, msg) | ||
} | ||
|
||
override fun debug(tag: String, msg: String) { | ||
Log.d(tag, msg) | ||
} | ||
|
||
override fun warn(tag: String, msg: String) { | ||
Log.w(tag, msg) | ||
} | ||
|
||
override fun error(tag: String, msg: String) { | ||
Log.e(tag, msg) | ||
} | ||
|
||
override fun error(tag: String, error: Throwable) { | ||
Log.e(tag, "", error) | ||
} | ||
|
||
override fun error(tag: String, msg: String, error: Throwable) { | ||
Log.e(tag, msg, error) | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
library/src/main/java/com/opensource/svgaplayer/utils/log/ILogger.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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.opensource.svgaplayer.utils.log | ||
|
||
/** | ||
* log 外部接管接口 | ||
**/ | ||
interface ILogger { | ||
fun verbose(tag: String, msg: String) | ||
fun info(tag: String, msg: String) | ||
fun debug(tag: String, msg: String) | ||
fun warn(tag: String, msg: String) | ||
fun error(tag: String, msg: String) | ||
fun error(tag: String, error: Throwable) | ||
fun error(tag: String, msg: String, error: Throwable) | ||
} |
57 changes: 57 additions & 0 deletions
57
library/src/main/java/com/opensource/svgaplayer/utils/log/LogUtils.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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package com.opensource.svgaplayer.utils.log | ||
|
||
/** | ||
* 日志输出 | ||
*/ | ||
internal object LogUtils { | ||
private const val TAG = "SVGALog" | ||
|
||
fun verbose(tag: String = TAG, msg: String) { | ||
if (!SVGALogger.isLogEnabled()) { | ||
return | ||
} | ||
SVGALogger.getSVGALogger()?.verbose(tag, msg) | ||
} | ||
|
||
fun info(tag: String = TAG, msg: String) { | ||
if (!SVGALogger.isLogEnabled()) { | ||
return | ||
} | ||
SVGALogger.getSVGALogger()?.info(tag, msg) | ||
} | ||
|
||
fun debug(tag: String = TAG, msg: String) { | ||
if (!SVGALogger.isLogEnabled()) { | ||
return | ||
} | ||
SVGALogger.getSVGALogger()?.debug(tag, msg) | ||
} | ||
|
||
fun warn(tag: String = TAG, msg: String) { | ||
if (!SVGALogger.isLogEnabled()) { | ||
return | ||
} | ||
SVGALogger.getSVGALogger()?.warn(tag, msg) | ||
} | ||
|
||
fun error(tag: String = TAG, msg: String) { | ||
if (!SVGALogger.isLogEnabled()) { | ||
return | ||
} | ||
SVGALogger.getSVGALogger()?.error(tag, msg) | ||
} | ||
|
||
fun error(tag: String = TAG, msg: String, error: Throwable) { | ||
if (!SVGALogger.isLogEnabled()) { | ||
return | ||
} | ||
SVGALogger.getSVGALogger()?.error(tag, msg, error) | ||
} | ||
|
||
fun error(tag: String, error: Throwable) { | ||
if (!SVGALogger.isLogEnabled()) { | ||
return | ||
} | ||
SVGALogger.getSVGALogger()?.error(tag, error) | ||
} | ||
} |
Oops, something went wrong.