go-playground / log

:green_book: Simple, configurable and scalable Structured Logging for Go.
MIT License
293 stars 21 forks source link

Synchronization #21

Closed Chiiruno closed 6 years ago

Chiiruno commented 6 years ago

but synchronization of the change is still the user's responsibility

Sorry to make another issue, but I just noticed that, and I'm a bit new to Go in general. How would I synchronize the changes in the email handler (or log itself?), for instance? I can't seem to find any way.

deankarn commented 6 years ago

@Chiiruno the best way would probably be to add an RWMutex internally in the email handler unless there is a way to know when the email log will occur.

I'll look at adding this quickly.

deankarn commented 6 years ago

@Chiiruno I'm going to make a single method to change the email config, otherwise, I think that you'll end up with a race in the middle of changing half of your settings.

Chiiruno commented 6 years ago

That would be ideal, I assume you'll probably set the struct options in email.Log, like the following?

email.once.Do(func() {
        email.formatter = email.formatFunc(email)
})

Thank you.

Chiiruno commented 6 years ago

Oh ok, that sounds a lot safer.

deankarn commented 6 years ago

not quite how I'll do it, the formatter will still not be editable.

Chiiruno commented 6 years ago

I saw the pull, thank you for doing that.

deankarn commented 6 years ago

@Chiiruno changes made!