protected static String levelToString(int level) { return LogWriterImpl.levelToString(level); }
/** * Handles the special cases for {@link #levelToString(int)} including * such cases as the SECURITY_LOGGING_PREFIX and an invalid log level. */ private static String levelToStringSpecialCase(int levelWithFlags) { if((levelWithFlags & SECURITY_LOGGING_FLAG) != 0) { //We know the flag is set so XOR will zero it out. int level = levelWithFlags ^ SECURITY_LOGGING_FLAG; return SecurityLogWriter.SECURITY_PREFIX + levelToString(level); } else { //Needed to prevent infinite recursion //This signifies an unknown log level was used return "level-" + String.valueOf(levelWithFlags); } }
public LogLevelConverter() { logLevels = new LinkedHashSet<Completion>(); int[] alllevels = LogWriterImpl.allLevels; for (int level : alllevels) { logLevels.add(new Completion(LogWriterImpl.levelToString(level))); } }
/** * * Fetches the current log level of the singleton log writer. * */ public static String getLogWriterLevel() { return LogWriterImpl.levelToString( logWriter.getLevel() ); } /**
protected void checkSecurityLogLevel(int value) { _checkIfModifiable(SECURITY_LOG_LEVEL_NAME); if (value < MIN_LOG_LEVEL) { throw new IllegalArgumentException( LocalizedStrings.AbstractDistributionConfig_COULD_NOT_SET_0_TO_1_BECAUSE_ITS_VALUE_CAN_NOT_BE_LESS_THAN_2.toLocalizedString( new Object[] { SECURITY_LOG_LEVEL_NAME, LogWriterImpl.levelToString(value), LogWriterImpl.levelToString(MIN_LOG_LEVEL)})); } if (value > MAX_LOG_LEVEL) { throw new IllegalArgumentException( LocalizedStrings.AbstractDistributionConfig_COULD_NOT_SET_0_TO_1_BECAUSE_ITS_VALUE_CAN_NOT_BE_GREATER_THAN_2.toLocalizedString( new Object[] { SECURITY_LOG_LEVEL_NAME, LogWriterImpl.levelToString(value), LogWriterImpl.levelToString(MAX_LOG_LEVEL)})); } }
@Override public String toString() { final SimpleDateFormat timeFormatter = new SimpleDateFormat(LogWriterImpl.FORMAT); java.io.StringWriter sw = new java.io.StringWriter(); PrintWriter pw = new PrintWriter(sw); pw.print('['); pw.print(LogWriterImpl.levelToString(level)); pw.print(' '); pw.print(timeFormatter.format(date)); pw.print(' '); pw.print(connectionName); pw.print(' '); pw.print(sourceId); pw.print("] "); pw.print(message); pw.close(); try { sw.close(); } catch (java.io.IOException ignore) {} return sw.toString(); } }
public String toString() { final SimpleDateFormat timeFormatter = new SimpleDateFormat( LogWriterImpl.FORMAT); java.io.StringWriter sw = new java.io.StringWriter(); PrintWriter pw = new PrintWriter(sw); pw.print('['); pw.print(LogWriterImpl.levelToString(alertLevel)); pw.print(' '); pw.print(timeFormatter.format(msgDate)); pw.print(' '); pw.print(connectionName); pw.print(' '); pw.print(sourceId); pw.print("] "); pw.print(message); pw.close(); try { sw.close(); } catch (java.io.IOException ignore) { } return sw.toString(); }
/** * Sets the loglevel for the provided log writer * @param l the {@link LogWriter} * @param logLevl the new log level as specified in {@link LogWriterImpl} * @return the old log level */ public static int setLogLevel(LogWriter l, int logLevl) { int ret = -1; l.config("PartitionedRegionDUnitTest attempting to set log level on LogWriter instance class:" + l.getClass().getName()); if (l instanceof PureLogWriter) { PureLogWriter pl = (PureLogWriter) l; ret = pl.getLevel(); l.config("PartitiionedRegionDUnitTest forcing log level to " + LogWriterImpl.levelToString(logLevl) + " from " + LogWriterImpl.levelToString(ret)); pl.setLevel(logLevl); } else if (l instanceof AnyLogWriter) { AnyLogWriter al = (AnyLogWriter) l; ret = al.getLevel(); l.config("PartitiionedRegionDUnitTest forcing log level to " + LogWriterImpl.levelToString(logLevl) + " from " + LogWriterImpl.levelToString(ret)); al.setLevel(logLevl); } return ret; }
for (int level : intLogLevels) { if (level >= LogWriterImpl.levelNameToCode(logLevel)) { logLevels.add(LogWriterImpl.levelToString(level).toLowerCase());
public static void logInitMessage(int logLevel, String msg, Throwable t) { final GemFireCacheImpl cache = GemFireCacheImpl.getInstance(); final GemFireCacheImpl.StaticSystemCallbacks sysCb; final LogWriter logger = cache != null ? cache.getLogger() : null; if (logger != null) { logger.info(msg, t); } else if (cache != null && (sysCb = GemFireCacheImpl.getInternalProductCallbacks()) != null) { sysCb.log(LogWriterImpl.levelToString(logLevel), msg, t); } else if (logLevel >= LogWriterImpl.WARNING_LEVEL) { System.out.println("NanoTimer::" + msg); if (t != null) { t.printStackTrace(); } } }
String end = sf.format(enddate); String logLevel = LogWriterImpl.levelToString(LogWriterImpl.INFO_LEVEL);
public void testExportLogs() throws IOException { Date startDate = new Date(System.currentTimeMillis() - 2 * 60 * 1000); SimpleDateFormat sf = new SimpleDateFormat("yyyy/MM/dd"); String start = sf.format(startDate); Date enddate = new Date(System.currentTimeMillis() + 2 * 60 * 60 * 1000); String end = sf.format(enddate); String dir = getCurrentTimeString(); setupForExportLogs(); String logLevel = LogWriterImpl.levelToString(LogWriterImpl.INFO_LEVEL); MiscellaneousCommands misc = new MiscellaneousCommands(); getCache(); Result cmdResult = misc .exportLogsPreprocessing( "./testExportLogs" + dir, null, null, logLevel, false, false, start, end, 1); getLogWriter().info("testExportLogs command result =" + cmdResult); if (cmdResult != null) { String cmdStringRsult = commandResultToString((CommandResult) cmdResult); getLogWriter().info("testExportLogs cmdStringRsult=" + cmdStringRsult); assertEquals(Result.Status.OK, cmdResult.getStatus()); } else { fail("testExportLogs failed as did not get CommandResult"); } FileUtil.delete(new File("./testExportLogs" + dir)); }
public void testExportLogsForMerge() throws IOException { setupForExportLogs(); Date startDate = new Date(System.currentTimeMillis() - 2 * 60 * 1000); SimpleDateFormat sf = new SimpleDateFormat("yyyy/MM/dd"); String start = sf.format(startDate); Date enddate = new Date(System.currentTimeMillis() + 2 * 60 * 60 * 1000); String end = sf.format(enddate); String dir = getCurrentTimeString(); String logLevel = LogWriterImpl.levelToString(LogWriterImpl.INFO_LEVEL); MiscellaneousCommands misc = new MiscellaneousCommands(); getCache(); Result cmdResult = misc .exportLogsPreprocessing( "./testExportLogsForMerge" + dir, null, null, logLevel, false, true, start, end, 1); getLogWriter().info("testExportLogsForMerge command=" + cmdResult); if (cmdResult != null) { String cmdStringRsult = commandResultToString((CommandResult)cmdResult); getLogWriter().info( "testExportLogsForMerge cmdStringRsult=" + cmdStringRsult); assertEquals(Result.Status.OK, cmdResult.getStatus()); } else { fail("testExportLogsForMerge failed as did not get CommandResult"); } FileUtil.delete(new File("./testExportLogsForMerge" + dir)); }
public void testExportLogsForTimeRange1() throws IOException { setupForExportLogs(); Date startDate = new Date(System.currentTimeMillis() - 1 * 60 * 1000); SimpleDateFormat sf = new SimpleDateFormat("yyyy/MM/dd"); String start = sf.format(startDate); Date enddate = new Date(System.currentTimeMillis() + 1 * 60 * 60 * 1000); String end = sf.format(enddate); String dir = getCurrentTimeString(); String logLevel = LogWriterImpl.levelToString(LogWriterImpl.INFO_LEVEL); MiscellaneousCommands misc = new MiscellaneousCommands(); getCache(); Result cmdResult = misc .exportLogsPreprocessing( "./testExportLogsForTimeRange1" + dir, null, null, logLevel, false, false, start, end, 1); getLogWriter().info("testExportLogsForTimeRange1 command result =" + cmdResult); if (cmdResult != null) { String cmdStringRsult = commandResultToString((CommandResult)cmdResult); getLogWriter().info( "testExportLogsForTimeRange1 cmdStringRsult=" + cmdStringRsult); assertEquals(Result.Status.OK, cmdResult.getStatus()); } else { fail("testExportLogsForTimeRange1 failed as did not get CommandResult"); } FileUtil.delete(new File("testExportLogsForTimeRange1" + dir)); }
String dir = getCurrentTimeString(); String logLevel = LogWriterImpl.levelToString(LogWriterImpl.SEVERE_LEVEL);
public void testExportLogsForMember() throws IOException { createDefaultSetup(null); Date startDate = new Date(System.currentTimeMillis() - 2 * 60 * 1000); SimpleDateFormat sf = new SimpleDateFormat("yyyy/MM/dd"); String start = sf.format(startDate); Date enddate = new Date(System.currentTimeMillis() + 2 * 60 * 60 * 1000); String end = sf.format(enddate); final VM vm1 = Host.getHost(0).getVM(1); final String vm1MemberId = (String) vm1.invoke( MiscellaneousCommandsDUnitTest.class, "getMemberId"); String dir = getCurrentTimeString(); String logLevel = LogWriterImpl.levelToString(LogWriterImpl.INFO_LEVEL); MiscellaneousCommands misc = new MiscellaneousCommands(); getCache(); Result cmdResult = misc .exportLogsPreprocessing( "./testExportLogsForMember" + dir, null, vm1MemberId, logLevel, false, false, start, end, 1); getLogWriter().info("testExportLogsForMember command result =" + cmdResult); if (cmdResult != null) { String cmdStringRsult = commandResultToString((CommandResult)cmdResult); getLogWriter().info( "testExportLogsForMember cmdStringRsult=" + cmdStringRsult); assertEquals(Result.Status.OK, cmdResult.getStatus()); } else { fail("testExportLogsForMember failed as did not get CommandResult"); } FileUtil.delete(new File("testExportLogsForMember" + dir)); }
public void disabled_bug47730_testExportLogsForTimeRangeForOnlyStartTime() throws IOException { setupForExportLogs(); Date date = new Date(); date.setTime(System.currentTimeMillis() - 1 * 60 * 1000); SimpleDateFormat sf = new SimpleDateFormat("yyyy/MM/dd/HH:mm"); String s = sf.format(date); String dir = getCurrentTimeString(); String logLevel = LogWriterImpl.levelToString(LogWriterImpl.INFO_LEVEL); MiscellaneousCommands misc = new MiscellaneousCommands(); getCache(); Result cmdResult = misc .exportLogsPreprocessing( "./testExportLogsForTimeRangeForOnlyStartTime" + dir, null, null, logLevel, false, false, s, null, 1); getLogWriter().info("testExportLogsForTimeRangeForOnlyStartTime command result =" + cmdResult); if (cmdResult != null) { String cmdStringRsult = commandResultToString((CommandResult)cmdResult); getLogWriter().info( "testExportLogsForTimeRangeForOnlyStartTime cmdStringRsult=" + cmdStringRsult); assertEquals(Result.Status.OK, cmdResult.getStatus()); } else { fail("testExportLogsForTimeRangeForOnlyStartTime failed as did not get CommandResult"); } FileUtil.delete(new File("testExportLogsForTimeRangeForOnlyStartTime" + dir)); } }
logLevel = LogWriterImpl.levelToString(LogWriterImpl.INFO_LEVEL);
LogWriterImpl.levelToString(distConfig.getLogLevel()); this.logDiskSpaceLimit = distConfig.getLogDiskSpaceLimit(); this.logFileSizeLimit = distConfig.getLogFileSizeLimit();
String str = tab.getString(key, tab.getWild(key, index, null)); if (str == null) { str = LogWriterImpl.levelToString(DistributionConfig.DEFAULT_LOG_LEVEL);