Closed benjaminglatzeder closed 5 years ago
Sorry!
As you know, Couchbase Lite is a multi-platform product. There is absolutely no reason to believe that our internal implementations of the various log levels have anything to do with Android's internal representation of log levels. In fact, it would be completely impossible to do that, for all platforms.
We should probably not put getValue
in the public API. Given that we do, we should document the fact that the number that it provides is utterly useless to client code. ... and, better yet, we should provide a library of useful tools, one of which maps CBLite log levels to their Android equivalents.
Several of these things are under consideration.
In the main time, you should use code like this:
public void log(LogLevel level, LogDomain domain, String message) {
switch (level) {
case DEBUG:
Log.d(domain, message);
break;
case VERBOSE:
Log.v(domain, message);
break;
case INFO:
Log.i(domain, message);
break;
case WARNING:
Log.w(domain, message);
break;
case ERROR:
Log.e(domain, message);
break;
}
}
... which says exactly what you mean to say, about as clearly as it is possible to say it
Setting LogLevel to verbose
Database.log.getConsole().setLevel(LogLevel.VERBOSE);
shows Couchbase logs as INFO logs in Logcat. Setting LogLevel to warningDatabase.log.getConsole().setLevel(LogLevel.WARNING);
hides them completely. Others LogLevels seem to be wrong, too.Constants in Couchbase Lite are:
And Android: https://developer.android.com/reference/android/util/Log.html#DEBUG DEBUG = 3 ERROR = 6 INFO = 4 VERBOSE = 2 WARN = 5
Values might be assigned a different value in native Couchbase Lite module. I did not check this.