forked from lulululbj/Box
-
Notifications
You must be signed in to change notification settings - Fork 0
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
13 changed files
with
195 additions
and
64 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package luyao.box.ext | ||
|
||
import android.util.Log | ||
import luyao.box.BuildConfig | ||
|
||
/** | ||
* Description: log相关,日志的开关和默认tag通过AndroidKtxConfig来配置 | ||
* Create by lxj, at 2018/12/5 | ||
*/ | ||
|
||
const val BOX="box" | ||
|
||
private enum class LogLevel{ | ||
Verbose, Debug, Info, Warn, Error | ||
} | ||
|
||
fun String.v(tag: String = BOX){ | ||
intervalLog(LogLevel.Verbose, tag, this ) | ||
} | ||
|
||
fun String.d(tag: String = BOX){ | ||
intervalLog(LogLevel.Debug, tag, this ) | ||
} | ||
fun String.i(tag: String = BOX){ | ||
intervalLog(LogLevel.Info, tag, this ) | ||
} | ||
fun String.w(tag: String = BOX){ | ||
intervalLog(LogLevel.Warn, tag, this ) | ||
} | ||
fun String.e(tag: String = BOX){ | ||
intervalLog(LogLevel.Error, tag, this ) | ||
} | ||
|
||
private fun intervalLog(level: LogLevel, tag: String, msg: String){ | ||
if(BuildConfig.DEBUG){ | ||
when (level) { | ||
LogLevel.Verbose -> Log.v(tag, msg) | ||
LogLevel.Debug -> Log.d(tag, msg) | ||
LogLevel.Info -> Log.i(tag, msg) | ||
LogLevel.Warn -> Log.w(tag, msg) | ||
LogLevel.Error -> Log.e(tag, msg) | ||
} | ||
} | ||
} |
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
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
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
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
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
Oops, something went wrong.