Android Log Package

Source: Internet
Author: User
Tags throwable

Package com.tv.ui.metro.utils;

/*
* Copyright (C) lytsing Huang http://lytsing.org
*
* Licensed under the Apache License, Version 2.0 (the "License");
* You are not a use this file except in compliance with the License.
* Obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable or agreed to writing, software
* Distributed under the License is distributed on a "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.
*/

/**
* Wrapper API for sending log output.
*/
public class _log {
Protected static final String TAG = "MyApplication";

Public _log () {
}

/**
* Send a VERBOSE log message.
* @param msg The message would like logged.
*/
public static void V (String msg) {
ANDROID.UTIL.LOG.V (TAG, Buildmessage (msg));
}

/**
* Send a VERBOSE log message and log the exception.
* @param msg The message would like logged.
* @param thr an exception to log
*/
public static void V (String msg, throwable thr) {
ANDROID.UTIL.LOG.V (TAG, Buildmessage (msg), THR);
}

/**
* Send a DEBUG log message.
* @param msg
*/
public static void D (String msg) {
ANDROID.UTIL.LOG.D (TAG, Buildmessage (msg));
}

public static void DI () {
ANDROID.UTIL.LOG.D (TAG, Buildmessage ("in"));
}
public static void Do () {
ANDROID.UTIL.LOG.D (TAG, Buildmessage ("Out"));
}
/**
* Send a DEBUG log message and log the exception.
* @param msg The message would like logged.
* @param tr an exception to log
*/
public static void D (String msg, throwable thr) {
ANDROID.UTIL.LOG.D (TAG, Buildmessage (msg), THR);
}

/**
* Send an INFO log message.
* @param msg The message would like logged.
*/
public static void I (String msg) {
ANDROID.UTIL.LOG.I (TAG, Buildmessage (msg));
}

/**
* Send a INFO log message and log the exception.
* @param msg The message would like logged.
* @param thr an exception to log
*/
public static void I (String msg, throwable thr) {
ANDROID.UTIL.LOG.I (TAG, Buildmessage (msg), THR);
}

/**
* Send an ERROR log message.
* @param msg The message would like logged.
*/
public static void E (String msg) {
ANDROID.UTIL.LOG.E (TAG, Buildmessage (msg));
}

/**
* Send a WARN log message
* @param msg The message would like logged.
*/
public static void W (String msg) {
ANDROID.UTIL.LOG.W (TAG, Buildmessage (msg));
}

/**
* Send a WARN log message and log the exception.
* @param msg The message would like logged.
* @param thr an exception to log
*/
public static void W (String msg, throwable thr) {
ANDROID.UTIL.LOG.W (TAG, Buildmessage (msg), THR);
}

/**
* Send an empty WARN log message and log the exception.
* @param thr an exception to log
*/
public static void W (Throwable thr) {
ANDROID.UTIL.LOG.W (TAG, Buildmessage (""), THR);
}

/**
* Send an ERROR log message and log the exception.
* @param msg The message would like logged.
* @param thr an exception to log
*/
public static void E (String msg, throwable thr) {
ANDROID.UTIL.LOG.E (TAG, Buildmessage (msg), THR);
}

/**
* Building Message
* @param msg The message would like logged.
* @return Message String
*/
protected static string Buildmessage (String msg) {
Stacktraceelement caller = new Throwable (). Fillinstacktrace (). Getstacktrace () [2];

return new StringBuilder ()
. Append (Caller.getclassname ())
. Append (".")
. Append (Caller.getmethodname ())
. Append ("():")
. Append (msg). toString ();
}
}

Android Log Package

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.