If you think the Android project openmidaas-android-app listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code
/*******************************************************************************
* Copyright 2013 SecureKey Technologies Inc.
* /*fromwww.java2s.com*/
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/package org.openmidaas.app.common;
/**
* Simple logging utility class
*/import org.openmidaas.app.Settings;
import android.util.Log;
publicclass Logger{
privatestaticfinalint VERBOSE = 2;
privatestaticfinalint ERROR = 4;
privatestaticfinalint WARNING = 8;
privatestaticfinalint INFO = 16;
privatestaticfinalint DEBUG = 32;
publicstaticvoid error(Class<?> cls, String message) {
log(cls, ERROR, message);
}
publicstaticvoid error(Class<?> cls, Exception e) {
log(cls, ERROR, e.toString());
}
publicstaticvoid verbose(Class<?> cls, String message) {
log(cls, VERBOSE, message);
}
publicstaticvoid verbose(Class<?> cls, Exception e) {
log(cls, VERBOSE, e.toString());
}
publicstaticvoid warn(Class<?> cls, String message) {
log(cls, WARNING, message);
}
publicstaticvoid warn(Class<?> cls, Exception e) {
log(cls, WARNING, e.toString());
}
publicstaticvoid info(Class<?> cls, String message) {
log(cls, INFO, message);
}
publicstaticvoid info(Class<?> cls, Exception e) {
log(cls, INFO, e.toString());
}
publicstaticvoid debug(Class<?> cls, String message) {
log(cls, DEBUG, message);
}
publicstaticvoid debug(Class<?> cls, Exception e) {
log(cls, DEBUG, e.toString());
}
privatestaticvoid log(Class<?> cls, int level, String msg) {
if(shouldLog()) {
switch(level) {
case VERBOSE:
Log.v(cls.getName(), msg);
break;
case ERROR:
Log.e(cls.getName(), msg);
break;
case WARNING:
Log.w(cls.getName(), msg);
break;
case INFO:
Log.i(cls.getName(), msg);
break;
case DEBUG:
Log.d(cls.getName(), msg);
break;
default:
Log.v(cls.getName(), msg);
break;
}
}
}
privatestaticboolean shouldLog() {
return Settings.SHOULD_LOG;
}
}