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

Unhandled Exception: Invalid argument(s): Logger has already been closed #130

Open
vadrian89 opened this issue Mar 21, 2022 · 1 comment

Comments

@vadrian89
Copy link

vadrian89 commented Mar 21, 2022

Hello,

Is there any way to test if the Logger was closed or not?
Making the instance variable nullable and then using null-aware operator ?. to access it's methods doesn't work.

I am logging API requests and this happens when the repository object is closed, because sometimes the connection is still up when this happens, but the Logger object is closed alread.y

This is how I clean up my repository object:

Future<void> close() async {
    _logger?.i("Closing repository $this");
    dio?.close(force: true);
    await _resultStreamController.close();
    _logger?.close();
  }

As you can see I force close the dio client yet I still get an exception.

It would be helpful if there would be a public getter for "_active" variable.

@haarts
Copy link
Collaborator

haarts commented Jun 3, 2022

The _active field is indeed private.

But I am not sure when this exception is called. You call in your code close somewhere and a bit further down you call a method on the global _logger, is that right?

I would move to suggest that it is that flow that is not optimal.

Bungeefan added a commit to SourceHorizon/logger that referenced this issue Feb 25, 2023
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

2 participants