Skip to content
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

Open
wants to merge 9 commits into
base: feature/kotlin
Choose a base branch
from
Open

kotlin/logging #89

wants to merge 9 commits into from

Conversation

saifer2505
Copy link
Contributor

logging: Java => Kotlin

private const val MAX_LOG_LENGTH = 4000
}

private fun normalize(message: String): String = message
Copy link
Contributor

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) {
Copy link
Contributor

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> {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reformat code

Copy link
Contributor Author

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())
Copy link
Contributor

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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checkstyle и PMD больше не используем

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants