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

Removing redundant logging #379

Open
ncatelli opened this issue Apr 12, 2024 · 3 comments
Open

Removing redundant logging #379

ncatelli opened this issue Apr 12, 2024 · 3 comments

Comments

@ncatelli
Copy link
Contributor

ncatelli commented Apr 12, 2024

General

As a follow up to the comment, #374 (comment). I'd like to open this to discuss removing the redundant logging stages.

Currently an output Writer is passed to each of the verify, prepare and publish stages and is used to output some content to the Writer https://github.com/semantic-release-cargo/semantic-release-cargo/blob/master/src/lib.rs#L155-L167. In cases where this is an error output, it makes sense to remove the writer and use the Error returned logging. However, for anything using the logger, ONLY stderr and stdout are supported which will lead to inconsistent logging behavior both with the napi-rs implementation that provides it's own writer, and will not initialize a logger. and with the later stages like publish which output SOME data to the --output provided path, or stdout depending on if that flag is passed.

I would like to open this ticket to provide swapping out the logger with a logger that supports passing a Writer, i.e. fern, so that we can unify the logging into a single place. I would then like to remove the output arguments from each of those stages in lib, and provide a mechanism for both napi-rs and more conventional artifacts to bootstrap the logger with an output file.

Prior to starting this work I wanted to open this issue for feedback.

Summary

  • Replace loggerv with the log-compatible fern
  • Remove the output arguments from the each of the internal verify-conditions, prepare, publish functions
    • potentially remove the forked implementations of each for napi-rs and non-napi
  • Provide functionality to bootstrap the logger both with an output Writer and a consolelog compatible target for napi.
@jwiesler
Copy link

jwiesler commented Apr 13, 2024

Have you thought about how the library use case should be done with a global logger? Replacing the logger in every call to verify, prepare, publish sounds a bit off to me. Furthermore, this is racy and the output is not correct when functions get called concurrently.

@jwiesler
Copy link

And I want to point out again that we are using std::io::stdout in the napi interface but every call to verify, prepare, publish gets stdout and stderr passed in the context parameter, so maybe we should forward these.

@EricCrosson
Copy link
Contributor

  • Replace loggerv with the log-compatible fern

  • Remove the output arguments from the each of the internal verify-conditions, prepare, publish functions

    • potentially remove the forked implementations of each for napi-rs and non-napi
  • Provide functionality to bootstrap the logger both with an output Writer and a consolelog compatible target for napi.

I'm in favor of this direction, especially if we are able to remove forked functions to satisfy napi-rs! It does seem the parameterized writer only aids the current test suite, which can find a better way to check the implementation than comparing log messages.

One ask I would make is to see what we can accomplish without dependencies, which add the risk of increased maintenance burden in the future (that may not be paid in a timely manner). For example, I have been meaning to remove thiserror and even anyhow, as even they come with an unfortunate amount of dependency-update noise and surface area this project doesn't require. If possible, I encourage you to evaluate what a solution without fern might look like, and if it is feasible, think this project would be more stable and future-proofed for the effort.

Thank you for your effort driving these improvements forward -- each milestone is making the project healthier and simpler to use!

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

3 participants