use of org.glassfish.api.VersionInfo in project Payara by payara.
the class JSONLogFormatter method getProductId.
/**
* Payara can override this to specify product version.
* @return The string value of the product id.
*/
protected String getProductId() {
if (habitat != null) {
VersionInfo version = habitat.getService(VersionInfo.class);
if (productId.isEmpty() && version != null) {
StringBuilder builder = new StringBuilder();
builder.append(version.getAbbreviatedProductName());
builder.append(' ');
builder.append(version.getVersionPrefix());
builder.append(version.getMajorVersion());
builder.append('.');
builder.append(version.getMinorVersion());
productId = builder.toString();
}
}
return productId;
}
use of org.glassfish.api.VersionInfo in project Payara by payara.
the class UniformLogFormatter method getProductId.
/**
* GlassFish can override to specify their product version
*/
protected String getProductId() {
if (habitat != null) {
VersionInfo versionInfo = habitat.getService(VersionInfo.class);
if (productId.isEmpty() && versionInfo != null) {
StringBuilder sb = new StringBuilder();
sb.append(versionInfo.getAbbreviatedProductName());
sb.append(' ');
sb.append(versionInfo.getVersionPrefix());
sb.append(versionInfo.getMajorVersion());
sb.append('.');
sb.append(versionInfo.getMinorVersion());
productId = sb.toString();
}
}
return productId;
}
use of org.glassfish.api.VersionInfo in project Payara by payara.
the class LoggingExclusionTest method initializeLoggingTest.
private void initializeLoggingTest(String excludeFields) throws Exception {
Globals.setDefaultHabitat(serviceLocatorMock);
VersionInfo versionInfo = new VersionInfo() {
@Override
public String getAbbreviatedProductName() {
return ABBREVIATED_PRODUCT;
}
@Override
public String getVersionPrefix() {
return VERSION_PREFIX;
}
@Override
public String getMajorVersion() {
return VERSION_MAJOR;
}
@Override
public String getMinorVersion() {
return VERSION_MINOR;
}
@Override
public String getUpdateVersion() {
return VERSION_UPDATE;
}
};
Mockito.when(serviceLocatorMock.getService(VersionInfo.class)).thenReturn(versionInfo);
File basePath = new File(BASE_PATH);
basePath.mkdirs();
// Add a file handler with UniformLogFormatter
uniformFormatHandler = new FileHandler(ULF_LOG);
uniformFormatHandler.setLevel(Level.FINE);
uniformFormatHandler.setFormatter(new UniformLogFormatter(excludeFields));
// Add a file handler with ODLLogFormatter
odlFormatHandler = new FileHandler(ODL_LOG);
odlFormatHandler.setLevel(Level.FINE);
odlFormatHandler.setFormatter(new ODLLogFormatter(excludeFields));
// Add a file handler with JSONLogFormatter
jsonFormatHandler = new FileHandler(JSON_LOG);
jsonFormatHandler.setLevel(Level.FINE);
jsonFormatHandler.setFormatter(new JSONLogFormatter(excludeFields));
consoleHandler = new ConsoleHandler();
consoleHandler.setFormatter(new UniformLogFormatter(excludeFields));
LOGGER.addHandler(uniformFormatHandler);
LOGGER.addHandler(odlFormatHandler);
LOGGER.addHandler(jsonFormatHandler);
boolean enableConsoleHandler = Boolean.getBoolean(LoggingExclusionTest.class.getName() + ".enableConsoleHandler");
if (enableConsoleHandler) {
LOGGER.addHandler(consoleHandler);
}
LOGGER.setUseParentHandlers(false);
LOGGER.setLevel(Level.FINE);
}
Aggregations