1월, 2016의 게시물 표시

[Android] Android 로깅 시 isLoggable() 메서드 사용

아래와 같이 isLoggable 이라는 메서드를 사용하여 원하는 로그를 찍고 싶을 경우 system property 값을 원하는 로그 레벨로 변경해 주거나 local.prop 파일을 생성하여 /data/local.prop 으로 위치시켜야 한다. public static void LOGD(final String tag, String message, Throwable cause) {         if (LOGGING_ENABLED){             if (Log. isLoggable (tag, Log.DEBUG)) {                 Log.d(tag, message, cause);             }         }   } system property 값을 변경해 주는 방법은 다음과 같다. adb shell setprop log.tag.<tag> <log level> myLog 라는 tag 를 debug 레벨에서 찍고 싶다면, console 창에서 아래와 같이 써주면 된다. adb shell setprop lgo.tag. myLog DEBUG * 공식사이트에 나와있는 isLoggable 메서드 관련 설명 public static boolean  isLoggable   ( String  tag, int level) Added in  API level 1 Checks to see whether or not a log for the specified tag is loggable at the specified level. The default level of any tag is set to INFO. This means that any level above and including INFO will be logged. Before you make any calls to a logging method you should check to see if your tag

[Spring] @PropertySource and Environment 사용시 Property 값이 null 로 들어오는 경우

Spring에서 Property 값을 아래와 같이 가져올 수 있다. @Configuration @PropertySource("classpath:myProperties.properties") public class MyConfiguration { @Autowired Environment environment; public DataSource getDataSource(){     dataSource.setDriverClassName(environment.get("jdbc.driverClassName"));     return dataSource; } } 하지만, Autowiring이 늦게 발생하는 경우 environment 에는 값이 없는 상태로 MyConfiguration 의 getDataSource() 메서드가 먼저 실행된다. 일종의 트릭이지만, org.springframwork.context.EnvironmentAware 를 implement 하여 해결할 수 있다. @Configuration @PropertySource("classpath:myProperties.properties") public class MyConfiguration implements EnvironmentAware {  private Environment environment;  @Override  public void setEnvironment(final Environment environment) {   this.environment = environment;  }  public void myMethod() {   final String myPropertyValue = environment.getProperty("myProperty");   // ...   } } refs : http://stackoverflow.com/questions

[SVN] commit fails with “Authorization failed” error

SVN 저장소를 새로 만들어서 소스코드를 업로드하는 중에 다음과 같은 에러가 발생하였다. SVN commit fails with “Authorization failed” error SVN 생성 폴더의 conf/svnserve 에 있는 디렉토리 접근 권한을 설정해 주지 않아서 발생한 문제였다. auth-access = write 설정을 추가하여 해결 하였다.

[Android] Android Local Unit Tests 환경 구성

이미지
Android 앱 개발 시 테스트하는 방법은 두가지가 있다. Instrumented Unit Tests Local Unit Tests 그중 하나인 Local Unit Tests 환경설정을 정리해 본다.  Local Unit Test 는 테스트하고자 하는 코드가 Android System 에 크게 의존적이지 않을 때 사용한다. 환경설정 폴더 생성 : 테스트 코드는 src/test/java 폴더에 위치해야 한다. 프로젝트 구조 build.gradle - dependancies 추가 testCompile  'junit:junit:4.12' testCompile  'org.mockito:mockito-core:1.10.19' testCompile  'org.hamcrest:hamcrest-library:1.1' 테스트 코드 작성 테스트 코드 구조 테스트 실행  안드로디으 스튜디오에 있는  Build Variants 창 클릭  Test Artifact 를 Unit Tests 로 변경   Run 메뉴에서 Unit Test 를 실행 Unit Tests 가 활성화 된 화면 ref : http://developer.android.com/intl/ko/training/testing/unit-testing/local-unit-tests.html