roboguice.util
Class Ln
java.lang.Object
roboguice.util.Ln
public class Ln
- extends Object
A more natural android logging facility.
WARNING: CHECK OUT COMMON PITFALLS BELOW
Unlike Log
, Log provides sensible defaults.
Debug and Verbose logging is enabled for applications that
have "android:debuggable=true" in their AndroidManifest.xml.
For apps built using SDK Tools r8 or later, this means any debug
build. Release builds built with r8 or later will have verbose
and debug log messages turned off.
The default tag is automatically set to your app's packagename,
and the current context (eg. activity, service, application, etc)
is appended as well. You can add an additional parameter to the
tag using #Log(String)
.
Log-levels can be programatically overridden for specific instances
using #Log(String, boolean, boolean)
.
Log messages may optionally use String.format(String, Object...)
formatting, which will not be evaluated unless the log statement is output.
Additional parameters to the logging statement are treated as varrgs parameters
to String.format(String, Object...)
Also, the current file and line is automatically appended to the tag
(this is only done if debug is enabled for performance reasons).
COMMON PITFALLS:
* Make sure you put the exception FIRST in the call. A common
mistake is to place it last as is the android.util.Log convention,
but then it will get treated as varargs parameter.
* vararg parameters are not appended to the log message! You must
insert them into the log message using %s or another similar
format parameter
Usage Examples:
Ln.v("hello there");
Ln.d("%s %s", "hello", "there");
Ln.e( exception, "Error during some operation");
Ln.w( exception, "Error during %s operation", "some other");
Field Summary |
protected static Ln.BaseConfig |
config
config is initially set to BaseConfig() with sensible defaults, then replaced
by BaseConfig(Context) during guice static injection pass. |
protected static Ln.Print |
print
print is initially set to Print(), then replaced by guice during
static injection pass. |
Method Summary |
static int |
d(Object s1,
Object... args)
|
static int |
d(Throwable t)
|
static int |
d(Throwable throwable,
Object s1,
Object... args)
|
static int |
e(Object s1,
Object... args)
|
static int |
e(Throwable t)
|
static int |
e(Throwable throwable,
Object s1,
Object... args)
|
static Ln.Config |
getConfig()
|
static int |
i(Object s1,
Object... args)
|
static int |
i(Throwable t)
|
static int |
i(Throwable throwable,
Object s1,
Object... args)
|
static boolean |
isDebugEnabled()
|
static boolean |
isVerboseEnabled()
|
static String |
logLevelToString(int loglevel)
|
static int |
v(Object s1,
Object... args)
|
static int |
v(Throwable t)
|
static int |
v(Throwable throwable,
Object s1,
Object... args)
|
static int |
w(Object s1,
Object... args)
|
static int |
w(Throwable t)
|
static int |
w(Throwable throwable,
Object s1,
Object... args)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
config
@Inject
protected static Ln.BaseConfig config
- config is initially set to BaseConfig() with sensible defaults, then replaced
by BaseConfig(Context) during guice static injection pass.
print
@Inject
protected static Ln.Print print
- print is initially set to Print(), then replaced by guice during
static injection pass. This allows overriding where the log message is delivered to.
v
public static int v(Throwable t)
v
public static int v(Object s1,
Object... args)
v
public static int v(Throwable throwable,
Object s1,
Object... args)
d
public static int d(Throwable t)
d
public static int d(Object s1,
Object... args)
d
public static int d(Throwable throwable,
Object s1,
Object... args)
i
public static int i(Throwable t)
i
public static int i(Object s1,
Object... args)
i
public static int i(Throwable throwable,
Object s1,
Object... args)
w
public static int w(Throwable t)
w
public static int w(Object s1,
Object... args)
w
public static int w(Throwable throwable,
Object s1,
Object... args)
e
public static int e(Throwable t)
e
public static int e(Object s1,
Object... args)
e
public static int e(Throwable throwable,
Object s1,
Object... args)
isDebugEnabled
public static boolean isDebugEnabled()
isVerboseEnabled
public static boolean isVerboseEnabled()
getConfig
public static Ln.Config getConfig()
logLevelToString
public static String logLevelToString(int loglevel)
Copyright © 2011. All Rights Reserved.