Repository navigation
Lazily create logging files to avoid creating empty files - #775
niqiangpro-cell wants to merge 3 commits into
Conversation
|
I like the idea of having this be opt-in - any thoughts @swebb2066 ? |
I support the intent of this PR. I don't think empty log files (or directory creation) are useful when they are not used. |
572d66d to
dd232ee
Compare
|
I fixed the compilation error. It looks like the workflows are waiting for maintainer approval. Could you please trigger or approve the CI run? |
| { | ||
| int style = APR_FILEPATH_ENCODING_UNKNOWN; | ||
| apr_filepath_encoding(&style, pool.getAPRPool()); | ||
| char* path = nullptr; |
There was a problem hiding this comment.
This section should be replaced with:
char* path = this->path.getAPRPath();
| { | ||
| m_priv->open(append); | ||
| m_priv->logappend = append; | ||
| m_priv->path = filename; |
There was a problem hiding this comment.
path is assigned in the FileOutputStreamPrivate constructor.
dd232ee to
3055feb
Compare
|
As it stands, this will break MultiprocessRollingFileAppender because it calls FileOutputStream::getFilePtr after a FileOutputStream is created. Please also replace |
swebb2066
left a comment
There was a problem hiding this comment.
Add a comment in the header file that this class assumes a single active thread.
The single active thread guarantee depends on the mutex lock in AppenderSkeleton::doAppend
| { | ||
| FileOutputStreamPrivate(const LogString& filename) | ||
| : path(filename) | ||
| : path(filename), logappend(false) |
There was a problem hiding this comment.
Add a bool append parameter to the constructor
| apr_file_t* fileptr{ nullptr }; | ||
| bool logappend; | ||
| void open(bool append); | ||
| void openAsTruncatedIfAlreadyExists(bool append); |
There was a problem hiding this comment.
Remove the bool append parameters and use this->logAppend in the open methods.
|
So this laziness behavior for log file creation happens through an optional param/setting right ? Thanks. |
Good point. The current PR changes the behavior unconditionally, but I agree that we should preserve the existing behavior by default and make lazy file creation opt-in. I plan to add an optional setting on FileAppender (and derived file-based appenders), as file creation is really an appender concern. I'd be happy to hear any suggestions you may have. |
3055feb to
eadb74f
Compare
commit for issue #745