001package Torello.Java.Build; 002 003import static Torello.Java.C.*; 004 005import Torello.Java.*; 006 007import java.io.IOException; 008import java.io.File; 009 010/** 011 * Class used to assist in writing out Log-Information to the file-system during the build process. 012 * 013 * <BR /> 014 * <EMBED CLASS='external-html' DATA-FILE-ID=INTERNAL_CLASS_NOTE> 015 */ 016public class Logs 017{ 018 // ******************************************************************************************** 019 // ******************************************************************************************** 020 // Fields 021 // ******************************************************************************************** 022 // ******************************************************************************************** 023 024 025 // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 026 // The only non-static / instance field 027 // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 028 029 final String LOG_DIR; 030 031 // This is not private, because the actual file-writing is done inside JavaDoc-Upgrader itself 032 static final String S03_UPGRADER = "Stage03-JavaDocUpgrader.log.html"; 033 034 035 // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 036 // All of the Log File-Names 037 // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 038 039 private static final String S01_SB = "Stage01-javac.sb.txt"; 040 private static final String S01_STD_OUT = "Stage01-javac.stdOut.txt"; 041 private static final String S01_STD_ERR = "Stage01-javac.stdErr.txt"; 042 private static final String S02_SB = "Stage02-javadoc.sb.html"; //txt"; 043 private static final String S02_STD_OUT = "Stage02-javadoc.stdOut.txt"; 044 private static final String S02_STD_ERR = "Stage02-javadoc.stdErr.txt"; 045 private static final String S03_SB = "Stage03-Other.log.html"; 046 private static final String S04_TAR_SB = "Stage04-tar.sb.txt"; 047 private static final String S04_JAR_SB = "Stage04-jar.sb.html"; // txt"; 048 private static final String S05_SYNC_JD_SB = "Stage05-sync-JavaDoc.sb.txt"; 049 private static final String S06_SYNC_TAR_JAR_SB = "Stage06-sync-TarJar.sb.txt"; 050 private static final String S08_SMA_SB = "Stage08-SMA.sb.txt"; 051 052 053 // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 054 // Short Printer Helpers 055 // *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 056 057 private static final String MESSAGE_FIRST_HALF = 058 '\n' + 059 Printing.LOG_LINE + '\n' + 060 BCYAN_BKGND + " " + RESET + " Write Stage 0"; 061 062 private static final String MESSAGE_SECOND_HALF = 063 " Logs" + 064 StringParse.nChars(' ', Printing.LEN - "* Write Stage 0x Logs".length() - 1) + 065 BCYAN_BKGND + " " + RESET + '\n' + 066 Printing.LOG_LINE; 067 068 069 // ******************************************************************************************** 070 // ******************************************************************************************** 071 // Constructor 072 // ******************************************************************************************** 073 // ******************************************************************************************** 074 075 076 Logs(final String LOG_DIR) { this.LOG_DIR = LOG_DIR; } 077 078 079 // ******************************************************************************************** 080 // ******************************************************************************************** 081 // Helper Methods 082 // ******************************************************************************************** 083 // ******************************************************************************************** 084 085 086 private String openStars(final int stepNumber) 087 { return MESSAGE_FIRST_HALF + stepNumber + MESSAGE_SECOND_HALF; } 088 089 private void printFileName(String fileName) 090 { 091 fileName = LOG_DIR + fileName; 092 093 System.out.println( 094 BCYAN_BKGND + " " + RESET + " Writing File: " + BYELLOW + fileName + RESET + 095 096 // "* Writing File: ".length() ==> 16 097 // NOTE: The extra '-1' is to put the closing '*' on the last character, not after it! 098 099 StringParse.nChars(' ', Printing.LEN - 16 - 1 - fileName.length()) + 100 BCYAN_BKGND + " " + RESET 101 ); 102 } 103 104 105 // ******************************************************************************************** 106 // ******************************************************************************************** 107 // Primary Log Writing Methods 108 // ******************************************************************************************** 109 // ******************************************************************************************** 110 111 112 void write_S01_LOGS( 113 final String sb, 114 final String stdOut, 115 final String stdErr 116 ) 117 throws IOException 118 { 119 System.out.println(openStars(1)); 120 121 printFileName(S01_SB); 122 FileRW.writeFile(sb, LOG_DIR + S01_SB); 123 124 printFileName(S01_STD_OUT); 125 FileRW.writeFile(stdOut, LOG_DIR + S01_STD_OUT); 126 127 printFileName(S01_STD_ERR); 128 FileRW.writeFile(stdErr, LOG_DIR + S01_STD_ERR); 129 130 System.out.println(Printing.LOG_LINE); 131 System.out.println(); 132 } 133 134 void write_S02_LOGS( 135 String sb, 136 final String stdOut, 137 final String stdErr 138 ) 139 throws IOException 140 { 141 System.out.println(openStars(2)); 142 143 printFileName(S02_SB); 144 sb = C.toHTML(sb, true, true, "Stage 2: javadoc"); 145 FileRW.writeFile(sb, LOG_DIR + S02_SB); 146 147 printFileName(S02_STD_OUT); 148 FileRW.writeFile(stdOut, LOG_DIR + S02_STD_OUT); 149 150 printFileName(S02_STD_ERR); 151 FileRW.writeFile(stdErr, LOG_DIR + S02_STD_ERR); 152 153 System.out.println(Printing.LOG_LINE); 154 System.out.println(); 155 } 156 157 void write_S03_LOGS(String sb) throws IOException 158 { 159 System.out.println(openStars(3)); 160 printFileName(S03_SB); 161 sb = C.toHTML(sb, true, true, "Misc JavaDoc Upgrader Extras"); 162 FileRW.writeFile(sb, LOG_DIR + S03_SB); 163 System.out.println(Printing.LOG_LINE); 164 System.out.println(); 165 } 166 167 void write_S04_LOGS(final String tarLog, String jarLog) throws IOException 168 { 169 System.out.println(openStars(4)); 170 171 printFileName(S04_TAR_SB); 172 FileRW.writeFile(tarLog, LOG_DIR + S04_TAR_SB); 173 174 printFileName(S04_JAR_SB); 175 jarLog = C.toHTML(jarLog, true, true, "Stage 4: jar "); 176 FileRW.writeFile(jarLog, LOG_DIR + S04_JAR_SB); 177 178 System.out.println(Printing.LOG_LINE); 179 System.out.println(); 180 } 181 182 void write_S05_LOG(final String sb) throws IOException 183 { 184 System.out.println(openStars(5)); 185 printFileName(S05_SYNC_JD_SB); 186 FileRW.writeFile(sb, LOG_DIR + S05_SYNC_JD_SB); 187 System.out.println(Printing.LOG_LINE); 188 System.out.println(); 189 } 190 191 void write_S06_LOG(final String sb) throws IOException 192 { 193 System.out.println(openStars(6)); 194 printFileName(S06_SYNC_TAR_JAR_SB); 195 FileRW.writeFile(sb, LOG_DIR + S06_SYNC_TAR_JAR_SB); 196 System.out.println(Printing.LOG_LINE); 197 System.out.println(); 198 } 199 200 void write_S08_LOG(final String sb) throws IOException 201 { 202 System.out.println(openStars(8)); 203 printFileName(S08_SMA_SB); 204 FileRW.writeFile(sb, LOG_DIR + S08_SMA_SB); 205 System.out.println(Printing.LOG_LINE); 206 System.out.println(); 207 } 208}