All Projects → Blankj → Alog

Blankj / Alog

Licence: apache-2.0
📝 A simple util of log in Android develop.

Programming Languages

java
68154 projects - #9 most used programming language

Labels

Projects that are alternatives of or similar to Alog

Nestjs Pino
Platform agnostic logger for NestJS based on Pino with REQUEST CONTEXT IN EVERY LOG
Stars: ✭ 283 (-37.25%)
Mutual labels:  logger
Electron Timber
Pretty logger for Electron apps
Stars: ✭ 337 (-25.28%)
Mutual labels:  logger
Onelog
Dead simple, super fast, zero allocation and modular logger for Golang
Stars: ✭ 389 (-13.75%)
Mutual labels:  logger
Analog
PHP logging library that is highly extendable and simple to use.
Stars: ✭ 314 (-30.38%)
Mutual labels:  logger
Caterpillar
Caterpillar is the ultimate logging system for Deno, Node.js, and Web Browsers. Log levels are implemented to the RFC standard. Log entries can be filtered and piped to various streams, including coloured output to the terminal, the browser's console, and debug files. You can even write your own transforms.
Stars: ✭ 330 (-26.83%)
Mutual labels:  logger
Cocoadebug
iOS Debugging Tool 🚀
Stars: ✭ 3,769 (+735.7%)
Mutual labels:  logger
Tty Logger
A readable, structured and beautiful logging for the terminal
Stars: ✭ 280 (-37.92%)
Mutual labels:  logger
Izumi
Productivity-oriented collection of lightweight fancy stuff for Scala toolchain
Stars: ✭ 423 (-6.21%)
Mutual labels:  logger
Log analyzer
Rails logs analyzer (see how fast your views are rendering)
Stars: ✭ 333 (-26.16%)
Mutual labels:  logger
Objectlogger
A powerful and easy-to-use operational logging system that supports analysis of changes in object properties. 强大且易用的操作日志记录系统,支持对象属性的变化分析。
Stars: ✭ 378 (-16.19%)
Mutual labels:  logger
Laravel Query Logger
📝 A dev tool to log all queries for laravel application.
Stars: ✭ 316 (-29.93%)
Mutual labels:  logger
Tslog
📝 tslog - Expressive TypeScript Logger for Node.js.
Stars: ✭ 321 (-28.82%)
Mutual labels:  logger
Laravel Logger
An out the box activity logger for your Laravel or Lumen application. Laravel logger is an activity event logger for your laravel application. It comes out the box with ready to use with dashboard to view your activity. Laravel logger can be added as a middleware or called through a trait. This package is easily configurable and customizable. Supports Laravel 5.3, 5.4, 5.5, 5.6, 5.7, 5.8, 6, and 7+
Stars: ✭ 366 (-18.85%)
Mutual labels:  logger
Trace4j
基于注解的轻量级java流程跟踪工具
Stars: ✭ 302 (-33.04%)
Mutual labels:  logger
Concurrency Logger
Log HTTP requests/responses separately, visualize their concurrency and report logs/errors in context of a request.
Stars: ✭ 400 (-11.31%)
Mutual labels:  logger
Apilogger
Small laravel package for viewing api logs which can be used in debugging.
Stars: ✭ 285 (-36.81%)
Mutual labels:  logger
Tinylog
tinylog is a lightweight logging framework for Java, Kotlin, Scala, and Android
Stars: ✭ 360 (-20.18%)
Mutual labels:  logger
Airframe
Essential Building Blocks for Scala
Stars: ✭ 442 (-2%)
Mutual labels:  logger
Quill
Asynchronous Low Latency C++ Logging Library
Stars: ✭ 422 (-6.43%)
Mutual labels:  logger
Monolog
Requirements
Stars: ✭ 19,361 (+4192.9%)
Mutual labels:  logger

ALog(该库已停止维护,后续更新都在 AndroidUtilCodeLogUtils

ALog api build License

Functions

  • 兼容 Android Studio 3.1.0 的 Logcat 完美显示日志
  • 兼容 Kotlin
  • 可设置 Log 开启和关闭
  • 可设置是否输出到控制台(Logcat)
  • 可设置 Log 全局 Tag
  • 全局 Tag 为空时 Tag 为当前类名
  • 可设置 Log 是否显示头部信息
  • Log 文件顶部显示设备信息
  • Log 头部含有当前线程名
  • Log 头部含有当前类及行号和函数名,支持点击跳转
  • 可设置 Log 是否写入文件
  • 可设置 Log 写入文件目录
  • 可设置 Log 写入文件前缀
  • 可设置 Log 是否显示边框
  • 可设置 Log 控制台过滤器
  • 可设置 Log 文件过滤器
  • 可设置 Log 栈深度
  • 可设置 Log 栈偏移
  • 可设置 Log 保存天数
  • 可增加 Log 格式化器,默认已支持 Array, Throwable, Bundle, Intent 格式化输出
  • 支持控制台长字符串的输出
  • 支持多参数输出
  • 支持单独写入文件
  • 支持 JSON 串的输出
  • 支持 XML 串的输出
  • 支持 Live Templates
  • jar 包不足 5Kb

API -> ALog.java -> Demo

init                     : 初始化
getConfig                : 获取 log 配置
Config.setLogSwitch      : 设置 log 总开关
Config.setConsoleSwitch  : 设置 log 控制台开关
Config.setGlobalTag      : 设置 log 全局 tag
Config.setLogHeadSwitch  : 设置 log 头部信息开关
Config.setLog2FileSwitch : 设置 log 文件开关
Config.setDir            : 设置 log 文件存储目录
Config.setFilePrefix     : 设置 log 文件前缀
Config.setBorderSwitch   : 设置 log 边框开关
Config.setSingleTagSwitch: 设置 log 单一 tag 开关(为美化 AS 3.1 的 Logcat)
Config.setConsoleFilter  : 设置 log 控制台过滤器
Config.setFileFilter     : 设置 log 文件过滤器
Config.setStackDeep      : 设置 log 栈深度
Config.setStackOffset    : 设置 log 栈偏移
Config.setSaveDays       : 设置 log 可保留天数
Config.addFormatter      : 新增 log 格式化器
log                      : 自定义 tag 的 type 日志
v                        : tag 为类名的 Verbose日志
vTag                     : 自定义 tag 的 Verbose日志
d                        : tag 为类名的 Debug 日志
dTag                     : 自定义 tag 的 Debug 日志
i                        : tag 为类名的 Info 日志
iTag                     : 自定义 tag 的 Info 日志
w                        : tag 为类名的 Warn 日志
wTag                     : 自定义 tag 的 Warn 日志
e                        : tag 为类名的 Error日志
eTag                     : 自定义 tag 的 Error日志
a                        : tag 为类名的 Assert 日志
aTag                     : 自定义 tag 的 Assert 日志
file                     : log 到文件
json                     : log 字符串之 json
xml                      : log 字符串之 xml

How to use

compile 'com.blankj:alog:1.9.1' or Download

Usage

初始化

在 Application 的 onCreate 函数中初始化,如下

// init it in ur application
public void initALog() {
    ALog.Config config = ALog.init(this)
            .setLogSwitch(BuildConfig.DEBUG)// 设置 log 总开关,包括输出到控制台和文件,默认开
            .setConsoleSwitch(BuildConfig.DEBUG)// 设置是否输出到控制台开关,默认开
            .setGlobalTag(null)// 设置 log 全局标签,默认为空
            // 当全局标签不为空时,我们输出的 log 全部为该 tag,
            // 为空时,如果传入的 tag 为空那就显示类名,否则显示 tag
            .setLogHeadSwitch(true)// 设置 log 头信息开关,默认为开
            .setLog2FileSwitch(false)// 打印 log 时是否存到文件的开关,默认关
            .setDir("")// 当自定义路径为空时,写入应用的 /cache/log/ 目录中
            .setFilePrefix("")// 当文件前缀为空时,默认为 "alog",即写入文件为 "alog-MM-dd.txt"
            .setBorderSwitch(true)// 输出日志是否带边框开关,默认开
            .setSingleTagSwitch(true)// 一条日志仅输出一条,默认开,为美化 AS 3.1 的 Logcat
            .setConsoleFilter(ALog.V)// log 的控制台过滤器,和 logcat 过滤器同理,默认 Verbose
            .setFileFilter(ALog.V)// log 文件过滤器,和 logcat 过滤器同理,默认 Verbose
            .setStackDeep(1)// log 栈深度,默认为 1
            .setStackOffset(0)// 设置栈偏移,比如二次封装的话就需要设置,默认为 0
            .setSaveDays(3)// 设置日志可保留天数,默认为 -1 表示无限时长
            // 新增 ArrayList 格式化器,默认已支持 Array, Throwable, Bundle, Intent 的格式化输出
            .addFormatter(new ALog.IFormatter<ArrayList>() {
                @Override
                public String format(ArrayList list) {
                    return "ALog Formatter ArrayList { " + list.toString() + " }";
                }
            });
    ALog.d(config.toString());
}

借助我帮大家写好的 Live Templates 大家可以更方便地使用 ALog,演示动画如下所示。

templates

大家可以下载这个 Live Templates 包,然后在 AS 中 File -> Import Settings 即可。

关于如何写 Live Templates,其实大家可以借鉴安卓自带的 Live Templates,然后效仿一下即可。

默认初始化下的图例

  • ALog.d("debug");

detail

  • ALog.d("customTag", "debug0", "debug1");

args

  • ALog.d(longStr);

long

  • ALog.file(longStr);

file

filecontent

  • ALog.json(json);

json

  • ALog.xml(xml);

xml

更多使用请运行 demo 来查看。

Contact

jianshu weibo Blog QQ0Group QQ1Group

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].