LogUtils


Source link: https://github.com/pengwei1024/LogUtils

LogUtils

More convenient and easy to use android Log manager

1. Features

  • ??????????,?List?Set?Map????
  • ????log??
  • ?????Tag
  • ?????????????????????
  • ??android????Intent?Bundle??
  • ??release-no-op??
  • ????????

2. screenshot

????

?????Tag

??????

????

??????????????

??????Intent

3. Simple

// ????? LogUtils.d("12345");
  // ???? LogUtils.d("12%s3%d45", "a", 0);
  // ???? LogUtils.d(new NullPointerException("12345"));
  // ???? Person person = new Person();
 person.setAge(11);
 person.setName("pengwei");
 person.setScore(37.5f);
 LogUtils.d(person);
  // ???? LogUtils.d(null);
  // ??json?json??debug??? String json = "{
'a':'b','c':{
'aa':234,'dd':{
'az':12
}

}

}
"; LogUtils.json(json);
  // ?????? List<Person> list1 = new ArrayList<>();
 for(int i = 0; i < 4; i++){

  list1.add(person);
 
}
 LogUtils.d(list1);
  // ???? double[][] doubles = {
{
1.2, 1.6, 1.7, 30, 33
}
,

  {
1.2, 1.6, 1.7, 30, 33
}
,

  {
1.2, 1.6, 1.7, 30, 33
}
,

  {
1.2, 1.6, 1.7, 30, 33
}

}
; LogUtils.d(doubles);
  // ???tag LogUtils.tag("?????tag").d("??????");
  // ???? LogUtils.v("12345");
 LogUtils.i("12345");
 LogUtils.w("12345");
 LogUtils.e("12345");
 LogUtils.wtf("12345");

options

?? ?? ?? ??
configAllowLog ???????? boolean true
configTagPrefix ??log??? String "LogUtils"
configShowBorders ?????? boolean false
configLevel ?????? LogLevelType LogLevel.TYPE_VERBOSE
addParserClass ??????? Parser ?
configFormatTag ?????Tag String %c{ -5 }
configMethodOffset ????? int 0
????????
?? ?? ?? ??
configLog2FileEnable ???????? boolean false
configLog2FilePath ?????? String /sdcard/LogUtils/logs/
configLog2FileNameFormat ??????? string %d{ yyyyMMdd } .txt
configLog2FileLevel ?????? LogLevelType LogLevel.TYPE_VERBOSE
configLogFileEngine ?????? LogFileEngine ?
configLogFileFilter ?????? LogFileFilter ?
Demo
LogUtils.getLogConfig()

  .configAllowLog(true)

  .configTagPrefix("MyAppName")

  .configShowBorders(true)

  .configFormatTag("%d{
HH:mm:ss:SSS
}
 %t %c{
-5
}
")  # ?????????  LogUtils.getLog2FileConfig().configLog2FileEnable(true)

  // targetSdkVersion >= 23 ??????sdcard??

  .configLog2FilePath("/sdcard/?????/logs/")

  .configLog2FileNameFormat("%d{
yyyyMMdd
}
.txt")

.configLogFileEngine(new LogFileEngineFactory());

  
configFormatTag????
?? ?? ?? ?? ?? ????
%% ? ??% ? %%d %d
%date %d ???? ?????,?HH:mm:ss %d{ HH:mm:ss:SSS } 10:00:46:238
%thread %t ?????? ? %t thread-127
%caller %c ???????? ???%c{ -5 } ???????%c{ ?? } ??%caller{ ?? } ????????????? com.apkfuns.logutils.demo.MainActivity.onCreate(MainActivity.java:135),%c{ 1 } ?? com??.??????,????0??????n???%c{ -1 } ???? apkfuns.logutils.demo.activity.MainActivity.onCreate(MainActivity.java:135), %c{ -5 } MainActivity.onCreate(MainActivity.java:135)
???????

??Parser??????parseClassType() ?parseString()??,???addParserClass()???LogUtil ????

4. Usage

Gradle

compile 'com.apkfuns.logutils:library:1.5.1.1'
release-no-op??
debugCompile 'com.apkfuns.logutils:library:1.5.1.1' releaseCompile 'com.apkfuns.logutils:logutils-no-op:1.5.1.1'
???????
  • ??log2file?(??okio)
compile 'com.apkfuns.log2file:log2file:1.0.0' ... ???????okio(?pokhttp)??? compile('com.apkfuns.log2file:log2file:1.0.0') {

  exclude module: 'okio' 
}
 ... LogUtils.getLog2FileConfig().configLogFileEngine(new LogFileEngineFactory());
 
  • ??LogFileEngine??
public class MyLogFileEngine implements LogFileEngine {

  @Override
  public void writeToFile(File logFile, String logContent, LogFileParam params) {

....
  
}
 
}
 ... LogUtils.getLog2FileConfig().configLogFileEngine(new MyLogFileEngine());
 

??????????

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> 

Eclipse??Jar

click here to download *.jar

5. Skills

6. History

  • 1.0.0 (2015/07/13)
    • ???????????
    • ??????????
  • 1.0.1 (2015/07/22)
    • ??json???
  • 1.0.2 (2015/07/24)
    • ????List?Se?????
  • 1.0.3 (2015/07/24)
    • ????Map??
  • 1.0.4 (2015/07/25)
    • ??????(???????????)
  • 1.0.6 (2015/08/28)
    • ?????????%s???bug
  • 1.1.0 (2016/03/02)
    • ???Exception?????
  • 1.2.0 (2016/03/09)
    • ??android????Bundle?Intent???
    • ??????
    • ??????
    • ?????????
    • ???????4k??
  • 1.2.1 (2016/03/14)
    • ??Intent??Flags??
    • ?????Parse???Parse?????
  • 1.2.2 (2016/03/22)
    • ????Reference??bug
  • 1.3.0 (2016/04/20)
    • ???????????????
  • 1.3.1 (2016/05/09)
    • ???????????????
  • 1.4.0 (2016/05/19)
  • 1.4.2 (2016/05/23)
    • ?????Tag(configFormatTag(); )
  • **1.4.3 **
    • ??Instant Run????????????
  • 1.5.1 (2017/03/31)
    • ???????????

7. About

8. Thanks

9. License

Copyright 2015-2016 pengwei1024  Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License. You may obtain a copy of the License at
  http://www.apache.org/licenses/LICENSE-2.0  Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 

Resources

Customizable Android Particles Drawable and View.

KPoet is a Kotlin extensions library on top of JavaPoet that helps you write code generators / annotation processors that feel like actually writing Java code directly. It provides a Kotlin DSL syntax that resembles real java code as much as possible. Also it attempts to make the code generator writing clear as writing native java code itself.

A lightweight iOS switch view style for Android.

Skygear Server is a cloud backend for making web and mobile app development easier https://skygear.io.

The Skygear Android SDK library that gives you access to the Skygear Server from your Android app.

Expansion pack for Android Volley Framework.

NeatLE is an Android BTLE (Bluetooth low energy) support library that simplifies management of BTLE connections, subscriptions, devices and operations. It provides a single entry point for all BTLE related operations and helps you:

  • Monitor connections to a BTLE devices.
  • Send read / write commands and receive responses.
  • Subscribe to characteristics and get notified of changes.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes