1 5 package org.exoplatform.services.backup; 6 12 public class ImportLogger { 13 private int numberOfEntry_ ; 14 private int numberOfFail_ ; 15 private StringBuffer buffer_ ; 16 private StringBuffer errorBuffer_ ; 17 18 public ImportLogger() { 19 numberOfEntry_ = 0; 20 numberOfFail_ = 0; 21 buffer_ = new StringBuffer (5000) ; 22 errorBuffer_ = new StringBuffer (1000) ; 23 } 24 25 public void log(String record) { 26 numberOfEntry_++ ; 27 buffer_.append("import record ").append(record).append(" successfully\n"); 28 } 29 30 public void log(String record, Throwable t) { 31 numberOfEntry_++ ; 32 numberOfFail_++ ; 33 errorBuffer_.append("import record ").append(record).append(" fail\n"); 34 } 35 36 public String getTextSummary() { 37 StringBuffer b = new StringBuffer () ; 38 b.append("Number of entry: ").append(numberOfEntry_).append("\n") ; 39 b.append("Number of fail entry: ").append(numberOfFail_).append("\n") ; 40 b.append(buffer_); 41 b.append(errorBuffer_); 42 return b.toString() ; 43 } 44 } | Popular Tags |