Java Code Examples for io.vlingo.actors.Logger#error()
The following examples show how to use
io.vlingo.actors.Logger#error() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Resources.java From vlingo-http with Mozilla Public License 2.0 | 6 votes |
/** * Dispatch the {@code Request} held by the {@code Context} and matching * one of my managed resource instances, or log a warning if no match. * Returns immediately following the non-blocking dispatch. * @param context the Context containing the Request to match * @param logger the Logger to log potential warnings and errors */ void dispatchMatching(final Context context, Logger logger) { String message; try { for (final Resource<?> resource : namedResources.values()) { final MatchResults matchResults = resource.matchWith(context.request.method, context.request.uri); if (matchResults.isMatched()) { final MappedParameters mappedParameters = matchResults.action.map(context.request, matchResults.parameters()); resource.dispatchToHandlerWith(context, mappedParameters); return; } } message = "No matching resource for method " + context.request.method + " and URI " + context.request.uri; logger.warn(message); } catch (Exception e) { message = "Problem dispatching request for method " + context.request.method + " and URI " + context.request.uri + " because: " + e.getMessage(); logger.error(message, e); } context.completes.with(Response.of(Response.Status.NotFound, message)); }
Example 2
Source File: ResourceErrorProcessor.java From vlingo-http with Mozilla Public License 2.0 | 5 votes |
static Response resourceHandlerError(ErrorHandler errorHandler, Logger logger, Exception exception) { Response response; try { logger.error("Exception thrown by Resource execution", exception); response = (errorHandler != null) ? errorHandler.handle(exception) : DefaultErrorHandler.instance().handle(exception); } catch (Exception errorHandlerException) { logger.error("Exception thrown by error handler when handling error", exception); response = defaultErrorResponse(); } return response; }
Example 3
Source File: Slf4jLoggerPluginTest.java From vlingo-actors with Mozilla Public License 2.0 | 5 votes |
@Test public void testStandardLogger() { Logger logger = LoggerProvider.standardLoggerProvider(world, "testStandardLogger").logger(); assertNotNull(logger); assertEquals("testStandardLogger", logger.name()); logger.trace("TRACE message"); logger.trace("TRACE message with parameters {}", "1"); logger.trace("TRACE message with exception", new Exception("test trace exception")); logger.trace("TRACE message with parameter {} and exception", 1, new Exception("test trace exception")); logger.debug("DEBUG message"); logger.debug("DEBUG message with parameters {}", "2"); logger.debug("DEBUG message with exception", new Exception("test debug exception")); logger.debug("DEBUG message with parameter {} and exception", 2, new Exception("test debug exception")); logger.info("INFO message"); logger.info("INFO message with parameters {}", "3"); logger.info("INFO message with exception", new Exception("test info exception")); logger.info("INFO message with parameter {} and exception", 3, new Exception("test info exception")); logger.warn("WARN message"); logger.warn("WARN message with parameters {}", "4"); logger.warn("WARN message with exception", new Exception("test warn exception")); logger.warn("WARN message with parameter {} and exception", 4, new Exception("test warn exception")); logger.error("ERROR message"); logger.error("ERROR message with parameters {}", "5"); logger.error("ERROR message with exception", new Exception("test error exception")); logger.error("ERROR message with parameter {} and exception", 5, new Exception("test error exception")); }