日志工具类

LogAuto 是一个用于简化 Android 应用程序中日志记录过程的工具类,它提供了一系列静态方法来帮助开发者轻松地进行日志输出,包括 DEBUG、INFO、ERROR、WARN 和 VERBOSE 等级别的日志记录。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

/*
 * @(#)LogAuto.java              Project:androidkit
 * Date:2013-9-9
 *
 * Copyright (c) 2013 CFuture09, Institute of Software, 
 * Guangdong Ocean University, Zhanjiang, GuangDong, China.
 * All rights reserved.
 *
 * 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.
 */
package com.lurencun.cfuture09.androidkit.utils.lang;

import android.util.Log;

import com.githang.androidkit.Version;

/**
 * @author Geek_Soledad <a target="_blank" href=
 *         "http://mail.qq.com/cgi-bin/qm_share?t=qm_mailme&email=XTAuOSVzPDM5LzI0OR0sLHM_MjA"
 *         style="text-decoration:none;"><img src=
 *         "http://rescdn.qqmail.com/zh_CN/htmledition/images/function/qm_open/ico_mailme_01.png"
 *         /></a>
 */
public class LogAuto {
   public static final int ASSERT = Log.ASSERT;
   public static final int DEBUG = Log.DEBUG;
   public static final int ERROR = Log.ERROR;
   public static final int INFO = Log.INFO;
   public static final int VERBOSE = Log.VERBOSE;
   public static final int WARN = Log.WARN;
   protected final String TAG;

   protected LogAuto(Class<?> clazz) {
      TAG = initTag(clazz);
   }

   protected String initTag(Class<?> clazz) {
      return String.format("%s: %s", Version.ANDROIDKIT_NAME, clazz.getSimpleName());
   }

   public static LogAuto getLog(Class<?> clazz) {
      return new LogAuto(clazz);
   }

   public void d(String msg) {
      Log.d(TAG, msg);
   }

   public void d(String msg, Throwable tr) {
      Log.d(TAG, msg, tr);
   }

   public void e(String msg) {
      Log.e(TAG, msg);
   }

   public void e(String msg, Throwable tr) {
      Log.e(TAG, msg, tr);
   }

   public void i(String msg) {
      Log.i(TAG, msg);
   }

   public void i(String msg, Throwable tr) {
      Log.i(TAG, msg, tr);
   }

   public void v(String msg) {
      Log.v(TAG, msg);
   }

   public void v(String msg, Throwable tr) {
      Log.v(TAG, msg, tr);
   }

   public void w(String msg) {
      Log.w(TAG, msg);
   }

   public void w(Throwable tr) {
      Log.w(TAG, tr);
   }

   public void w(String msg, Throwable tr) {
      Log.w(TAG, msg, tr);
   }

   public void getStackTraceString(Throwable tr) {
      Log.getStackTraceString(tr);
   }

   public void isLoggable(int level) {
      Log.isLoggable(TAG, level);
   }

   public void println(int priority, String msg) {
      Log.println(priority, TAG, msg);
   }

}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值