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