use of com.emc.vipr.model.sys.logging.LogRequest in project coprhd-controller by CoprHD.
the class LogStreamTest method testSmallFileLevelFilter.
/**
* Test if logs read from LogStream match level specified in LogRequest
*/
@Test
public void testSmallFileLevelFilter() throws Exception {
File file = new File(timeRangeFilePath);
List<File> files = new ArrayList<File>();
files.add(file);
// "WARN"
int level = 5;
LogRequest req = new LogRequest.Builder().logLevel(level).build();
LogStatusInfo status = new LogStatusInfo();
LogFileStream stream = new LogFileStream("", files, req, status);
while (true) {
LogMessage log = stream.readNextLogMessage();
if (log == null) {
break;
}
assertTrue("Log level should match", LogSeverity.toLevel(new String(log.getLevel())) <= level);
}
}
use of com.emc.vipr.model.sys.logging.LogRequest in project coprhd-controller by CoprHD.
the class LogStreamTest method testSmallFilePatternFilter.
/**
* Test if logs read from LogStream match pattern(keywords) specified in
* LogRequest
*/
@Test
public void testSmallFilePatternFilter() throws Exception {
File file = new File(timeRangeFilePath);
List<File> files = new ArrayList<File>();
files.add(file);
String pattern = "reset";
LogRequest req = new LogRequest.Builder().regex(pattern).build();
LogStatusInfo status = new LogStatusInfo();
LogFileStream stream = new LogFileStream("", files, req, status);
while (true) {
LogMessage log = stream.readNextLogMessage();
if (log == null) {
break;
}
assertTrue("log should have the keywords", toStringOriginalFormatStr(log).indexOf(pattern) >= 0);
}
}
use of com.emc.vipr.model.sys.logging.LogRequest in project coprhd-controller by CoprHD.
the class LogStreamTest method testReadNextLogMaxCountFilterGreaterThanMAXCOUNTOVERFLOW.
/**
* Test max count filter totalCount > maxCount + MAX_OVERFLOW
*
* @throws Exception
*/
@Test
@Ignore
public void testReadNextLogMaxCountFilterGreaterThanMAXCOUNTOVERFLOW() throws Exception {
List<File> files = new ArrayList<File>();
files.add(new File(timeStampFilePath));
// should get 16 log Messages
long maxCount = 10;
int count = 0;
LogRequest req = new LogRequest.Builder().maxCont(maxCount).build();
LogStatusInfo status = new LogStatusInfo();
LogFileStream stream = new LogFileStream("", files, req, status);
while (true) {
LogMessage log = stream.readNextLogMessage();
if (log == null) {
System.out.println("count=" + count);
assertEquals("Total line number should match max count limit", 16, count);
break;
}
count++;
}
}
use of com.emc.vipr.model.sys.logging.LogRequest in project coprhd-controller by CoprHD.
the class SendAlertEvent method generateSystemEventFile.
/**
* Gets system events for the parameters entered,
* loads the output to file with name SYSTEM_EVENT_FILE_NAME and returns it.
*/
private String generateSystemEventFile() throws IOException {
// Create the log request info bean from the request data.
LogRequest logReqInfo = new LogRequest.Builder().nodeIds(_nodeIds).baseNames(sysEventlogFileNames).logLevel(_severity).startTime(_start).endTime(_end).regex(_msgRegex).maxCont(maxCount).build();
String fileName = SYSTEM_EVENT_FILE_NAME + getFileExtension();
generateLogFile(logReqInfo, mediaType, SYSTEM_EVENT_FILE_PATH, fileName);
return SYSTEM_EVENT_FILE_PATH;
}
use of com.emc.vipr.model.sys.logging.LogRequest in project coprhd-controller by CoprHD.
the class SendAlertEvent method genAttachFiles.
/**
* Generate the attachments for alerts event
* 1. ovf properties file
* 2. log file for the parameters given
* 3. system events file for the parameters given
*/
@Override
protected ArrayList<String> genAttachFiles() throws Exception {
_log.info("Start SendAlertEvent::genAttachFiles");
// Generate message file
ArrayList<String> fileList = new ArrayList<String>();
// Generate log file
ZipOutputStream outputStream = null;
try {
fileList.add(generateConfigFile());
fileList.add(generateSystemEventFile());
// Create the log request info bean from the request data.
String fileName = SYSTEM_LOGS_FILE_NAME + getFileExtension();
_log.debug("Logs zip entry name {}", fileName);
LogRequest logReqInfo = new LogRequest.Builder().nodeIds(_nodeIds).baseNames(_logNames).logLevel(_severity).startTime(_start).endTime(_end).regex(_msgRegex).maxCont(maxCount).build();
generateLogFile(logReqInfo, mediaType, SYSTEM_LOGS_FILE_PATH, fileName);
fileList.add(SYSTEM_LOGS_FILE_PATH);
} finally {
if (outputStream != null) {
outputStream.close();
}
}
_log.info("Finish SendAlertEvent::genAttachFiles");
return fileList;
}
Aggregations