Skip to content

Commit d0ff9f3

Browse files
author
Julia Valchuk
committed
added validation for logger name
1 parent 05b6297 commit d0ff9f3

File tree

9 files changed

+10
-2
lines changed

9 files changed

+10
-2
lines changed
647 Bytes
Binary file not shown.
647 Bytes
Binary file not shown.
647 Bytes
Binary file not shown.
647 Bytes
Binary file not shown.
647 Bytes
Binary file not shown.
647 Bytes
Binary file not shown.
647 Bytes
Binary file not shown.

src/com/backendless/exceptions/ExceptionMessage.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,4 +136,5 @@ public class ExceptionMessage
136136
public final static String NOT_FOUND_PROVIDER = "The provider for tracking location cannot be found. Please check if the permission android.permission.ACCESS_FINE_LOCATION has been added to the application manifest.";
137137

138138
public final static String INVALID_LOG_POLICY = "Either the number of messages or the time frequency must be a positive value";
139+
public final static String INVALID_LOG_NAME = "Log name cannot be empty";
139140
}

src/com/backendless/logging/Logger.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818

1919
package com.backendless.logging;
2020

21+
import com.backendless.exceptions.ExceptionMessage;
22+
2123
/**
2224
* Created by baas on 21.04.15.
2325
*/
@@ -33,6 +35,9 @@ public static Logger getLogger( Class clazz )
3335

3436
public static Logger getLogger( String name )
3537
{
38+
if( name == null || name.trim().isEmpty() )
39+
throw new IllegalArgumentException( ExceptionMessage.INVALID_LOG_NAME );
40+
3641
return new Logger( name );
3742
}
3843

@@ -71,7 +76,8 @@ public void error( String message, Throwable t )
7176
logBufer.enqueue( name, Level.ERROR, message, t );
7277
}
7378

74-
public void fatal( String message ){
79+
public void fatal( String message )
80+
{
7581
logBufer.enqueue( name, Level.FATAL, message, null );
7682
}
7783

@@ -80,7 +86,8 @@ public void fatal( String message, Throwable t )
8086
logBufer.enqueue( name, Level.FATAL, message, t );
8187
}
8288

83-
public void trace( String message ){
89+
public void trace( String message )
90+
{
8491
logBufer.enqueue( name, Level.TRACE, message, null );
8592
}
8693
}

0 commit comments

Comments
 (0)