AndroidBaseUtils icon indicating copy to clipboard operation
AndroidBaseUtils copied to clipboard

LogUtil

Open ugurcany opened this issue 8 years ago • 14 comments

It would be nice to have a LogUtil (that prints messages in a pretty way) in this library.

ugurcany avatar Mar 14 '16 14:03 ugurcany

This sounds great! I would like to design proper API for LogUtil. Here is my thought about it! Let me know if you have any idea to add or if you don't like some part of the design.

Class name: LogUtil

Set Defaults Methods

  • LogUtil.setDefaultTag(String tag);
  • LogUtil.setDefaultShowThreadInfo(boolean show);
  • LogUtil.setDefaultShowMethods(int count);

Builder Methods

  • LogUtil.tag(String tag)
  • LogUtil.showThreadInfo()
  • LogUtil.showThreadInfo(boolean show)
  • LogUtil.showMethods(int count)

Log Methods:

  • LogUtil.v(...);
  • LogUtil.d(...);
  • LogUtil.i(...);
  • LogUtil.w(...);
  • LogUtil.e(...);
  • LogUtil.wtf(...);
  • LogUtil.json(String jsonString);

Parameters:

  • byte
  • char
  • short
  • int
  • long
  • float
  • double
  • boolean
  • JsonObject
  • Exception

What to show

  • Tag: default as class name
  • Thread Information: main/background, thread id
  • Methods stack

User case

LogUtil.v("Hello World");
LogUtil.showThreadInfo().v("Hello World");

TheFinestArtist avatar Mar 16 '16 04:03 TheFinestArtist

That's perfect. I'm looking forward to it.

ugurcany avatar Mar 18 '16 12:03 ugurcany

@ugurcany I might be able to finish this util today. Updating it https://github.com/TheFinestArtist/AndroidBaseUtils/commit/bb3540b5205ed1f8f42e96dfdb6a01a659aeea26 I will get back to Annotation Processor problem after this!

TheFinestArtist avatar Mar 18 '16 13:03 TheFinestArtist

@ugurcany Check the API out. It's almost done! https://github.com/TheFinestArtist/AndroidBaseUtils#logutil- https://github.com/TheFinestArtist/AndroidBaseUtils#loghelper-

TheFinestArtist avatar Mar 18 '16 16:03 TheFinestArtist

@ugurcany Released 0.8.6

TheFinestArtist avatar Mar 19 '16 13:03 TheFinestArtist

Add logging to file. After creating FileUtil.

TheFinestArtist avatar Mar 19 '16 13:03 TheFinestArtist

Hi, I have a suggestion: You can add separator lines at the start and end of each log to be able to separate logs easily from each other when we look at them.

For an inspiration, see this library: https://github.com/orhanobut/logger

ugurcany avatar Mar 22 '16 15:03 ugurcany

@ugurcany Surely, I will add this feature!

TheFinestArtist avatar Mar 23 '16 05:03 TheFinestArtist

@ugurcany Released 0.9.2

TheFinestArtist avatar Mar 23 '16 07:03 TheFinestArtist

Perfect! Thanks.

ugurcany avatar Mar 23 '16 07:03 ugurcany

Is there any way to disable all log before release? I set log level to NONE but it does not work.

IHNEL avatar Mar 24 '16 06:03 IHNEL

@IHNEL The log level to NONE is the intension for disable all log. I think log level doesn't work as I expected. Let me check!

TheFinestArtist avatar Mar 24 '16 11:03 TheFinestArtist

@IHNEL Released 0.9.3 which fixed LogLevel issue!

TheFinestArtist avatar Mar 24 '16 12:03 TheFinestArtist

Thank you for fast responding. It works fine now.

IHNEL avatar Mar 25 '16 02:03 IHNEL