MFLogger class
MFLogger is a class for logging that provides some enhanced capability such as capturing log calls, package filtering, and log level control at both global and individual package scope.
It also provides a method call to send captured logs to the IBM MobileFirst Platform server.
Log file data is sent to the IBM MobileFirst Platform server when this class's send() method is called and the accumulated log size is greater than zero. When the log data is successfully uploaded, the persisted local log data is deleted.
When this Logger class's capture flag is turned on via setCapture(true) method call, all messages passed through this class's log methods will be persisted to store in the following JSON object format:
{
"timestamp" : "17-02-2013 13:54:27:123", // "dd-MM-yyyy hh:mm:ss:S"
"level" : "ERROR", // FATAL || ERROR || WARN || INFO || LOG || DEBUG || TRACE
"package" : "your_tag", // typically a class name, app name, or JavaScript object name
"msg" : "the message", // a helpful log message
"metadata" : {"hi": "world"}, // (optional) additional JSON metadata, appended via doLog API call
"threadid" : long // (optional) id of the current thread
}
Constructors
Properties
- hashCode → int
-
The hash code for this object. [...]
read-only, inherited
- packageName ↔ String
-
read / write
- runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited
Methods
-
debug(
{String message, Map metadata}) → void -
Logs the
message
atDEBUG
level with any optionalmetadata
-
error(
{String message, Map metadata}) → void -
Logs the
message
atERROR
level with any optionalmetadata
-
info(
{String message, Map metadata}) → void -
Logs the
message
atINFO
level with any optionalmetadata
-
log(
{String message, Map metadata}) → void -
Logs the
message
atVERBOSE
level with any optionalmetadata
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed. [...]
inherited
-
toString(
) → String -
Returns a string representation of this object.
inherited
-
trace(
{String message, Map metadata}) → void -
Logs the
message
atTRACE
level with any optionalmetadata
-
warn(
{String message, Map metadata}) → void -
Logs the
message
atWARN
level with any optionalmetadata
Operators
-
operator ==(
Object other) → bool -
The equality operator. [...]
inherited
Static Methods
-
getCapture(
) → Future< bool> - Returns whether the Logging is enabled or not
-
getLevel(
) → Future< String> - Returns the current Logger level.
-
getMaxFileSize(
) → Future< int> - Returns the current setting for the maximum file size threshold.
-
send(
) → void - Sends the accumulated log data when the persistent log buffer exists and is not empty.
-
setCapture(
{bool flag}) → void - Turns logging on or off globally.
-
setLevel(
{String level}) → void - Sets the level and above at which log messages should be saved/printed.
-
setMaxFileSize(
{int bytes}) → void - Sets the maximum size of the local log file. [...]
-
updateConfigFromServer(
) → void - Reads the log configuration from the Mobile Foundation server and applies it to the logger.