SystemLog
From UrbanWiki
Contents |
[edit] Introduction
SystemLog is an Android service developed at CENS to facilitates collecting logs during deployment of mobile application. The SystemLog client runs as an Android Service on the phone. It defines a simple interface using the Android Interface Definition Language (AIDL). All other applications can send their log messages to SystemLog. SystemLog will augment log messages with information such as date and time and name of the logger application. The log records are kept in the local SQLite database. When SystemLog detects the phone is plugged to external power, it will upload the log records to the right table on sensorbase. Forward your questions to "Hossein Falaki" <falaki at cs [dot] ucla [dot] com>
[edit] Downloading SystemLog
The SystemLog package can be downloaded here. To get the source code: svn co http://urban.cens.ucla.edu/svn/systemlog
To install SystemLog:
- click on this link on your Android browser
- Follow the installation instructions on the phone.
- Restart your phone.
[edit] Application Interface
SystemLog offers five methods in its interface.
- boolean registerLogger (String tag, String dbTable):
Registers the given tag and dbTable name with SystemLog. All logs with the given tag will be uploaded to the corresponding dbTable on sensorbase.org. Making this call is not mandatory. If a tag has not been "registered" with a table, SystemLog will uploads all the logs with that tag to a default table on sensorbase.org
- void debug (String tag, String message):
Used to log a debug-level message.
- void info (String tag, String message):
Used to log an info-level message.
- void warning (String tag, String message):
Used to log a warning-level message.
- void error (String tag, String message):
Used to log a error-level message.
[edit] Logging Through SystemLog
Follow these steps to use SystemLog in your application:
- Download the interface file [ISystemLog.java].
- Save this file under cens/systemlog/ in the src/ directory of your project.
- Add
import cens.systemlog.ISystemLog;to your service or activity class file. - Define a member of type ISystemLog:
private ISystemLog mSystemLog; - Get an instance of the SystemLog service with this call:
mSystemLog = ISystemLog.Stub.asInterface(service); - After this point you can make SystemLog calls on the object that is referenced by mSystemLog.
SystemLog will send the logs to the SystemLog project on sensorbase (ID: 606).
[edit] Log Format
Each log message is a JSON string containing the following fields:
- time_stamp: in milliseconds.
- ver: version number of the log message format
- level: log level. Possible values are: debug, info, warning, error.
- tag: name of the entity that sent the log
- user: IMEI of the phone
- date: human readable date and time
- message: log message in string format.
Example log record:
{"time_stamp":1253823350112,"ver":"1.0","level":"info","message":"Test log message","tag":"MicrobenchmarkActivity","user":"358279013815871","date":"2009-8-24 13:15:50"}

