= LogC Argp programmers guide

This document describes usage of Argp based parser for LogC. This is dedicated
library extension. It is intentionally separate to not add unnecessary dependency
on Argp when user is going to use different argument parser. Note that probably
only GNU Lib C provides Argp and in other cases external standalone Argp library
is required.


== Provided options

Basic::
- `--verbose` / `-v` Increases log verbosity by one.
- `--quiet` / `-q` Decreases log verbosity by one.
- `--log-level level` Sets log verbosity to specified `level`.
- `--log-file file` Sends logs to specified `file`.

Application::
- `--syslog` Send logs to syslog.

Daemon::
- `--no-syslog` Do not send logs to syslog.

  
== Inclusion

You have to first include link:./logc.adoc[LogC]. LogC Argp is then included the
same way. You should link your program with `liblogc_argp` (as well as with
`libargp_standalone` if required). You can also use `pkg-config` configuration
under name `logc_argp`.

In code you have to just include `logc_argp.h`.


== Usage

To use LogC Argp you need to add either `logc_argp_parser` or
`logc_argp_daemon_parser` as child parser to your own Argp parser instance. Then
before you invoke `argp_parse` you need to also set `logc_argp_log` to your log
instance. Then you can just use Argp as you are used to.

Full example:
[,C]
----
const struct argp argp = {
	.options = (struct argp_option[]){{NULL}},
	.parser = parse_opt,
	.doc = "Some help text",
	.children = (struct argp_child[]){{&logc_argp_parser, 0, "Logging", 2}, {NULL}},
};
argp_parse(&argp_tlog_parser, argc, argv, 0, NULL, NULL);
----

[TIP]
  You want to use `logc_argp_daemon_parser` when you define your log using
  `LOG_DAEMON` macro. In other cases you want to use `logc_argp_parser`.

[WARNING]
  The LogC Argp uses or reserves internally keys from 1050 till 1100 and `'v'`
  and `'q'`. These are values of `int key` in `struct argp_option`. You should
  never use them.
