Skip to content

Commit

Permalink
Merge branch 'master' of github.com:choll/xtr
Browse files Browse the repository at this point in the history
  • Loading branch information
choll committed Apr 23, 2024
2 parents d7dd2bb + d632965 commit 018b0df
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 35 deletions.
30 changes: 15 additions & 15 deletions docs/api.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ <h2 id="L">L</h2>
<li><a href="api.html#_CPPv4N3xtr6loggerE">logger (C++ class)</a>

<ul>
<li><a href="api.html#_CPPv4I0EN3xtr6logger6loggerE21storage_interface_ptrRR5ClockNSt6stringE17log_level_style_t12option_flags">(C++ function)</a>, <a href="api.html#_CPPv4I0EN3xtr6logger6loggerENSt6stringEP4FILERR5ClockNSt6stringE17log_level_style_t12option_flags">[1]</a>, <a href="api.html#_CPPv4I0EN3xtr6logger6loggerEP4FILERR5ClockNSt6stringE17log_level_style_t12option_flags">[2]</a>, <a href="api.html#_CPPv4I0EN3xtr6logger6loggerEPKcRR5ClockNSt6stringE17log_level_style_t12option_flags">[3]</a>
<li><a href="api.html#_CPPv4I0EN3xtr6logger6loggerE21storage_interface_ptrRR5ClockNSt6stringE17log_level_style_t">(C++ function)</a>, <a href="api.html#_CPPv4I0EN3xtr6logger6loggerENSt6stringEP4FILERR5ClockNSt6stringE17log_level_style_t">[1]</a>, <a href="api.html#_CPPv4I0EN3xtr6logger6loggerEP4FILERR5ClockNSt6stringE17log_level_style_t">[2]</a>, <a href="api.html#_CPPv4I0EN3xtr6logger6loggerEPKcRR5ClockNSt6stringE17log_level_style_t">[3]</a>
</li>
</ul></li>
</ul></td>
Expand Down
2 changes: 1 addition & 1 deletion docs/guide.html
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ <h2>Formatting Containers, Tuples and Pairs<a class="headerlink" href="#formatti
fast.</p>
<p><code class="xref cpp cpp-func docutils literal notranslate"><span class="pre">std::chrono::system_clock()</span></code> is used to read the current time, this can
be customised by passing an arbitrary function to the ‘clock’ parameter when
constructing the logger (see <a class="reference internal" href="api.html#_CPPv4I0EN3xtr6logger6loggerEPKcRR5ClockNSt6stringE17log_level_style_t12option_flags" title="xtr::logger::logger"><code class="xref cpp cpp-func docutils literal notranslate"><span class="pre">xtr::logger::logger()</span></code></a>). In these macros</p>
constructing the logger (see <a class="reference internal" href="api.html#_CPPv4I0EN3xtr6logger6loggerEPKcRR5ClockNSt6stringE17log_level_style_t" title="xtr::logger::logger"><code class="xref cpp cpp-func docutils literal notranslate"><span class="pre">xtr::logger::logger()</span></code></a>). In these macros</p>
</section>
<section id="real-time-clock">
<h3>Real-time Clock<a class="headerlink" href="#real-time-clock" title="Link to this heading"></a></h3>
Expand Down
8 changes: 4 additions & 4 deletions docs/libxtr.3
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ The main logger class. When constructed a background thread will be created whic
Public Functions
.INDENT 7.0
.TP
.B template<typename Clock = std::chrono::system_clock> inline explicit logger(const char *path, \fI\%Clock\fP &&clock = \fI\%Clock\fP(), std::string command_path = \fI\%default_command_path\fP(), \fI\%log_level_style_t\fP level_style = \fI\%default_log_level_style\fP, option_flags options = option_flags::none)
.B template<typename Clock = std::chrono::system_clock> inline explicit logger(const char *path, \fI\%Clock\fP &&clock = \fI\%Clock\fP(), std::string command_path = \fI\%default_command_path\fP(), \fI\%log_level_style_t\fP level_style = \fI\%default_log_level_style\fP)
Path constructor. The first argument is the path to a file which should be opened and logged to. The file will be opened in append mode, and will be created if it does not exist. Errors will be written to stdout.
.sp
.INDENT 7.0
Expand All @@ -269,7 +269,7 @@ level_style: The log level style that will be used to prefix each log statement\
.UNINDENT
.INDENT 7.0
.TP
.B template<typename Clock = std::chrono::system_clock> inline explicit logger(FILE *stream = stderr, \fI\%Clock\fP &&clock = \fI\%Clock\fP(), std::string command_path = \fI\%default_command_path\fP(), \fI\%log_level_style_t\fP level_style = \fI\%default_log_level_style\fP, option_flags options = option_flags::none)
.B template<typename Clock = std::chrono::system_clock> inline explicit logger(FILE *stream = stderr, \fI\%Clock\fP &&clock = \fI\%Clock\fP(), std::string command_path = \fI\%default_command_path\fP(), \fI\%log_level_style_t\fP level_style = \fI\%default_log_level_style\fP)
Stream constructor.
.sp
It is expected that this constructor will be used with streams such as stdout or stderr. If a stream that has been opened by the user is to be passed to the logger then the \fI\%stream constructor with reopen path\fP constructor is recommended instead, as this will mean that the log file can be rotated\-\-\-please refer to the xtrctl documentation for the \fI\%reopening log files\fP command for details.
Expand All @@ -295,7 +295,7 @@ Reopening the log file via the \fI\%xtrctl\fP tool is \fInot\fP supported if thi
.UNINDENT
.INDENT 7.0
.TP
.B template<typename Clock = std::chrono::system_clock> inline logger(std::string reopen_path, FILE *stream, \fI\%Clock\fP &&clock = \fI\%Clock\fP(), std::string command_path = \fI\%default_command_path\fP(), \fI\%log_level_style_t\fP level_style = \fI\%default_log_level_style\fP, option_flags options = option_flags::none)
.B template<typename Clock = std::chrono::system_clock> inline logger(std::string reopen_path, FILE *stream, \fI\%Clock\fP &&clock = \fI\%Clock\fP(), std::string command_path = \fI\%default_command_path\fP(), \fI\%log_level_style_t\fP level_style = \fI\%default_log_level_style\fP)
Stream constructor with reopen path.
.sp
.INDENT 7.0
Expand All @@ -321,7 +321,7 @@ Reopening the log file via the \fI\%xtrctl\fP tool is supported, with the reopen
.UNINDENT
.INDENT 7.0
.TP
.B template<typename Clock = std::chrono::system_clock> inline explicit logger(\fI\%storage_interface_ptr\fP storage, \fI\%Clock\fP &&clock = \fI\%Clock\fP(), std::string command_path = \fI\%default_command_path\fP(), \fI\%log_level_style_t\fP level_style = \fI\%default_log_level_style\fP, option_flags options = option_flags::none)
.B template<typename Clock = std::chrono::system_clock> inline explicit logger(\fI\%storage_interface_ptr\fP storage, \fI\%Clock\fP &&clock = \fI\%Clock\fP(), std::string command_path = \fI\%default_command_path\fP(), \fI\%log_level_style_t\fP level_style = \fI\%default_log_level_style\fP)
Custom back\-end constructor (please refer to the \fI\%custom back\-ends\fP section of the user guide for further details on implementing a custom back\-end).
.sp
.INDENT 7.0
Expand Down
Binary file modified docs/objects.inv
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/searchindex.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/xtrctl.html
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ <h3>Setting Log Levels<a class="headerlink" href="#setting-log-levels" title="Li
<p>Please refer to the documentation for <a class="reference internal" href="api.html#_CPPv4N3xtr20default_command_pathEv" title="xtr::default_command_path"><code class="xref cpp cpp-func docutils literal notranslate"><span class="pre">xtr::default_command_path()</span></code></a> in
the API reference or <strong>libxtr</strong>(3) for an explanation of how the default
socket path is constructed. Custom command paths may be specified either by
passing an argument to <a class="reference internal" href="api.html#_CPPv4I0EN3xtr6logger6loggerEPKcRR5ClockNSt6stringE17log_level_style_t12option_flags" title="xtr::logger::logger"><code class="xref cpp cpp-func docutils literal notranslate"><span class="pre">xtr::logger::logger()</span></code></a> or by calling
passing an argument to <a class="reference internal" href="api.html#_CPPv4I0EN3xtr6logger6loggerEPKcRR5ClockNSt6stringE17log_level_style_t" title="xtr::logger::logger"><code class="xref cpp cpp-func docutils literal notranslate"><span class="pre">xtr::logger::logger()</span></code></a> or by calling
<a class="reference internal" href="api.html#_CPPv4N3xtr6logger16set_command_pathENSt6stringE" title="xtr::logger::set_command_path"><code class="xref cpp cpp-func docutils literal notranslate"><span class="pre">xtr::logger::set_command_path()</span></code></a>, the documentation for both may also
be found in the API reference or <strong>libxtr</strong>(3).</p>
</section>
Expand Down
42 changes: 30 additions & 12 deletions single_include/xtr/logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2948,6 +2948,12 @@ class xtr::logger
#endif

public:
enum class option_flags
{
none,
disable_worker_thread
};

/**
* Path constructor. The first argument is the path to a file which
* should be opened and logged to. The file will be opened in append mode,
Expand Down Expand Up @@ -2982,7 +2988,8 @@ class xtr::logger
const char* path,
Clock&& clock = Clock(),
std::string command_path = default_command_path(),
log_level_style_t level_style = default_log_level_style) :
log_level_style_t level_style = default_log_level_style,
option_flags options = option_flags::none) :
logger(
make_fd_storage(path),
std::forward<Clock>(clock),
Expand Down Expand Up @@ -3021,7 +3028,8 @@ class xtr::logger
FILE* stream = stderr,
Clock&& clock = Clock(),
std::string command_path = default_command_path(),
log_level_style_t level_style = default_log_level_style) :
log_level_style_t level_style = default_log_level_style,
option_flags options = option_flags::none) :
logger(
make_fd_storage(stream, null_reopen_path),
std::forward<Clock>(clock),
Expand Down Expand Up @@ -3058,7 +3066,8 @@ class xtr::logger
FILE* stream,
Clock&& clock = Clock(),
std::string command_path = default_command_path(),
log_level_style_t level_style = default_log_level_style) :
log_level_style_t level_style = default_log_level_style,
option_flags options = option_flags::none) :
logger(
make_fd_storage(stream, std::move(reopen_path)),
std::forward<Clock>(clock),
Expand Down Expand Up @@ -3093,15 +3102,19 @@ class xtr::logger
storage_interface_ptr storage,
Clock&& clock = Clock(),
std::string command_path = default_command_path(),
log_level_style_t level_style = default_log_level_style)
{
consumer_ = jthread(
&detail::consumer::run,
std::make_unique<detail::consumer>(
detail::buffer(std::move(storage), level_style),
&control_,
std::move(command_path)),
make_clock(std::forward<Clock>(clock)));
log_level_style_t level_style = default_log_level_style,
option_flags options = option_flags::none)
{
if (options != option_flags::disable_worker_thread)
{
consumer_ = jthread(
&detail::consumer::run,
std::make_unique<detail::consumer>(
detail::buffer(std::move(storage), level_style),
&control_,
std::move(command_path)),
make_clock(std::forward<Clock>(clock)));
}
control_.open_ = true;
(void)detail::get_tsc_hz();
}
Expand Down Expand Up @@ -3162,6 +3175,11 @@ class xtr::logger
*/
void set_default_log_level(log_level_t level);

/**
*
*/
void process_some_log_events();

private:
template<typename Func>
void post(Func&& f)
Expand Down

0 comments on commit 018b0df

Please sign in to comment.