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

Other file accessors besides appender? #24

Closed
eddelbuettel opened this issue Jun 17, 2019 · 9 comments
Closed

Other file accessors besides appender? #24

eddelbuettel opened this issue Jun 17, 2019 · 9 comments
Assignees

Comments

@eddelbuettel
Copy link

Maybe I am being dense but while

log_appender(appender_file(someFilename))

worked great, I think I'd also like a (trivial) create_file(...) or overwrite_file(). Is there a common idiom in the other logging frameworks?

logger is ❤️ though. Really nice so far.

@daroczig
Copy link
Owner

Sorry, I totally missed this message 😱

Can you please clarify on what create_file or overwrite_file would do?

Currently, appender_file will create the file if not existing yet and append a new line for every log message there. Should overwrite_file truncate it with each new message?

@eddelbuettel
Copy link
Author

Yes, I think I was in "debug mode" and wanted an "overwrite, don't append" mode which did not (does not ?) exist yet. It seems that it is standard POSIX semantics, so should be add a simple "destructive" file accessor?

@daroczig
Copy link
Owner

Thanks for the clarification 👍
#29 is a simple workaround for this ... what do you think?

@eddelbuettel
Copy link
Author

Yes that is close to what I had in mind.

If it were me I'd also add a convenience function with a different name that just calls this one with append=FALSE. Not sure which (if any) name you'd find most useful.

@daroczig
Copy link
Owner

Yeah, you are right -- I tried to keep the appender prefix for all "appender" function names, but there is indeed this case that does not really append ... I guess it's time to give up with that prefix and I will add a helper as suggested above after figuring out the naming bit :)

@daroczig
Copy link
Owner

Okay, so I think this requires dropping the "appender" term from the overall design as well:

image

And the appender piece might be renamed to destination or something similar. This will require us to rename quite a few pieces .. eg the main logger fn will take the current formatter and layout params but destination instead of appender for the last piece, and eg log_appender to be renamed to log_destionation etc. All these taking functions.

I guess that sounds OK?

I mean the formatter piece does sound like something that takes a function, but the layout and destination are not really ... but that's fine I hope. appender in this sense worked better, but as layout was already a bit off in this sense (not really suggesting that it's a function), I think destination works as well.

Sorry for the wall of text ... but after messing up with the original 3-4 terms on which the whole design was built, probably it's better to spend some extra time to do this right after all.

@daroczig
Copy link
Owner

Referencing the main logger to get more clarity on the above: https://github.com/daroczig/logger/blob/master/R/logger.R#L1

@eddelbuettel
Copy link
Author

Didn't mean to imply cascading changes and wholesale renaming. appender_file() is still fine. Maybe just add empty_file() or new_file() ...

@daroczig daroczig self-assigned this Aug 20, 2019
@daroczig
Copy link
Owner

daroczig commented Sep 2, 2019

merging now and will generalize the file appender a bit further at #31

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