[Title] create skin log file path if not exists
authorSon Hyunjun <hj79.son@samsung.com>
Sat, 17 Mar 2012 19:07:25 +0000 (04:07 +0900)
committerSon Hyunjun <hj79.son@samsung.com>
Sat, 17 Mar 2012 19:07:25 +0000 (04:07 +0900)
[Type] Bugfix
[Module]
[Priority] Minor
[CQ#]
[Redmine#]
[Problem]
[Cause]
[Solution]

Change-Id: I9b97400a5b40d3c6af508b4775f040604c3db4e4

tizen/src/skin/client/src/org/tizen/emulator/skin/log/SkinLogger.java

index 8e345c9..a02683b 100644 (file)
@@ -95,13 +95,30 @@ public class SkinLogger {
                        String path = "";
                        
                        if( !StringUtil.isEmpty( filePath ) ) {
-                               path = filePath;
+                               path = filePath + File.separator;
                        }
+
+                       File dir = new File( path + LOG_FOLDER );
+                       dir.mkdir();
                        
+                       File file = new File( dir + File.separator + FILE_NAME );
+                       if( !file.exists() ) {
+                               try {
+                                       if( !file.createNewFile() ) {
+                                               System.err.println( "[SkinLog:error]Cannot create skin log file. path:" + file.getAbsolutePath() );
+                                               System.exit( -1 );
+                                               return;
+                                       }
+                               } catch ( IOException e ) {
+                                       e.printStackTrace();
+                                       System.exit( -1 );
+                                       return;
+                               }
+                       }
+
                        try {
-                               path = path + File.separator + LOG_FOLDER + File.separator + FILE_NAME;
-                               System.out.println( "[SkinLog]log file path:" + path );
-                               fileHandler = new FileHandler( path, false );
+                               System.out.println( "[SkinLog]log file path:" + file.getAbsolutePath() );
+                               fileHandler = new FileHandler( file.getAbsolutePath(), false );
                        } catch ( SecurityException e1 ) {
                                e1.printStackTrace();
                        } catch ( IOException e1 ) {