Skip to content

Commit

Permalink
Fix docs (#200)
Browse files Browse the repository at this point in the history
* Fix doc cc_log

- update docs with changes introduced in commits: fe26565 b676f75

* Fix doc cc_option

- update docs with changes introduced in commits: c6baec1 edbb2d2

* Fix doc cc_metric

- update docs with changes introduced in commit 0e12282
  • Loading branch information
michalbiesek authored and Yao Yue committed Jul 20, 2019
1 parent e58f6a8 commit 236c98d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
10 changes: 5 additions & 5 deletions docs/modules/cc_log.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
-----------
Expand Down Expand Up @@ -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.

Expand Down
4 changes: 2 additions & 2 deletions docs/modules/cc_metric.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 7 additions & 5 deletions docs/modules/cc_option.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ Data Structure
typedef enum option_type {
OPTION_TYPE_BOOL,
OPTION_TYPE_UINT,
OPTION_TYPE_FPN,
OPTION_TYPE_STR,
OPTION_TYPE_SENTINEL
} option_type_e;
typedef union option_val {
bool vbool;
uintmax_t vuint;
double vfpn;
char *vstr;
} option_val_u;
Expand All @@ -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
--------
Expand All @@ -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);
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 236c98d

Please sign in to comment.