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

Improve CaptureLogEvents test logger #256

Closed
keithrbennett opened this issue Dec 25, 2022 · 1 comment
Closed

Improve CaptureLogEvents test logger #256

keithrbennett opened this issue Dec 25, 2022 · 1 comment

Comments

@keithrbennett
Copy link
Contributor

Environment

Ruby version independent
Semantic Logger version 4.12.0

Requested Improvement

The CaptureLogEvents logger for testing is useful, but when I tried to access the events array before any log messages were logged, it was not yet initialized. So I had to do an additional check for nil when accessing the events array.

I suggest initializing the events array in the constructor rather than lazily initializing it in the log method. This way, callers can be guaranteed to get the array whether or not any messages have been logged yet.

Also, in my use of this logger, I found it useful to be able to clear the array of events. I recommend adding a clear method that does this.

@reidmorrison
Copy link
Owner

Merged the pull request

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