AAkira / Napier

Logging library for Kotlin Multiplatform
Apache License 2.0
820 stars 36 forks source link

Add an option to use compact tag format to DebugAntilog #93

Open Vlad-M-1 opened 2 years ago

Vlad-M-1 commented 2 years ago

Method name etc in the tag can be verbose in some cases.

For example, error messages in the projects I'm working on are more or less unique. And there's no need for the detailed tags.

It takes more time and cognitive efforts to read log lines with long tags. And in this case it doesn't seem to provide enough value to justify it.

An option to use short tags seems like a reasonable addition. Class name as a tag would make logs look like default Android logs. Which is what lots of developers are used to. And those who prefer long tags would still be able to use them.

Of course, there is an option to implement custom Antilog in a project. But it seems to be an extra effort multiplied by a number of platforms multiplied by a number of devs who prefer short tags :)

Another option with writing short tags for each Napier call manually would also be not the most pleasant thing.

What do you think?

AAkira commented 2 years ago

When I first created this library, I was dissatisfied with MPP modules that could only use print, because I could not recognize which file was outputting the log with just print.

So I added a default tag to display the file path and name in the Napier. If you want to set a shorter tag, I have designed it so that you can make a custom Antilog as you say.

I could provide an option to set the tags at once, but I'm not thinking about it right now. Do you have a better solution?

Vlad-M-1 commented 2 years ago

Oh, I see. I think it's ok. It was more of a suggestion. Writing a custom Antilog appeared to be fine.

Thank you for the reply.

frontiertsymbal commented 2 years ago

Hello @AAkira. I have a slightly different question, but also related to the tag. Previously, I used Timber and I had the opportunity to make a clickable tag for the logcat. Now I'm using your library - how can I implement the same functional for this library? Thank you!

class HyperlinkedDebugTree : Timber.DebugTree() { override fun createStackElementTag(element: StackTraceElement) = element.run { "($fileName:$lineNumber)$methodName()" } }