-
Notifications
You must be signed in to change notification settings - Fork 121
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
Allow logging to a file (besides logging to the console) #1023
Comments
I assumed this could be done with common shell tools like |
A problem is that I then need to go parse Maven output/logs in a reliable way. If I just get the problems/output logged by this plugin, in the Also, the aggregate reporter is a Maven plugin executed during the same build, so it would need to read a file that is currently being written, which could also cause problems. And it would mean that whoever/whatever calls the build needs to |
Not saying no outright, but outputting to a file won't work. I want to make sure the feature makes sense in the long term. The main problem is that the current feature is not thought of as a reporting tool, instead, to fail-fast builds. We collect the messages for the latest converted doc and fail if there are any. If you have 10 files, and the first one is the one with errors, that's the only information you are going to get. The motivation was to ensure that if the build succeeds, it contains no errors (based on the configuration). In that regard, you can run My assumptions for that approach were:
I think those still hold. Can you explain more about the writing workflow? I don't mean to be rude, but I don't think the user is writing 3 or 4 pages, running a conversion, and then looking at a xml/json report 🙇 PD: there's some mention of multi-modules, I am not considering that, unless we go the rabbit hole of creating a reporting via maven-site. But that would complicate configuration for users imo. |
Thanks for listing your thoughts on this! Here are some replies to the points you raise:
|
Thanks, I'll have a look. Since it seems ppl use that as validation for local builds I'd not bother with formatting, same output we redirect to console should suffice. This could be a dedicated goal run during
Offtopic, I'd would suggest to give a try to the IDEA plugin. IMO the best experience and includes Antora support. |
Thanks!
We develop plugins for the Eclipse IDE, so we also do our development in the Eclipse IDE. I don't think people want to switch to another IDE just for the documentation. |
I was implementing the changes as a new mojo, and I see I am simply re-implementing the default behavior in a separate Mojo.
I don't see much value. By default, a user can see the file converted and the errors found in it (each error, shows the message and source line). The only things missing are:
The first is something the user can configure (aka, a docs issue), for the later, I am thinking about simply tuning when to fail. With a new
With the following, we can make the build and show all errors. <logHandler>
<outputToConsole>true</outputToConsole>
<failFast>true|false</failFast>
</logHandler> |
Looking for feedback here and taking notes for myself too. My current branch, prints all messages at the end of the conversion process.
For comparison, when not configuring to fail, that is, no
To get the same output, we'd need to buffer all information (log messages and filenames). The downsides are:
|
After doing some tests, I found more cases where no file is provided. |
I tried using a custom log handler. I also removed the In the log handler, I don't know what the Maven project is that is being built. The Java current working directory is the root of the multi-module project. I couldn't figure out how to get the Maven session from the log handler. So, for now I solved that by writing with an Ant taks
I also noticed such cases while testing this. |
Thanks for the effort!
<logHandler>
<outputToConsole>false</outputToConsole>
<failFast>false</failFast> <!-- 👈 the new option -->
<failIf>
<severity>DEBUG</severity>
</failIf>
</logHandler> The output.
I think it covers alls, for human review we don't need a formatted ouput file. |
I found another gotcha. In a multi-module Maven build, if you use AsciiDoctor multiple times, in different projects, still only one instance of the log handler is ever created by AsciiDoctorJ during the entire Maven build. I assumed I could determine the file to write to in the constructor of my log handler, thinking a new one would be created for every use of AsciiDoctor. However, since it is only created once, I have to determine the file to write to for each call to the |
Do you have a full project to reproduce? In theory that should not be possible because each execution creates a new instance of both Asciidoctor and LogHandler. |
Release v3.2.0 is out and should be available in Maven Central in a few minutes. |
I made this small test project: log-handler-test.zip It has a project with a custom log handler. The constructor of this log handler prints Click to expand Maven output
|
I see, AsciidoctorJ uses a ServiceLoader and since both executions run in the same thread it returns the same instance (even when there are two separated Asciidoctor instances) 🤔 I get the expectation is that it should behave the same in both cases (single-thread and parallel) but with the current model, it won't be possible on the plugin side. AsciidoctorJ should provide a way to make it so the
@dhendriks may I ask you to open an issue in AsciidoctorJ? I can join the conversation and add more details if necessary. |
I've created asciidoctor/asciidoctorj#1297. |
According to the documentation at https://docs.asciidoctor.org/maven-tools/latest/plugin/goals/process-asciidoc/#configuration-logHandler, we can configure the
logHandler
. We can configureoutputToConsole
, by setting it totrue
orfalse
. However, I'd like to log to both the console and to a file (to generate a composite report of all problems of various Maven plugins/goals). Could an option namedoutputFile
be added for thelogHandler
, that gives the path to the output file, such that logging is (also) written there?What do you think?
The text was updated successfully, but these errors were encountered: