use of java.util.logging.LogRecord in project OpenAM by OpenRock.
the class FedletLogger method access.
/**
* Writes access to a component into a log.
* @param level indicating log level
* @param messageId Message id
* @param data string array of dynamic data only known during run time
* @param session Session object (it could be null)
* @param props representing log record columns
* @exception LogException if there is an error.
*/
public void access(Level level, String messageId, String[] data, Object session, Map props) throws LogException {
if (isAccessLoggable(level)) {
LogRecord lr = new LogRecord(level, formatMessage(messageId, data, session));
accessLogger.log(lr);
}
}
use of java.util.logging.LogRecord in project voltdb by VoltDB.
the class JdkLogger method log.
/**
* Log the message at the specified level with the specified throwable if any.
* This method creates a LogRecord and fills in caller date before calling
* this instance's JDK14 logger.
*
* See bug report #13 for more details.
*/
private void log(String callerFQCN, Level level, String msg, Throwable t) {
// millis and thread are filled by the constructor
LogRecord record = new LogRecord(level, msg);
record.setLoggerName(name());
record.setThrown(t);
fillCallerData(callerFQCN, record);
logger.log(record);
}
use of java.util.logging.LogRecord in project ACS by ACS-Community.
the class AcsJException method createSingleErrorTraceLogRecord.
/**
* Creates a {@link LogRecord} with the data from the given {@link ErrorTrace} object.
* Some data such as thread name, line of code, user-defined properties etc which do not correspond to any
* field of <code>LogRecord</code> are stored inside a <code>Map</code> that is set as a parameter of the <code>LogRecord</code>.
* Later when the ACS logging system will process this <code>LogRecord</code>, it will recognize the special data
* and turn them into the XML attributes of elements like <Debug>
* @param et the ErrorTrace input object
* @param stackID the stackID that must be the same for all linked <code>ErrorTrace</code> objects.
* @param stackLevel 0-based index for LogRecords from an ErrorTrace chain.
* @return the LogRecord that contains the data from the input parameters.
*/
LogRecord createSingleErrorTraceLogRecord(ErrorTrace et, String stackID, int stackLevel) {
Level logLevel = ErrorTraceLogLevels.mapErrorLevelToLogLevel(et.severity);
String message = et.shortDescription.trim();
message += " (type=" + et.errorType + ", code=" + et.errorCode + ")";
String usermessage = ErrorTraceManipulator.getProperty(et, CorbaExceptionConverter.PROPERTY_JAVAEXCEPTION_MESSAGE);
if (usermessage != null && usermessage.trim().length() > 0) {
message += " :: " + usermessage.trim();
}
// need to explicitly construct a log record with the historical data (normal Logger methods would not allow setting these fields)
LogRecord logRec = new LogRecord(logLevel, message);
logRec.setMillis(UTCUtility.utcOmgToJava(et.timeStamp));
logRec.setSourceClassName(et.file);
logRec.setSourceMethodName(et.routine);
// the SourceObject will be derived from the logger name in AcsXMLLOgFormatter
logRec.setLoggerName(et.sourceObject);
// other fields are encoded in a map and will be extracted by the AcsXMLLOgFormatter before sending the log record over the wire
// Due to build order problems we can't call LogParameterUtil#createPropertiesMap(), but instead have to repeat that code here;
// the same is true for the property names which would be available as String constants of LogParameterUtil.
Map<String, Object> specialLogProperties = new HashMap<String, Object>();
specialLogProperties.put("isAcsPropertiesMap", Boolean.TRUE);
specialLogProperties.put("Line", new Long(et.lineNum));
specialLogProperties.put("ThreadName", et.thread);
specialLogProperties.put("HostName", et.host);
// logProperties.put("Context", "???");
specialLogProperties.put("StackId", stackID);
specialLogProperties.put("StackLevel", new Long(stackLevel));
specialLogProperties.put("ProcessName", et.process);
specialLogProperties.put("SourceObject", et.sourceObject);
// non-standard properties from ErrorTrace
Map etProperties = ErrorTraceManipulator.getProperties(et);
etProperties.remove(CorbaExceptionConverter.PROPERTY_JAVAEXCEPTION_CLASS);
etProperties.remove(CorbaExceptionConverter.PROPERTY_JAVAEXCEPTION_MESSAGE);
// set both maps as log parameters. By design there can't be any other parameters which would be lost here
logRec.setParameters(new Object[] { specialLogProperties, etProperties });
return logRec;
}
use of java.util.logging.LogRecord in project ACS by ACS-Community.
the class MaciSupervisorTest method setUp.
@Override
public void setUp() throws Exception {
System.out.println("\n--- " + getName() + " ----------------");
// make the manager
// -----------------------------------------------------------------
orb = Mockito.mock(ORB.class);
manager = Mockito.mock(Manager.class);
administrator = Mockito.mock(Administrator.class);
final int hhhhh = 0;
final int[] empty = new int[] {};
ComponentInfo comp100 = new ComponentInfo("type", "code", null, "comp100", empty, 10, "cont10", 100, 0, new String[] {});
ComponentInfo comp200 = new ComponentInfo("type", "code", null, "comp200", empty, 20, "cont20", 200, 0, new String[] {});
ComponentInfo comp300 = new ComponentInfo("type", "code", null, "comp300", empty, 30, "cont30", 300, 0, new String[] {});
ComponentInfo[] one_comp = { comp100 };
ComponentInfo[] two_comps = { comp100, comp200 };
ComponentInfo[] three_comps = { comp100, comp200, comp300 };
ContainerInfo cont10 = new ContainerInfo("cont10", 10, null, empty);
ContainerInfo cont20 = new ContainerInfo("cont20", 20, null, empty);
ContainerInfo cont30 = new ContainerInfo("cont30", 30, null, empty);
ContainerInfo[] one_cont = { cont10 };
ContainerInfo[] two_conts = { cont10, cont20 };
ContainerInfo[] three_conts = { cont10, cont20, cont30 };
ClientInfo clientA = new ClientInfo(0, null, empty, "clientA", 0);
ClientInfo client1 = new ClientInfo(1, null, empty, "client1", 0);
ClientInfo client2 = new ClientInfo(2, null, empty, "client2", 0);
ClientInfo client3 = new ClientInfo(3, null, empty, "client3", 0);
ClientInfo[] one_client = { client1 };
ClientInfo[] two_clients = { client1, client2 };
ClientInfo[] three_clients = { client1, client2, client3 };
Mockito.when(orb.string_to_object("dummy")).thenReturn(manager);
Mockito.when(manager.login(administrator)).thenReturn(clientA);
Mockito.when(manager.get_component_info(hhhhh, empty, "*", "*", false)).thenReturn(one_comp, two_comps, three_comps);
Mockito.when(manager.get_container_info(hhhhh, empty, "*")).thenReturn(one_cont, one_cont, two_conts, three_conts);
Mockito.when(manager.get_client_info(hhhhh, empty, "*")).thenReturn(one_client, two_clients, three_clients, two_clients, three_clients);
// make the supervisor
// -----------------------------------------------------------------
log = new Logger("Test", null) {
final long start = System.nanoTime();
@Override
public void log(LogRecord r) {
long sinceStart = (System.nanoTime() - start) / 1000 / 1000 / 1000;
System.out.println(String.format("%2d", sinceStart) + " " + r.getLevel() + " " + r.getMessage());
}
};
log.setLevel(Level.FINE);
testee = new MaciSupervisor("Test", "dummy", orb, log);
testee.acImpl = testee.new AdministratorImplementation() {
@Override
protected Administrator asCorbaObject(ORB orb) {
return administrator;
}
};
testee.start();
// assertions
// ----------------------------------------------------------------
maciListener = new MaciInfoListener();
MaciInfo maciInformation = testee.getMaciInformation();
maciInformation.addTreeModelListener(maciListener);
}
use of java.util.logging.LogRecord in project ACS by ACS-Community.
the class AcsLoggingHandler method configureLogging.
/**
* Called whenever the logging configuration is updated, for example when the CDB is read.
* @see alma.acs.logging.config.LogConfigSubscriber#configureLogging(alma.acs.logging.config.LogConfig)
*/
public void configureLogging(LogConfig logConfig) {
// we expect always the same singleton object, but there is no reason for this class to rely on this
// or even assert this behavior. Instead we just update our reference.
this.logConfig = logConfig;
// this handler still needs to filter out log records whose levels are in between the thresholds.
try {
AcsLogLevelDefinition minLogLevelACS = AcsLogLevelDefinition.fromXsdLogLevel(logConfig.getNamedLoggerConfig(loggerName).getMinLogLevel());
setLevel(AcsLogLevel.getLowestMatchingJdkLevel(minLogLevelACS));
immediateDispatchLevel = logConfig.getImmediateDispatchLevel();
} catch (Exception ex) {
publish(new LogRecord(Level.WARNING, "Failed to configure remote log handler: " + ex.toString()));
}
}
Aggregations