-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
kotlin/logging #89
base: feature/kotlin
Are you sure you want to change the base?
kotlin/logging #89
Conversation
private const val MAX_LOG_LENGTH = 4000 | ||
} | ||
|
||
private fun normalize(message: String): String = message |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Можно сделать extension
val messageToLog = normalize(message + if (throwable != null) '\n' + Log.getStackTraceString(throwable) else "") | ||
val length = messageToLog.length | ||
var i = 0 | ||
while (i < length) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Перепиши без циклов. В Kotlin стиле
|
||
private val DATE_TIME_FORMATTER = ThreadLocalValue( | ||
fabric = object : ThreadLocalValue.Fabric<SimpleDateFormat> { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reformat code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не помагает, если только так:
private val DATE_TIME_FORMATTER = ThreadLocalValue(object : ThreadLocalValue.Fabric<SimpleDateFormat> {
override fun create(): SimpleDateFormat = SimpleDateFormat("HH:mm:ss.SSS", Locale.getDefault())
})
null | ||
} | ||
|
||
private fun createLogMessage(formattedMessage: String?): String = DATE_TIME_FORMATTER.get()!!.format(System.currentTimeMillis()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Небезопасно
* Group of log messages with specific tag prefix (name of group). | ||
* It could be used in specific [LogProcessor] to filter messages by group. | ||
*/ | ||
@SuppressWarnings("checkstyle:methodname", "PMD.ShortMethodName") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checkstyle и PMD больше не используем
logging: Java => Kotlin