Skip to content

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.

3 participants