author | Da Risk <da_risk@beem-project.com> |
Mon, 15 Jun 2015 20:58:21 +0200 | |
changeset 1067 | 401b33f78a4d |
parent 1001 | ec0c60b581ed |
permissions | -rw-r--r-- |
1001
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
1 |
BEEM : Boost Your Eyes, Ears, and Mouth |
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
2 |
--------------------------------------- |
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
3 |
|
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
4 |
This little document attempt to explain how the Log should be made in Beem. |
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
5 |
|
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
6 |
Logging Usage |
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
7 |
------------- |
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
8 |
|
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
9 |
Before |
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
10 |
Many use of android.utils.Log.* with different LOGTAG. Often it |
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
11 |
uses the class name as a LOGTAG. This cause confusion in logcat because it |
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
12 |
is hard to say for which application the tag is from. |
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
13 |
|
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
14 |
Hopefully now |
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
15 |
The class com.google.android.apps.iosched.util.LogUtils allow to unify the |
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
16 |
Log. |
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
17 |
The method makeLogTag() add a prefix to the tag made by the |
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
18 |
application (current prefix is "Beem-"). |
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
19 |
This class also implement the best practices for log on the Android |
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
20 |
platform. Each Log call is preceed by an isLoggable() call to check if the |
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
21 |
application should do Logging at this LogLevel. |
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
22 |
Also on release build, verbose logs will not be printed. |
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
23 |
The drawback of this is that all logs are not visible by default and require |
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
24 |
little work to make them appears. |
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
25 |
|
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
26 |
Usage of Log levels |
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
27 |
------------------- |
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
28 |
|
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
29 |
VERBOSE: for log messages in low level layers, that should be necessary only |
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
30 |
for the developers. |
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
31 |
|
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
32 |
DEBUG: for log messages which allow to debug the application by retrieving |
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
33 |
info not easilly retrieved and not necessary to the user. |
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
34 |
|
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
35 |
INFO: for log informational message potentially usefull to the the user. |
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
36 |
|
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
37 |
WARNING: to log bad events but handled by the application. The LOGW(TAG, |
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
38 |
"message", exception) is particularly usefull |
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
39 |
|
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
40 |
ERROR: to log fatal error. Typically crash or other unexpected errors. |
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
41 |
|
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
42 |
Showing all logs |
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
43 |
---------------- |
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
44 |
|
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
45 |
As specified in the javadoc for android.util.Log : |
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
46 |
|
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
47 |
The default level of any tag is set to INFO. This means that any level above and including |
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
48 |
INFO will be logged. Before you make any calls to a logging method you should check to see |
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
49 |
if your tag should be logged. You can change the default level by setting a system property: |
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
50 |
'setprop log.tag.<YOUR_LOG_TAG> <LEVEL>' |
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
51 |
Where level is either VERBOSE, DEBUG, INFO, WARN, ERROR, ASSERT, or SUPPRESS. SUPPRESS will |
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
52 |
turn off all logging for your tag. You can also create a local.prop file that with the |
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
53 |
following in it: |
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
54 |
'log.tag.<YOUR_LOG_TAG>=<LEVEL>' |
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
55 |
and place that in /data/local.prop. |
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
56 |
|
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
57 |
Don't forget that your LOG_TAG is prefixed by "Beem-" |
ec0c60b581ed
Add LogUtils to try to unify logging messages
Da Risk <da_risk@beem-project.com>
parents:
diff
changeset
|
58 |