Was printing too many lines for an obsolete reason.
During the brief period in which configuration has not been completely parsed yet (and therefore, Fort is not yet aware of the desired running mode), the standard streams and syslog are used simultaneously.
+Fort uses exactly five syslog levels of priority. These are their meanings:
+
+- `crit`: Programming errors. (These lead to program termination.)
+- `err`: Validation failures. (RPKI object rejected.)
+- `warning`: Suspicious validation outcome. (RPKI object not rejected.)
+- `info`: Information deemed useful to the user:
+ - Configuration echo at the beginning.
+ - Server binding status.
+ - Additional noise we're considering downgrading to `debug`.
+- `debug`: Information deemed useful to the developer. These messages are usually compiled out of the binary by default. If you want them, you need to enable `-DDEBUG` (eg. by uncommenting [`CFLAGS_DEBUG`](https://github.com/NICMx/FORT-validator/blob/master/src/Makefile.am#L3)).
+
+When standard streams are enabled, `info` and `debug` are printed in standard output, while rest are printed in standard error.
+
- **Type:** None
- **Availability:** `argv` and JSON
-If enabled, the logging output will contain ANSI color codes. Meant for human consumption.
+If enabled, the logging output will contain ANSI color codes. Meant for human consumption:
<pre><code class="terminal">$ {{ page.command }} --color-output (...)
<span style="color:cyan">DBG: Manifest '62gPOPXWxxu0sQa4vQZYUBLaMbY.mft' {</span>
<span style="color:magenta">CRT: Programming error: Array size is 1 but array is NULL.</span>
</code></pre>
+At present, this flag only affects standard output and standard error. Color codes are not sent to syslog, regardless of this flag.
+
### `--log.file-name-format`
- **Type:** Enumeration (`global-url`, `local-path`, `file-name`)
ERR: baz.cer: Certificate validation failed: certificate has expired
{% endhighlight %}
+This flag affects standard output, standard error and syslog.
+
### `--output.roa`
- **Type:** String (Path to file)
fprintf(lvl->stream, "\n");
}
-static bool
-pr_file_name(int level)
-{
- char const *file_name;
-
- file_name = fnstack_peek();
- if (file_name == NULL)
- return false;
-
- if (syslog_enabled)
- syslog(level, "%s:", file_name);
- if (fprintf_enabled)
- __fprintf(level, "%s:", file_name);
-
- return true;
-}
-
#define MSG_LEN 512
static void
-pr_syslog(int level, bool indent, const char *format, va_list args)
+pr_syslog(int level, const char *format, va_list args)
{
+ char const *file_name;
+ struct level const *lvl;
char msg[MSG_LEN];
+
+ file_name = fnstack_peek();
+ lvl = level2struct(level);
+
/* Can't use vsyslog(); it's not portable. */
vsnprintf(msg, MSG_LEN, format, args);
- syslog(level, "%s%s", indent ? " " : "", msg);
+ if (file_name != NULL)
+ syslog(level, "%s: %s: %s", lvl->label, file_name, msg);
+ else
+ syslog(level, "%s: %s", lvl->label, msg);
}
static void
-pr_stream(int level, bool indent, const char *format, va_list args)
+pr_stream(int level, const char *format, va_list args)
{
- struct level const *lvl = level2struct(level);
+ char const *file_name;
+ struct level const *lvl;
+
+ file_name = fnstack_peek();
+ lvl = level2struct(level);
if (config_get_color_output())
fprintf(lvl->stream, "%s", lvl->color);
fprintf(lvl->stream, "%s: ", lvl->label);
- if (indent)
- fprintf(lvl->stream, " ");
+ if (file_name != NULL)
+ fprintf(lvl->stream, "%s: ", file_name);
vfprintf(lvl->stream, format, args);
if (config_get_color_output())
#define PR_SIMPLE(level) \
do { \
va_list args; \
- bool indent; \
- \
- indent = pr_file_name(level); \
\
if (syslog_enabled) { \
va_start(args, format); \
- pr_syslog(level, indent, format, args); \
+ pr_syslog(level, format, args); \
va_end(args); \
} \
\
if (fprintf_enabled) { \
va_start(args, format); \
- pr_stream(level, indent, format, args); \
+ pr_stream(level, format, args); \
va_end(args); \
} \
} while (0)
#define pr_debug(...) do {} while (0)
#endif
+/* Non-errors deemed useful to the user. */
void pr_info(const char *, ...) CHECK_FORMAT(1, 2);
+/* Issues that did not trigger RPKI object rejection. */
int pr_warn(const char *, ...) CHECK_FORMAT(1, 2);
+/* Errors that trigger RPKI object rejection. */
int pr_err(const char *, ...) CHECK_FORMAT(1, 2);
int pr_errno(int, const char *, ...) CHECK_FORMAT(2, 3);
int crypto_err(const char *, ...) CHECK_FORMAT(1, 2);
int pr_enomem(void);
+/* Programming errors */
__dead void pr_crit(const char *, ...) CHECK_FORMAT(1, 2);
int incidence(enum incidence_id, const char *, ...) CHECK_FORMAT(2, 3);
return crypto_err("Could not parse certificate serial number");
#ifdef DEBUG
- pr_debug_prefix();
fprintf(stdout, "serial Number: ");
BN_print_fp(stdout, number);
- pr_debug_suffix();
+ fprintf(stdout, "\n");
#endif
error = x509stack_store_serial(validation_certstack(state), number);
continue;
}
- pr_debug_prefix();
fprintf(stdout, "Revoked: ");
BN_print_fp(stdout, serial_bn);
BN_free(serial_bn);
- pr_debug_suffix();
+ fprintf(stdout, "\n");
#endif
if (X509_REVOKED_get0_revocationDate(revoked) == NULL) {