Here i show u how to use the Logging.Logger class
// Top of ur .cs file
using AndroidCtrl.Logging;
// Activate the logger
Logger.Instance.Active = true;
// Here u can tell the log writer that it has to write each new log directly to the log-file
Logger.Instance.WriteParts = true;
// Log-file path (by default the file will be generated beside the dll)
Logger.Instance.Path = "C:\\myLogFile.txt";
// Here are the events u can subscribe to, to get the logs in ur progam-code
Logger.Instance.CallbackDebug += CallbackLogger;
Logger.Instance.CallbackError += CallbackLogger;
Logger.Instance.CallbackInfo += CallbackLogger;
Logger.Instance.CallbackOutput += CallbackLogger;
Logger.Instance.CallbackWarning += CallbackLogger;
// This is the callback for all events
public void CallbackLogger(object sender, LoggerArgs e)
{
App.Current.Dispatcher.Invoke((Action)delegate
{
// Do what u want with the log-data "e.Log"
});
}
// Define the log-level (that is a bit tricky but i'll explain)
Logger.Instance.SetLogLevel(IDLog.DEBUG);
// In the above example we "only" define the level "Debug", this will log all events!
// U can also define the log levels like the following examples...
// All events and all outputs
Logger.Instance.SetLogLevel(IDLog.DEBUG, IDLog.OUTPUT);
// This will do the same as the above example
Logger.Instance.SetLogLevel(IDLog.ERROR, IDLog.INFO, IDLog.OUTPUT, IDLog.WARNING);
Simply, u can define a "special" part u want to log, with-/out output or everything that happens. Here is a short explain about the log-levels.
- DEBUG = Logs everything that happens
- ERROR = Log all errors and *hopefully* all exceptions (caused by my dll)
- INFO = Log all calls and sub-call (currently "only" the ProcessModels namespace got he log-writer)
- OUTPUT = Log all outputs
- WARNING = Log all warnings