All Projects → tianzhijiexian → LogDelegate

tianzhijiexian / LogDelegate

Licence: Apache-2.0 license
Simple, pretty and powerful logger for android

Projects that are alternatives of or similar to LogDelegate

aixlog
Header-only C++ logging library
Stars: ✭ 95 (-66.9%)
Mutual labels:  log, logcat
TLog
Android日志工具
Stars: ✭ 16 (-94.43%)
Mutual labels:  log, logcat
Logger
✔️ Simple, pretty and powerful logger for android
Stars: ✭ 13,093 (+4462.02%)
Mutual labels:  log, logcat
datalogger
DataLogger foi projetado para ser uma biblioteca simples de log com suporte a vários providers.
Stars: ✭ 46 (-83.97%)
Mutual labels:  log, logcat
Xlog
Android logger, pretty, powerful and flexible, log to everywhere, save to file, all you want is here.
Stars: ✭ 2,468 (+759.93%)
Mutual labels:  log, logcat
Wordpress Simple History
🔍🕵️‍♀️ WordPress audit log that track user changes in WordPress admin using a nice activity feed.
Stars: ✭ 232 (-19.16%)
Mutual labels:  log
logy
Parse log files like a pro with this awesome CLI tool. Paginate and filter with great ease.
Stars: ✭ 28 (-90.24%)
Mutual labels:  log
Monolog Bundle
Symfony Monolog Bundle
Stars: ✭ 2,532 (+782.23%)
Mutual labels:  log
Pgbadger
A fast PostgreSQL Log Analyzer
Stars: ✭ 2,522 (+778.75%)
Mutual labels:  log
woodpecker-client
异常日志收集客户端 环境隔离版本
Stars: ✭ 51 (-82.23%)
Mutual labels:  log
log
Aplus Framework Log Library
Stars: ✭ 14 (-95.12%)
Mutual labels:  log
Matomo
Liberating Web Analytics. Star us on Github? +1. Matomo is the leading open alternative to Google Analytics that gives you full control over your data. Matomo lets you easily collect data from websites & apps and visualise this data and extract insights. Privacy is built-in. We love Pull Requests!
Stars: ✭ 15,711 (+5374.22%)
Mutual labels:  log
Sagan
** README ** This repo has MOVED to https://github.com/quadrantsec/sagan
Stars: ✭ 236 (-17.77%)
Mutual labels:  log
git-tui
Collection of human friendly terminal interface for git.
Stars: ✭ 95 (-66.9%)
Mutual labels:  log
Golog
A high-performant Logging Foundation for Go Applications. X3 faster than the rest leveled loggers.
Stars: ✭ 208 (-27.53%)
Mutual labels:  log
k3log
三大王日志,一款开箱即用且高效,快捷,安全的golang日志,基于uber zap
Stars: ✭ 32 (-88.85%)
Mutual labels:  log
Lumberjackconsole
On-device CocoaLumberjack console with support for search, adjust levels, copying and more.
Stars: ✭ 205 (-28.57%)
Mutual labels:  log
Base
🍁 Base是针对于Android开发封装好一些常用的基类,主要包括通用的Adapter、Activity、Fragment、Dialog等、和一些常用的Util类,只为更简单。
Stars: ✭ 249 (-13.24%)
Mutual labels:  log
Fluent Bit
Fast and Lightweight Logs and Metrics processor for Linux, BSD, OSX and Windows
Stars: ✭ 3,223 (+1023%)
Mutual labels:  log
Laravel Log Viewer
🐪 Laravel log viewer
Stars: ✭ 2,726 (+849.83%)
Mutual labels:  log

Android Arsenal

Logger

Simple, pretty and powerful logger for android

Logger provides :

  • Thread information
  • Class information
  • Method information
  • Pretty-print for json/xml content
  • Pretty-print for new line "\n"
  • Clean output
  • print max long log
  • Jump to source(by link)
  • Smart log tag
  • different log format
  • null message
  • null tag
  • support large string

Gradle

Add it in your root build.gradle at the end of repositories:

allprojects {
    repositories {
	//...
	maven { url "https://jitpack.io" }
    }
}

Add the dependency

compile 'com.github.tianzhijiexian:logger:Latest release(<-click)'

Print

D/MainActivity: │ first
D/MainActivity: │ second
D/MainActivity: └ third ==> levTest(MainActivity.java:62) // 多行

D/MainActivity: └ just test ==> test(MainActivity.java:67) // 单行

D/MainActivity: └ User{name=jack, sex=f, $change=Object}  ==> objTest(MainActivity.java:72)

D/MainActivity: │ ArrayList size = 3 [ 
D/MainActivity: │    [0]:kale,
D/MainActivity: │    [1]:jack,
D/MainActivity: │    [2]:tony
D/MainActivity: │ 
D/MainActivity: └ ] ==> objTest(MainActivity.java:74) // list

D/MainActivity: │ String[3] { 
D/MainActivity: │    [Android,	ios,	wp]
D/MainActivity: └ } ==> objTest(MainActivity.java:76) // array

D/MainActivity: │ double[4][5] { 
D/MainActivity: │   [1.2,	1.6,	1.7,	30.0,	33.0]
D/MainActivity: │   [1.2,	1.6,	1.7,	30.0,	33.0]
D/MainActivity: │   [1.2,	1.6,	1.7,	30.0,	33.0]
D/MainActivity: │   [1.2,	1.6,	1.7,	30.0,	33.0]
D/MainActivity: │ 
D/MainActivity: └ } ==> objTest(MainActivity.java:83) // array

D/MainActivity: │ {
D/MainActivity: │     "widget": {
D/MainActivity: │         "debug": "on",
D/MainActivity: │         "window": {
D/MainActivity: │             "title": "Sample Konfabulator Widget",
D/MainActivity: │             "name": "main_window",
D/MainActivity: │             "width": 500,
D/MainActivity: │             "height": 500
D/MainActivity: │         }
D/MainActivity: │     }
D/MainActivity: └ } ==> jsonTest(MainActivity.java:87) // json

Usage

With Timber

public class DefaultLogTree extends Timber.DebugTree {

    private LogDelegate mDelegate;   
    
    public DefaultLogTree(LogSettings settings) {
        this(settings, new DefaultLogFormatter()); // or new PrettyFormatter()
  }

    DefaultLogTree(LogSettings settings, AbsLogFormatter formatter) {
        mDelegate = new LogDelegate(settings, formatter,
  (priority, tag, message, throwable) -> Log.println(priority, tag, message));
  }

    @Override
  protected boolean isLoggable(String tag, int priority) {
        return mDelegate.isLoggable(priority, tag);
  }

    @Override
  protected String createStackElementTag(@NonNull StackTraceElement element) {
        return mDelegate.getAutoTag(element);
  }

    @Override
  protected void log(int priority, String tag, @NonNull String message, Throwable t) {
        mDelegate.printLog(priority, tag, message, t);
  }

}
Timber.plant(new DefaultLogTree(settings));
Timber.d("debug"); 
Timber.e("error"); 
Timber.w("warning"); 
Timber.v("verbose"); 
Timber.i("information"); 
Timber.wtf("wtf!!!!");

Timber.tag("Custom Tag").w("logger with custom tag"); // tag

Timber.i(JsonXmlParser.json(json)); // json

Timber.i(JsonXmlParser.xml(xmlStr)); // xml

// object 
Timber.d(ObjParser.obj(new User("jack", "f"))); 
// list 
Timber.d(ObjParser.obj(Arrays.asList("kale", "jack", "tony"))); 
// array 
Timber.d(ObjParser.obj(new String[]{"Android", "ios", "wp"}));

With Your LogUtil

public final class LogUtils {

    private static LogDelegate sDelegate;

    public static void init(LogSettings settings) {
        sDelegate = new LogDelegate(settings, new DefaultLogFormatter(),
                (priority, tag, message, throwable) -> Log.println(priority, tag, message));
    }

    public static boolean isLoggable(int priority, String tag) {
        return sDelegate.isLoggable(priority, tag);
    }

    public static void d(String tag, String message) {
        if (isLoggable(Log.DEBUG, tag)) {
            print(Log.DEBUG, tag, message);
        }
    }

    public static void d(String message) {
        String tag = sDelegate.getAutoTag(null);
        d(tag, message);
    }

    public static void e(String tag, String message) {
        if (isLoggable(Log.ERROR, tag)) {
            print(Log.ERROR, tag, message);
        }
    }

    public static void openLog(boolean b) {
        if (b) {
            sDelegate.getSettings().changeLogLev(Log.VERBOSE);
        } else {
            sDelegate.getSettings().closeLog();
        }
    }

    private static void print(int priority, String tag, String message) {
        sDelegate.printLog(priority, tag, message, null);
    }

}
LogUtils.init(settings);

LogUtils.d("kale-tag", "my message");
LogUtils.d("my message");

LogUtils.e("kale-tag", "my error message");

Settings

This should be called only once. Best place would be in application class, all of them are optional.

public class App extends Application {

    @Override
    public void onCreate() {
        super.onCreate();

	LogSettings settings = new LogSettings.Builder()
	        .showMethodLink(true)
	        .showThreadInfo(true)
	        .tagPrefix("kale")
	        .globalTag("GLOBAL-TAG")
	        .methodOffset(1)
	        .logPriority(BuildConfig.DEBUG ? Log.VERBOSE : Log.ASSERT)
	        .build();
}

You might also like

  • Logger Simple, pretty and powerful logger for android
  • Hawk Simple,powerful,secure key-value storage
  • Wasp All-in-one network solution
  • Bee QA/Debug tool
  • DialogPlus Easy,simple dialog solution
  • SimpleListView Simple basic listview implementation with linearlayout
  • Android-PLog A Pure, Pretty and Powerful logging library for android.

License

Copyright 2015 Orhan Obut

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.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].