本文整理汇总了Java中org.slf4j.event.Level类的典型用法代码示例。如果您正苦于以下问题:Java Level类的具体用法?Java Level怎么用?Java Level使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Level类属于org.slf4j.event包,在下文中一共展示了Level类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkRole
import org.slf4j.event.Level; //导入依赖的package包/类
private boolean checkRole(Authentication authentication, Object privilege, boolean logPermission) {
String roleKey = getRoleKey(authentication);
if (RoleConstant.SUPER_ADMIN.equals(roleKey)) {
log(logPermission, Level.INFO,
"access granted: privilege={}, role=SUPER-ADMIN, userKey={}",
privilege, getUserKey());
return true;
}
if (!roleService.getRoles(TenantContextUtils.getRequiredTenantKeyValue(tenantContextHolder.getContext()))
.containsKey(roleKey)) {
log(logPermission, Level.ERROR,
"access denied: privilege={}, role={}, userKey={} due to role is missing",
privilege, roleKey, getUserKey());
throw new AccessDeniedException("Access is denied");
}
return false;
}
示例2: handleRequestPost
import org.slf4j.event.Level; //导入依赖的package包/类
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@Timed
public Response handleRequestPost(SamlRequestDto samlRequestDto) {
relayStateValidator.validate(samlRequestDto.getRelayState());
AuthnRequest authnRequest = stringSamlAuthnRequestTransformer.apply(samlRequestDto.getSamlRequest());
SamlValidationResponse signatureValidationResponse = authnRequestSignatureValidator.validate(authnRequest, SPSSODescriptor.DEFAULT_ELEMENT_NAME);
protectiveMonitoringLogger.logAuthnRequest(authnRequest, Direction.INBOUND, signatureValidationResponse.isOK());
if (!signatureValidationResponse.isOK()) {
SamlValidationSpecificationFailure failure = signatureValidationResponse.getSamlValidationSpecificationFailure();
throw new SamlTransformationErrorException(failure.getErrorMessage(), signatureValidationResponse.getCause(), Level.ERROR);
}
SamlAuthnRequestContainerDto samlAuthnRequestContainerDto = new SamlAuthnRequestContainerDto(samlRequestDto.getSamlRequest(), Optional.ofNullable(samlRequestDto.getRelayState()), samlRequestDto.getPrincipalIpAsSeenByFrontend());
SessionId sessionId = sessionProxy.createSession(samlAuthnRequestContainerDto);
return Response.ok(sessionId).build();
}
示例3: log
import org.slf4j.event.Level; //导入依赖的package包/类
private void log(Level level, String format, Object[] argArray) {
switch (level) {
case TRACE:
logger.trace(format, argArray);
break;
case DEBUG:
logger.debug(format, argArray);
break;
case INFO:
logger.info(format, argArray);
break;
case WARN:
logger.warn(format, argArray);
break;
case ERROR:
logger.error(format, argArray);
break;
}
}
示例4: debug_format_argSupplier1
import org.slf4j.event.Level; //导入依赖的package包/类
@Test
public void debug_format_argSupplier1() throws Exception {
lambdaLogger.debug("debug format", () -> "arg1");
verify(lambdaLogger).doLog(eq(null), eq(Level.DEBUG), eq("debug format"), argSuppliersCaptor.capture(), eq(null));
Supplier[] suppliers = argSuppliersCaptor.getValue();
assertThat(suppliers.length).isEqualTo(1);
assertThat(suppliers[0].get()).isEqualTo("arg1");
}
示例5: handle_shouldNotifyPolicyWhenSamlStringCannotBeConvertedToAnElement
import org.slf4j.event.Level; //导入依赖的package包/类
@Test(expected=SamlTransformationErrorException.class)
public void handle_shouldNotifyPolicyWhenSamlStringCannotBeConvertedToAnElement() throws Exception {
final SamlResponseDto samlResponse = new SamlResponseDto("Woooo!");
when(responseUnmarshaller.apply(samlResponse.getSamlResponse())).thenThrow(new SamlTransformationErrorException("not xml", Level.ERROR));
matchingServiceResponseTranslatorService.translate(samlResponse);
// event sink logging is tested in SamlTransformationErrorExceptionMapperTest
}
示例6: error_marker_msgSupplier_throwable
import org.slf4j.event.Level; //导入依赖的package包/类
@Test
public void error_marker_msgSupplier_throwable() throws Exception {
lambdaLogger.error(testMarker, () -> "error message sup", testException);
verify(lambdaLogger).doLog(eq(testMarker), eq(Level.ERROR), msgSupplierCaptor.capture(), eq(testException));
assertThat(msgSupplierCaptor.getValue().get()).isEqualTo("error message sup");
}
示例7: setDebugMode
import org.slf4j.event.Level; //导入依赖的package包/类
public void setDebugMode(boolean on) {
if(on) {
setLoggerLevel("com.paypal.butterfly", Level.DEBUG);
} else {
setLoggerLevel("com.paypal.butterfly", Level.INFO);
}
}
示例8: testVerboseOn
import org.slf4j.event.Level; //导入依赖的package包/类
@Test
public void testVerboseOn() {
Assert.assertNotNull(logbackVerboseConfigurator);
Assert.assertNotNull(loggerContext);
logbackVerboseConfigurator.setDebugMode(true);
Assert.assertTrue(loggerContext.getLogger("com.paypal.butterfly").getLevel() == ch.qos.logback.classic.Level.DEBUG);
}
示例9: testLoggerAsStringAndLogBackLevelAsInfo
import org.slf4j.event.Level; //导入依赖的package包/类
@Test
public void testLoggerAsStringAndLogBackLevelAsInfo() {
Assert.assertNotNull(logbackVerboseConfigurator);
Assert.assertNotNull(loggerContext);
logbackVerboseConfigurator.setLoggerLevel("com.paypal.butterfly.cli", Level.INFO);
Assert.assertTrue(loggerContext.getLogger("com.paypal.butterfly.cli").getLevel() == ch.qos.logback.classic.Level.INFO);
}
示例10: testLoggerAsStringAndLogBackLevelAsInfoWithWrongPackage
import org.slf4j.event.Level; //导入依赖的package包/类
@Test
public void testLoggerAsStringAndLogBackLevelAsInfoWithWrongPackage() {
Assert.assertNotNull(logbackVerboseConfigurator);
Assert.assertNotNull(loggerContext);
logbackVerboseConfigurator.setLoggerLevel("com.paypal.butterfly.cli", Level.INFO);
Assert.assertFalse(loggerContext.getLogger("com.paypal.butterfly.cli.test").getLevel() == ch.qos.logback.classic.Level.INFO);
}
示例11: testLoggerAsStringAndLogBackLevelAsDebug
import org.slf4j.event.Level; //导入依赖的package包/类
@Test
public void testLoggerAsStringAndLogBackLevelAsDebug() {
Assert.assertNotNull(logbackVerboseConfigurator);
Assert.assertNotNull(loggerContext);
logbackVerboseConfigurator.setLoggerLevel("com.paypal.butterfly.cli", Level.DEBUG);
Assert.assertTrue(loggerContext.getLogger("com.paypal.butterfly.cli").getLevel() == ch.qos.logback.classic.Level.DEBUG);
}
示例12: info_marker_format_argSupplier1
import org.slf4j.event.Level; //导入依赖的package包/类
@Test
public void info_marker_format_argSupplier1() throws Exception {
lambdaLogger.info(testMarker, "info format", () -> "arg1");
verify(lambdaLogger).doLog(eq(testMarker), eq(Level.INFO), eq("info format"), argSuppliersCaptor.capture(), eq(null));
Supplier[] suppliers = argSuppliersCaptor.getValue();
assertThat(suppliers.length).isEqualTo(1);
assertThat(suppliers[0].get()).isEqualTo("arg1");
}
示例13: testLoggerAsClassAndLogBackLevelAsInfo
import org.slf4j.event.Level; //导入依赖的package包/类
@Test
public void testLoggerAsClassAndLogBackLevelAsInfo() {
Assert.assertNotNull(logbackVerboseConfigurator);
Assert.assertNotNull(loggerContext);
logbackVerboseConfigurator.setLoggerLevel(this.getClass(), Level.INFO);
Assert.assertTrue(loggerContext.getLogger(this.getClass()).getLevel() == ch.qos.logback.classic.Level.INFO);
}
示例14: testLoggerAsClassAndLogBackLevelAsWarn
import org.slf4j.event.Level; //导入依赖的package包/类
@Test
public void testLoggerAsClassAndLogBackLevelAsWarn() {
Assert.assertNotNull(logbackVerboseConfigurator);
Assert.assertNotNull(loggerContext);
logbackVerboseConfigurator.setLoggerLevel(this.getClass(), Level.WARN);
Assert.assertTrue(loggerContext.getLogger(this.getClass()).getLevel() == ch.qos.logback.classic.Level.WARN);
}
示例15: doLog_format_argSuppliers_enabled
import org.slf4j.event.Level; //导入依赖的package包/类
@Test
public void doLog_format_argSuppliers_enabled() throws Exception {
when(underlyingLogger.isInfoEnabled(testMarker)).thenReturn(true);
lambdaLogger.doLog(testMarker, Level.INFO, "message format", new Supplier<?>[] { () -> "hello", () -> "world" }, testException);
verify(underlyingLogger, times(1)).log(testMarker, FQCN, Level.INFO.toInt(), "message format", new Object[] { "hello", "world" },
testException);
}