Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is printing a log a time-consuming operation? #1

Open
ziqiangai opened this issue Jun 22, 2020 · 0 comments
Open

Is printing a log a time-consuming operation? #1

ziqiangai opened this issue Jun 22, 2020 · 0 comments

Comments

@ziqiangai
Copy link

I just constructed the log object in vertxroute under the quarkus IO thread project, and entered a word in the greetings method, which reduced the throughput of the program by nearly ten times.
Is my way of logging incorrect?

@Singleton
public class VertxRoute{
    private static final Logger logger = LoggerFactory.getLogger(VertxRoute.class);
    @Inject
    Validator validator;

    final MessageService messageService;

    public VertxRoute(MessageService messageService) {
        this.messageService = messageService;
    }

    @Route(path = "/hello/:name", methods = HttpMethod.GET)
    void greetings(RoutingExchange ex) {
        logger.info("receive");
        Set<ConstraintViolation<RequestWrapper>> violations = validator.validate(new RequestWrapper(ex.getParam("name").get()));
        if( violations.size() == 0) {
            ex.ok(messageService.sayHello(ex.getParam("name").orElse("world")));
        } else {
            StringBuilder vaidationError = new StringBuilder();
            violations.stream().forEach(violation -> vaidationError.append(violation.getMessage()));
            ex.response().setStatusCode(400).end(vaidationError.toString());
        }
    }

 ....
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant