Skip to content

Commit

Permalink
Log the debug and trace messages only if the Logger is set on debug o…
Browse files Browse the repository at this point in the history
…r trace level
  • Loading branch information
giastfader committed Feb 2, 2014
1 parent d79f3c5 commit 91d3e65
Show file tree
Hide file tree
Showing 48 changed files with 345 additions and 345 deletions.
4 changes: 2 additions & 2 deletions app/com/baasbox/configuration/Application.java
Expand Up @@ -43,7 +43,7 @@ public void change(final Object iCurrentValue, final Object iNewValue){
public void setValue(Object newValue) {
Object parsedValue=null;

Logger.debug("New setting value, key: " + this.key + ", type: "+ this.type + ", new value: " + newValue);
if (Logger.isDebugEnabled()) Logger.debug("New setting value, key: " + this.key + ", type: "+ this.type + ", new value: " + newValue);
if (newValue != null)
if (type == Boolean.class)
parsedValue = Boolean.parseBoolean(newValue.toString());
Expand Down Expand Up @@ -71,7 +71,7 @@ public Object getValue() {
IndexApplicationConfiguration idx;
try {
idx = new IndexApplicationConfiguration();
Logger.debug("getting "+key+" from index");
if (Logger.isDebugEnabled()) Logger.debug("getting "+key+" from index");
return idx.get(key);
} catch (Exception e) {
Logger.error("Could not retrieve key " + key, e);
Expand Down
6 changes: 3 additions & 3 deletions app/com/baasbox/configuration/IosCertificateHandler.java
Expand Up @@ -43,7 +43,7 @@ public void change(Object iCurrentValue, Object iNewValue) {
try {
currentValue =new ObjectMapper().readValue(iCurrentValue.toString(), ConfigurationFileContainer.class);
} catch (Exception e) {
Logger.debug("unable to convert value to ConfigurationFileContainer");
if (Logger.isDebugEnabled()) Logger.debug("unable to convert value to ConfigurationFileContainer");
}
}else if (iCurrentValue instanceof ConfigurationFileContainer){
currentValue = (ConfigurationFileContainer)iCurrentValue;
Expand Down Expand Up @@ -95,7 +95,7 @@ public static void init(){
ConfigurationFileContainer prod = Push.PRODUCTION_IOS_CERTIFICATE.getValueAsFileContainer();
ConfigurationFileContainer sandbox = Push.SANDBOX_IOS_CERTIFICATE.getValueAsFileContainer();
if(prod!=null){
Logger.debug("Creating production certificate:"+prod.getName());
if (Logger.isDebugEnabled()) Logger.debug("Creating production certificate:"+prod.getName());
File prodCertificate = new File(Play.application().path().getAbsolutePath()+sep+folder+sep+prod.getName());
if(!prodCertificate.exists()){
try{
Expand All @@ -110,7 +110,7 @@ public static void init(){
}
}
if(sandbox!=null){
Logger.debug("Creating sandbox certificate:"+sandbox.getName());
if (Logger.isDebugEnabled()) Logger.debug("Creating sandbox certificate:"+sandbox.getName());
File sandboxCertificate = new File(Play.application().path().getAbsolutePath()+sep+folder+sep+sandbox.getName());
if(!sandboxCertificate.exists()){
try{
Expand Down
2 changes: 1 addition & 1 deletion app/com/baasbox/configuration/Push.java
Expand Up @@ -40,7 +40,7 @@ public enum Push implements IProperties{
@Override
public void setValue(Object newValue) {
Object parsedValue=null;
Logger.debug("Type:"+type+" Setting "+newValue.toString() + "of class: "+newValue.getClass().toString());
if (Logger.isDebugEnabled()) Logger.debug("Type:"+type+" Setting "+newValue.toString() + "of class: "+newValue.getClass().toString());
try{
if (newValue != null)
if (type == Boolean.class)
Expand Down
44 changes: 22 additions & 22 deletions app/com/baasbox/controllers/Admin.java
Expand Up @@ -110,7 +110,7 @@ public class Admin extends Controller {
static String fileSeparator = System.getProperty("file.separator")!=null?System.getProperty("file.separator"):"/";

public static Result getUsers(){
Logger.trace("Method Start");
if (Logger.isTraceEnabled()) Logger.trace("Method Start");
Context ctx=Http.Context.current.get();
QueryParams criteria = (QueryParams) ctx.args.get(IQueryParametersKeys.QUERY_PARAMETERS);
List<ODocument> users=null;
Expand All @@ -125,13 +125,13 @@ public static Result getUsers(){
}catch (Throwable e){
return internalServerError(ExceptionUtils.getFullStackTrace(e));
}
Logger.trace("Method End");
if (Logger.isTraceEnabled()) Logger.trace("Method End");
response().setContentType("application/json");
return ok(ret);
}

public static Result getUser(String username){
Logger.trace("Method Start");
if (Logger.isTraceEnabled()) Logger.trace("Method Start");
Context ctx=Http.Context.current.get();

ODocument user=null;
Expand All @@ -147,13 +147,13 @@ public static Result getUser(String username){
}catch (Throwable e){
return internalServerError(ExceptionUtils.getFullStackTrace(e));
}
Logger.trace("Method End");
if (Logger.isTraceEnabled()) Logger.trace("Method End");
response().setContentType("application/json");
return ok(ret);
}

public static Result getCollections(){
Logger.trace("Method Start");
if (Logger.isTraceEnabled()) Logger.trace("Method Start");

List<ODocument> result;
String ret="{[]}";
Expand All @@ -172,13 +172,13 @@ public static Result getCollections(){
return internalServerError(ExceptionUtils.getFullStackTrace(e));
}

Logger.trace("Method End");
if (Logger.isTraceEnabled()) Logger.trace("Method End");
response().setContentType("application/json");
return ok(ret);
}

public static Result createCollection(String name) throws Throwable{
Logger.trace("Method Start");
if (Logger.isTraceEnabled()) Logger.trace("Method Start");
try{
CollectionService.create(name);
}catch (CollectionAlreadyExistsException e) {
Expand All @@ -191,7 +191,7 @@ public static Result createCollection(String name) throws Throwable{
Logger.error(ExceptionUtils.getFullStackTrace(e));
throw e;
}
Logger.trace("Method End");
if (Logger.isTraceEnabled()) Logger.trace("Method End");
return created();
}

Expand Down Expand Up @@ -317,11 +317,11 @@ public static Result getRole(String name) throws SqlInjectionException{
/* create user in any role */

public static Result createUser(){
Logger.trace("Method Start");
if (Logger.isTraceEnabled()) Logger.trace("Method Start");
Http.RequestBody body = request().body();

JsonNode bodyJson= body.asJson();
Logger.debug("signUp bodyJson: " + bodyJson);
if (Logger.isDebugEnabled()) Logger.debug("signUp bodyJson: " + bodyJson);

//check and validate input
if (!bodyJson.has("username"))
Expand Down Expand Up @@ -362,17 +362,17 @@ public static Result createUser(){
Logger.error(ExceptionUtils.getFullStackTrace(e));
throw new RuntimeException(e) ;
}
Logger.trace("Method End");
if (Logger.isTraceEnabled()) Logger.trace("Method End");
return created();
}//createUser


public static Result updateUser(String username){
Logger.trace("Method Start");
if (Logger.isTraceEnabled()) Logger.trace("Method Start");
Http.RequestBody body = request().body();

JsonNode bodyJson= body.asJson();
Logger.debug("signUp bodyJson: " + bodyJson);
if (Logger.isDebugEnabled()) Logger.debug("signUp bodyJson: " + bodyJson);

if (!bodyJson.has("role"))
return badRequest("The 'role' field is missing");
Expand Down Expand Up @@ -434,7 +434,7 @@ public static Result updateUser(String username){
if (Play.isDev()) return internalServerError(ExceptionUtils.getFullStackTrace(e));
else return internalServerError(e.getMessage());
}
Logger.trace("Method End");
if (Logger.isTraceEnabled()) Logger.trace("Method End");
return ok(user.toJSON(Formats.USER.toString()));
}//updateUser

Expand All @@ -446,10 +446,10 @@ public static Result updateUser(String username){
* @throws SqlInjectionException
*/
public static Result changePassword(String username) throws SqlInjectionException, UserNotFoundException{
Logger.trace("Method Start");
if (Logger.isTraceEnabled()) Logger.trace("Method Start");
Http.RequestBody body = request().body();
JsonNode bodyJson= body.asJson(); //{"password":"Password"}
Logger.trace("changePassword bodyJson: " + bodyJson);
if (Logger.isTraceEnabled()) Logger.trace("changePassword bodyJson: " + bodyJson);

if (bodyJson==null) return badRequest("The body payload cannot be empty.");
JsonNode passwordNode=bodyJson.findValue("password");
Expand All @@ -463,7 +463,7 @@ public static Result changePassword(String username) throws SqlInjectionExceptio
Logger.error("Username not found " + username, e);
return notFound("Username not found");
}
Logger.trace("Method End");
if (Logger.isTraceEnabled()) Logger.trace("Method End");
return ok();
}

Expand All @@ -481,7 +481,7 @@ public static Result dropUser(){
* @return
*/
public static Result dropCollection(String name){
Logger.trace("Method Start");
if (Logger.isTraceEnabled()) Logger.trace("Method Start");
try {
CollectionService.drop(name);
}catch (SqlInjectionException e){
Expand All @@ -492,7 +492,7 @@ public static Result dropCollection(String name){
Logger.error(ExceptionUtils.getFullStackTrace(e));
return internalServerError(e.getMessage());
}
Logger.trace("Method End");
if (Logger.isTraceEnabled()) Logger.trace("Method End");
response().setContentType("application/json");
return ok();
}
Expand Down Expand Up @@ -551,7 +551,7 @@ public static Result getConfiguration(String section) throws Throwable{

public static Result getLatestVersion() {
String urlToCall="http://www.baasbox.com/version/"+ Internal.INSTALLATION_ID.getValueAsString() + "/";
Logger.debug("Calling " + urlToCall);
if (Logger.isDebugEnabled()) Logger.debug("Calling " + urlToCall);
final Promise<Response> promise = WS.url(urlToCall).get();
return status(promise.get().getStatus(),promise.get().getBody());
}//getLatestVersion
Expand Down Expand Up @@ -754,15 +754,15 @@ public static Result importDb(){
if (version.compareToIgnoreCase("0.6.0")<0){ //we support imports from version 0.6.0
return badRequest(String.format("Current baasbox version(%s) is not compatible with import file version(%s)",BBConfiguration.getApiVersion(),version));
}else{
Logger.debug("Version : "+version+" is valid");
if (Logger.isDebugEnabled()) Logger.debug("Version : "+version+" is valid");
}
}else{
return badRequest("The manifest file does not contain a version number");
}
}else{
return badRequest("Looks like zip file does not contain a manifest file");
}
Logger.debug("Importing: "+fileContent);
if (Logger.isDebugEnabled()) Logger.debug("Importing: "+fileContent);
if(fileContent!=null && StringUtils.isNotEmpty(fileContent.trim())){
DbHelper.importData(appcode, fileContent);
zis.closeEntry();
Expand Down

0 comments on commit 91d3e65

Please sign in to comment.