Changeset 96

Show
Ignore:
Timestamp:
04/17/06 13:45:06 (3 years ago)
Author:
jlee
Message:

Added more logging and log viewer

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/org/thestaticvoid/iriverter/Converter.java

    r94 r96  
    198198                        commandList.add("xvid"); 
    199199                        commandList.add("-xvidencopts"); 
    200                         commandList.add("bitrate=" + converterOptions.getVideoBitrate() + ":max_bframes=0:profile=sp0"); 
    201                         commandList.add("-ffourcc"); 
    202                         commandList.add("DX50"); 
     200                        commandList.add("bitrate=" + converterOptions.getVideoBitrate() + ":max_bframes=0"); 
    203201                } 
    204202                 
     
    389387                MencoderStreamParser errorStream = null; 
    390388                 
    391                 System.out.print("DEBUG--- Running: ")
     389                String commandStr = ""
    392390                for (int i = 0; i < command.length; i++) 
    393                         System.out.print(command[i] + " ")
    394                 System.out.println(); 
     391                        commandStr += command[i] + " "
     392                Logger.logMessage(commandStr); 
    395393                 
    396394                try { 
  • trunk/src/org/thestaticvoid/iriverter/ConverterUI.java

    r93 r96  
    1919        private CTabFolder tabFolder; 
    2020        private Map profileMenuItems, dimensionsMenuItems; 
    21         private MenuItem convert, playFile, newSingleVideo, newDirectory, newDVD, advancedJobs, manualSplit, joinVideos, moveUp, moveDown, closeJob, closeAllJobs, quit, bitrate, videoSize, panAndScan, advancedOptions, audioSync, automaticallySplit, volume, contents, about; 
     21        private MenuItem convert, playFile, newSingleVideo, newDirectory, newDVD, advancedJobs, manualSplit, joinVideos, moveUp, moveDown, closeJob, closeAllJobs, quit, bitrate, videoSize, panAndScan, advancedOptions, audioSync, automaticallySplit, volume, contents, logViewer, about; 
    2222        private Menu videoSizeMenu; 
    2323        private DropTarget target; 
     
    265265                contents.addSelectionListener(this); 
    266266                 
     267                logViewer = new MenuItem(helpMenu, SWT.PUSH); 
     268                logViewer.setText("&Log Viewer"); 
     269                logViewer.addSelectionListener(this); 
     270                 
     271                new MenuItem(helpMenu, SWT.SEPARATOR); 
     272                 
    267273                about = new MenuItem(helpMenu, SWT.PUSH); 
    268274                about.setText("&About"); 
     
    478484                         
    479485                        new HelpBrowser(index); 
     486                } 
     487                 
     488                if (e.getSource() == logViewer) { 
     489                        if (LogViewer.getSingleton() == null) 
     490                                new LogViewer(); 
     491                        else 
     492                                LogViewer.getSingleton().getShell().setActive(); 
    480493                } 
    481494                 
     
    653666         
    654667        public static void main(String[] args) { 
    655                 ConverterUI ui = new ConverterUI(); 
     668                try { 
     669                        ConverterUI ui = new ConverterUI(); 
     670                } catch (Exception e) { 
     671                        String message = "An unhandled exception occured: " + e.getMessage() + "\n\n"; 
     672                        StackTraceElement[] st = e.getStackTrace(); 
     673                        for (int i = 0; i < st.length; i++) 
     674                                message += st[i] + "\n"; 
     675                         
     676                        MessageBox messageBox = new MessageBox(new Shell(Display.getDefault()), SWT.ICON_ERROR | SWT.OK); 
     677                        messageBox.setText("Error"); 
     678                        messageBox.setMessage(message); 
     679                        messageBox.open(); 
     680                } 
    656681        } 
    657682} 
  • trunk/src/org/thestaticvoid/iriverter/Logger.java

    r85 r96  
    99                try { 
    1010                        output = new PrintWriter(new BufferedWriter(new FileWriter(new File(System.getProperty("user.home") + File.separator + ".iriverter.log")))); 
     11                         
     12                        if (LogViewer.getSingleton() != null) 
     13                                LogViewer.getSingleton().clear(); 
    1114                } catch (IOException e) { 
    1215                        e.printStackTrace(); 
     
    1518         
    1619        public static void logMessage(String message) { 
     20                System.out.println(message); 
     21                 
    1722                if (output == null) 
    1823                        openLogFile(); 
     
    2025                output.println(message); 
    2126                output.flush(); 
     27                 
     28                if (LogViewer.getSingleton() != null) 
     29                        LogViewer.getSingleton().logMessage(message); 
     30        } 
     31         
     32        public static String getLogText() { 
     33                InputStream input = null; 
     34                try { 
     35                        input = new FileInputStream(new File(System.getProperty("user.home") + File.separator + ".iriverter.log")); 
     36                } catch (IOException e) { 
     37                        // empty 
     38                } 
     39                 
     40                String text = ""; 
     41                if (input != null) { 
     42                        int read; 
     43                        byte[] buffer = new byte[4096]; 
     44                        try { 
     45                                while ((read = input.read(buffer)) > -1) 
     46                                        text += new String(buffer, 0, read) + "\n"; 
     47                        } catch (IOException e) { 
     48                                e.printStackTrace(); 
     49                        } 
     50                } 
     51                 
     52                return text; 
    2253        } 
    2354} 
  • trunk/src/org/thestaticvoid/iriverter/MPlayerInfo.java

    r88 r96  
    105105                String output = matcher.group(); 
    106106         
    107                 // originally used String.split() not available in GCJ 
    108                 return Integer.parseInt(output.substring(10, output.indexOf(" titles"))); 
     107                return Integer.parseInt(output.substring(14)); 
    109108        } 
    110109         
  • trunk/src/org/thestaticvoid/iriverter/MencoderStreamParser.java

    r88 r96  
    2626                 
    2727                try {                    
    28                         while ((inputLine = input.readLine()) != null) 
     28                        while ((inputLine = input.readLine()) != null) { 
     29                                if (inputLine.indexOf("Pos:") == -1) 
     30                                        Logger.logMessage(inputLine); 
     31                                 
    2932                                if (inputLine.indexOf("Video stream:") > -1) 
    3033                                        lengthLine = inputLine; 
     34                        } 
    3135                         
    3236                        input.close();