diff --git a/docs/modules/cc_log.rst b/docs/modules/cc_log.rst index 122dfe9c1..167fc4ff6 100644 --- a/docs/modules/cc_log.rst +++ b/docs/modules/cc_log.rst @@ -53,7 +53,7 @@ Synopsis void log_flush(struct logger *logger); - rstatus_i log_reopen(struct logger *logger); + rstatus_i log_reopen(struct logger *logger, char *target); Description ----------- @@ -95,18 +95,18 @@ Flush to file ^^^^^^^^^^^^^ .. code-block:: C - void log_flush(struct logger *logger); + size_t log_flush(struct logger *logger); -``log_flush`` writes as much data to the log file as possible, and updates the (read) marker in the ring buffer. Data that cannot be written to the file will be kept until next call. If the ring buffer or the file was never setup, no action is taken. +``log_flush`` writes as much data to the log file as possible, and updates the (read) marker in the ring buffer. Data that cannot be written to the file will be kept until next call. If the ring buffer or the file was never setup, no action is taken. Return the number of bytes flushed. Log reopen ^^^^^^^^^^ .. code-block:: C - rstatus_i log_reopen(struct logger *logger); + rstatus_i log_reopen(struct logger *logger, char *target); -``log_reopen`` reopens the log file according to ``name``, and does nothing if standard outputs are used. It returns ``CC_OK`` for success or ``CC_ERROR`` if reopen failed (at which point ``logger`` will no longer have a valid ``fd``). +``log_reopen`` reopens the log file according to ``name``, and does nothing if standard outputs are used. It returns ``CC_OK`` for success or ``CC_ERROR`` if reopen failed (at which point ``logger`` will no longer have a valid ``fd``). If ``target`` is specified function will rename original log file to the provided target filename and reopen the log file. This function can be used to reopen the log file when an exception has happened, or another party such as ``logrotate`` instructs the application to do so. Log rotation in a ``nocopytruncate`` manner- i.e. the content in the file is not copied, but the file is simply renamed- is more efficient in high-load systems. But doing so requires signaling the application to reopen the log file after renaming. This function makes it possible to achieve that when used with proper signal handling. diff --git a/docs/modules/cc_metric.rst b/docs/modules/cc_metric.rst index bfc6adad0..d220fd9db 100644 --- a/docs/modules/cc_metric.rst +++ b/docs/modules/cc_metric.rst @@ -111,10 +111,10 @@ Helper functions .. code-block:: C void metric_reset(struct metric sarr[], unsigned int nmetric); - size_t metric_print(char *buf, size_t nbuf, struct metric *m); + size_t metric_print(char *buf, size_t nbuf, char *fmt, struct metric *m); ``metric_reset`` resets the values of an array of metrics. -``metric_print`` prints the name and value of a metric, in human readable format, to buffer ``buf``, with a single space separating the two fields. This simple style is compatible with how Memcached currently reports metrics ([Memcached]_). Helper functions for other formats (e.g. Redis [Redis]_, StatsD [StatsD]_) may be introduced in the future. +``metric_print`` prints the name and value of a metric, in human readable format specified by ``fmt``, to buffer ``buf``. Update diff --git a/docs/modules/cc_option.rst b/docs/modules/cc_option.rst index ecde3dbe6..20ab0c0f0 100644 --- a/docs/modules/cc_option.rst +++ b/docs/modules/cc_option.rst @@ -40,6 +40,7 @@ Data Structure typedef enum option_type { OPTION_TYPE_BOOL, OPTION_TYPE_UINT, + OPTION_TYPE_FPN, OPTION_TYPE_STR, OPTION_TYPE_SENTINEL } option_type_e; @@ -47,6 +48,7 @@ Data Structure typedef union option_val { bool vbool; uintmax_t vuint; + double vfpn; char *vstr; } option_val_u; @@ -59,7 +61,7 @@ Data Structure char *description; }; -The core data structure ``struct option`` has six members. ``name`` and ``description`` help identify and explain the purpose of the option. ``type`` decides how input should be interpreted, which currently can be boolean, unsigned integer or C string. Both the default value and current value are kept around, with values matching the type. Keeping the default separately will make it easy to reset the option to original. Finally, boolean ``set`` tells if an option has been set, and thus usable. +The core data structure ``struct option`` has six members. ``name`` and ``description`` help identify and explain the purpose of the option. ``type`` decides how input should be interpreted, which currently can be boolean, unsigned integer, double or C string. Both the default value and current value are kept around, with values matching the type. Keeping the default separately will make it easy to reset the option to original. Finally, boolean ``set`` tells if an option has been set, and thus usable. Synopsis -------- @@ -71,8 +73,8 @@ Synopsis rstatus_i option_load_file(FILE *fp, struct option options[], unsigned int nopt); void option_print(struct option *opt); - void option_printall(struct option options[], unsigned int nopt); - void option_printall_default(struct option options[], unsigned int nopt); + void option_print_all(struct option options[], unsigned int nopt); + void option_describe_all(struct option options[], unsigned int nopt); void option_free(struct option options[], unsigned int nopt); @@ -118,8 +120,8 @@ Print option info .. code-block:: C void option_print(struct option *opt); - void option_printall(struct option options[], unsigned int nopt); - void option_printall_default(struct option options[], unsigned int nopt); + void option_print_all(struct option options[], unsigned int nopt); + void option_describe_all(struct option options[], unsigned int nopt); Examples