@Documented @Retention(value=RUNTIME) @Target(value={METHOD,CONSTRUCTOR,TYPE}) public @interface Loggable
Logger.
For example, this load() method produces a log line
on every call:
@Loggable
String load(String resource) throws IOException {
return "something";
}
You can configure the level of logging:
@Loggable(Loggable.DEBUG)
void save(String resource) throws IOException {
// do something
}
Since version 0.7.6, you can specify a maximum execution time limit for
a method. If such a limit is reached a logging message will be issued with
a WARN priority. It is a very convenient mechanism for profiling
applications in production. Default value of a limit is 1 second.
@Loggable(limit = 2)
void save(String resource) throws IOException {
// do something, potentially slow
}
Since version 0.7.14 you can change the time unit for the "limit" parameter. Default unit of measurement is a second:
@Loggable(limit = 200, unit = TimeUnit.MILLISECONDS)
void save(String resource) throws IOException {
// do something, potentially slow
}Logger,
http://www.jcabi.com/jcabi-aspects/| Modifier and Type | Optional Element and Description |
|---|---|
int |
limit
Maximum amount allowed for this method (a warning will be
issued if it takes longer).
|
boolean |
prepend
Method entry moment should be reported as well (by default only
an exit moment is reported).
|
boolean |
trim
Shall we trim long texts in order to make log lines more readable?
|
TimeUnit |
unit
Time unit for the limit.
|
int |
value
Level of logging.
|
public abstract int value
public abstract int limit
public abstract TimeUnit unit
public abstract boolean trim
public abstract boolean prepend
Copyright © 2012-2013 jcabi.com. All Rights Reserved.