Interface IRepositoryImportLogger
-
- All Superinterfaces:
org.apache.commons.logging.Log
- All Known Implementing Classes:
Log4JRepositoryImportLogger
public interface IRepositoryImportLogger extends org.apache.commons.logging.Log
* Below is a sample of how to use this class to generate a log file. 1) You must use startJob(OutputStream, ImportPath) to instantiate the log and supply it with an output stream to hold the log and the root folder of the import. 2) Call setCurrentFilePath() each time you start processing a new import file. The log shows the file being imported so it must be registered. 3) Call endJob() when the import is done to log the finish and release resources. If the the import terminates abnormally this call should be in the finally block. Sample code taken from RepositoryImportLogTest FileOutputStream fileStream = new FileOutputStream(outputFile); logger = PentahoSystem.get(IRepositoryImportLogger.class); //You must call this method to start posting the log. logger.startJob(fileStream, "/import/Path"); logger.setCurrentFilePath("/path/file1path"); logger.debug("Some more detail here"); logger.info("Success"); logger.setCurrentFilePath("path/file2path"); //Simulate an exception try { throw new RuntimeException("forced exception"); } catch (Exception e) { logger.error(e); } //End of job logger.endJob();- Author:
- TKafalas
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
debug(String s)
Log debug informationvoid
endJob()
Makes an "End Import Job" log entry and releases memory associated with this log.void
error(Exception e)
Log error informationvoid
error(String s)
Log an error.boolean
hasLogger()
Allows a class to check if an ImportLogger has been instantiated for the current thread.void
info(String s)
Log informational data.void
setCurrentFilePath(String currentFilePath)
Registers the file being worked on.void
startJob(OutputStream outputStream, String importRootPath, org.apache.logging.log4j.Level logLevel)
Initiates an import job.
-
-
-
Method Detail
-
startJob
void startJob(OutputStream outputStream, String importRootPath, org.apache.logging.log4j.Level logLevel)
Initiates an import job. Each call creates a new log associated with the current thread.- Parameters:
outputStream
- Will receive the html content of the logimportRootPath
- The root import dir receiving the importlogLevel
- The log level to be logged.
-
setCurrentFilePath
void setCurrentFilePath(String currentFilePath)
Registers the file being worked on. Each log entry will list the path to the file being processed. Call this method just before processing the next file. It will automatically post a "Start File Import" entry in the log.- Parameters:
currentFilePath
- path to file being imported
-
endJob
void endJob()
Makes an "End Import Job" log entry and releases memory associated with this log.
-
info
void info(String s)
Log informational data. Should be called when the starting a new file and when finishing that file.- Parameters:
s
- The information message to be logged.
-
error
void error(String s)
Log an error.- Parameters:
s
- The Error message to be logged.
-
debug
void debug(String s)
Log debug information- Parameters:
s
- The debug message to be logged
-
error
void error(Exception e)
Log error information- Parameters:
e
- The exception to be logged.
-
hasLogger
boolean hasLogger()
Allows a class to check if an ImportLogger has been instantiated for the current thread.- Returns:
- true if the logger is present.
-
-