-
Notifications
You must be signed in to change notification settings - Fork 507
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
Log messages mixed with formatted code on stdout #2246
Comments
No there are no plans to add a new toggle. But theoretically should should be able to manage this with the logger configuration. Ktlint CLI uses logback classic as logger implementation. If you provide a
Please let me know if you can get it to work and provide some details back so that it can be transformed to a FAQ in the documentation. It would be supercool if you could write that documentation and raise a PR for it. |
Where would you place/refer this file if you installed ktlint with something like |
I have never tried. But with some googling I found that you can pass an option |
Thanks for hearing us. Unfortunately It is quite inconvenient for editor plugins to modify the classpath, and placing a file on the classpath is more complicated still. Stdin->stdout formatting, with logging to stderr, is the easiest and most reliable way to implement editor plugins. The plugin I maintain, Format-All for Emacs, calls out to 80 different formatters all using this convention. It would really help plugin authors if ktlint had robust native support for this use case. It's been years since I wrote any Java code, but I found the following Groovy snippet to do the same thing as the above XML. appender("SystemErr", ConsoleAppender) {
// Enable coloured output.
withJansi = true
encoder(PatternLayoutEncoder) {
pattern = "%blue(%-5level) %green(%logger{35}) - %msg %n"
}
// Redirect output to the System.err.
target = 'System.err'
}
root(DEBUG, ["SystemErr"]) |
Btw, one thing that you can do is to add I will park the issue for now. I see no way to change this behavior in ktlint without affect other use cases. |
Thank you for the tip. We adopted Just to clarify: Adding a |
No that would not interfere. But I see no way how I can implement that in a reasonable way. Ktlint uses I do think it is possible to do so. But to be honest I don't want to spend my time on it. |
When formatting code from stdin to stdout, all log messages should go to stderr. Only the formatted code should go to stdout.
Is there a current or planned way to accomplish this using command line flags?
(Prompted by lassik/emacs-format-all-the-code#237)
The text was updated successfully, but these errors were encountered: