rpicms-android

Android app for the RPICMS.
git clone git://archive.git.mtrnord.blog/RpicmsTeam/rpicms-android.git
Log | Files | Refs

Log.java (7545B)


      1 package de.nordgedanken.rpicms.common.logger;
      2 
      3 /**
      4  * Created by frank on 14.10.14.
      5  */
      6 public class Log {
      7     // Grabbing the native values from Android's native logging facilities,
      8     // to make for easy migration and interop.
      9     public static final int NONE = -1;
     10     public static final int VERBOSE = android.util.Log.VERBOSE;
     11     public static final int DEBUG = android.util.Log.DEBUG;
     12     public static final int INFO = android.util.Log.INFO;
     13     public static final int WARN = android.util.Log.WARN;
     14     public static final int ERROR = android.util.Log.ERROR;
     15     public static final int ASSERT = android.util.Log.ASSERT;
     16 
     17     // Stores the beginning of the LogNode topology.
     18     private static LogNode mLogNode;
     19 
     20     /**
     21      * Returns the next LogNode in the linked list.
     22      */
     23     public static LogNode getLogNode() {
     24         return mLogNode;
     25     }
     26 
     27     /**
     28      * Sets the LogNode data will be sent to.
     29      */
     30     public static void setLogNode(LogNode node) {
     31         mLogNode = node;
     32     }
     33 
     34     /**
     35      * Instructs the LogNode to print the log data provided. Other LogNodes can
     36      * be chained to the end of the LogNode as desired.
     37      *
     38      * @param priority Log level of the data being logged. Verbose, Error, etc.
     39      * @param tag Tag for for the log data. Can be used to organize log statements.
     40      * @param msg The actual message to be logged.
     41      * @param tr If an exception was thrown, this can be sent along for the logging facilities
     42      *           to extract and print useful information.
     43      */
     44     public static void println(int priority, String tag, String msg, Throwable tr) {
     45         if (mLogNode != null) {
     46             mLogNode.println(priority, tag, msg, tr);
     47         }
     48     }
     49 
     50     /**
     51      * Instructs the LogNode to print the log data provided. Other LogNodes can
     52      * be chained to the end of the LogNode as desired.
     53      *
     54      * @param priority Log level of the data being logged. Verbose, Error, etc.
     55      * @param tag Tag for for the log data. Can be used to organize log statements.
     56      * @param msg The actual message to be logged. The actual message to be logged.
     57      */
     58     public static void println(int priority, String tag, String msg) {
     59         println(priority, tag, msg, null);
     60     }
     61 
     62     /**
     63      * Prints a message at VERBOSE priority.
     64      *
     65      * @param tag Tag for for the log data. Can be used to organize log statements.
     66      * @param msg The actual message to be logged.
     67      * @param tr If an exception was thrown, this can be sent along for the logging facilities
     68      *           to extract and print useful information.
     69      */
     70     public static void v(String tag, String msg, Throwable tr) {
     71         println(VERBOSE, tag, msg, tr);
     72     }
     73 
     74     /**
     75      * Prints a message at VERBOSE priority.
     76      *
     77      * @param tag Tag for for the log data. Can be used to organize log statements.
     78      * @param msg The actual message to be logged.
     79      */
     80     public static void v(String tag, String msg) {
     81         v(tag, msg, null);
     82     }
     83 
     84 
     85     /**
     86      * Prints a message at DEBUG priority.
     87      *
     88      * @param tag Tag for for the log data. Can be used to organize log statements.
     89      * @param msg The actual message to be logged.
     90      * @param tr If an exception was thrown, this can be sent along for the logging facilities
     91      *           to extract and print useful information.
     92      */
     93     public static void d(String tag, String msg, Throwable tr) {
     94         println(DEBUG, tag, msg, tr);
     95     }
     96 
     97     /**
     98      * Prints a message at DEBUG priority.
     99      *
    100      * @param tag Tag for for the log data. Can be used to organize log statements.
    101      * @param msg The actual message to be logged.
    102      */
    103     public static void d(String tag, String msg) {
    104         d(tag, msg, null);
    105     }
    106 
    107     /**
    108      * Prints a message at INFO priority.
    109      *
    110      * @param tag Tag for for the log data. Can be used to organize log statements.
    111      * @param msg The actual message to be logged.
    112      * @param tr If an exception was thrown, this can be sent along for the logging facilities
    113      *           to extract and print useful information.
    114      */
    115     public static void i(String tag, String msg, Throwable tr) {
    116         println(INFO, tag, msg, tr);
    117     }
    118 
    119     /**
    120      * Prints a message at INFO priority.
    121      *
    122      * @param tag Tag for for the log data. Can be used to organize log statements.
    123      * @param msg The actual message to be logged.
    124      */
    125     public static void i(String tag, String msg) {
    126         i(tag, msg, null);
    127     }
    128 
    129     /**
    130      * Prints a message at WARN priority.
    131      *
    132      * @param tag Tag for for the log data. Can be used to organize log statements.
    133      * @param msg The actual message to be logged.
    134      * @param tr If an exception was thrown, this can be sent along for the logging facilities
    135      *           to extract and print useful information.
    136      */
    137     public static void w(String tag, String msg, Throwable tr) {
    138         println(WARN, tag, msg, tr);
    139     }
    140 
    141     /**
    142      * Prints a message at WARN priority.
    143      *
    144      * @param tag Tag for for the log data. Can be used to organize log statements.
    145      * @param msg The actual message to be logged.
    146      */
    147     public static void w(String tag, String msg) {
    148         w(tag, msg, null);
    149     }
    150 
    151     /**
    152      * Prints a message at WARN priority.
    153      *
    154      * @param tag Tag for for the log data. Can be used to organize log statements.
    155      * @param tr If an exception was thrown, this can be sent along for the logging facilities
    156      *           to extract and print useful information.
    157      */
    158     public static void w(String tag, Throwable tr) {
    159         w(tag, null, tr);
    160     }
    161 
    162     /**
    163      * Prints a message at ERROR priority.
    164      *
    165      * @param tag Tag for for the log data. Can be used to organize log statements.
    166      * @param msg The actual message to be logged.
    167      * @param tr If an exception was thrown, this can be sent along for the logging facilities
    168      *           to extract and print useful information.
    169      */
    170     public static void e(String tag, String msg, Throwable tr) {
    171         println(ERROR, tag, msg, tr);
    172     }
    173 
    174     /**
    175      * Prints a message at ERROR priority.
    176      *
    177      * @param tag Tag for for the log data. Can be used to organize log statements.
    178      * @param msg The actual message to be logged.
    179      */
    180     public static void e(String tag, String msg) {
    181         e(tag, msg, null);
    182     }
    183 
    184     /**
    185      * Prints a message at ASSERT priority.
    186      *
    187      * @param tag Tag for for the log data. Can be used to organize log statements.
    188      * @param msg The actual message to be logged.
    189      * @param tr If an exception was thrown, this can be sent along for the logging facilities
    190      *           to extract and print useful information.
    191      */
    192     public static void wtf(String tag, String msg, Throwable tr) {
    193         println(ASSERT, tag, msg, tr);
    194     }
    195 
    196     /**
    197      * Prints a message at ASSERT priority.
    198      *
    199      * @param tag Tag for for the log data. Can be used to organize log statements.
    200      * @param msg The actual message to be logged.
    201      */
    202     public static void wtf(String tag, String msg) {
    203         wtf(tag, msg, null);
    204     }
    205 
    206     /**
    207      * Prints a message at ASSERT priority.
    208      *
    209      * @param tag Tag for for the log data. Can be used to organize log statements.
    210      * @param tr If an exception was thrown, this can be sent along for the logging facilities
    211      *           to extract and print useful information.
    212      */
    213     public static void wtf(String tag, Throwable tr) {
    214         wtf(tag, null, tr);
    215     }
    216 
    217 }