lib: Add ot_journal_* helper macros
Rather than wrapping each instance of `sd_journal_*` with `HAVE_SYSTEMD`, let's just add some convenience macros that are just no-op if we're not compiling with systemd. Closes: #1841 Approved by: cgwalters
This commit is contained in:
parent
d69214ade3
commit
5464535205
|
|
@ -163,18 +163,16 @@ _ostree_fetcher_journal_failure (const char *remote_name,
|
||||||
const char *url,
|
const char *url,
|
||||||
const char *msg)
|
const char *msg)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_LIBSYSTEMD
|
|
||||||
/* Sanity - we don't want to log this when doing local/file pulls */
|
/* Sanity - we don't want to log this when doing local/file pulls */
|
||||||
if (!remote_name)
|
if (!remote_name)
|
||||||
return;
|
return;
|
||||||
sd_journal_send ("MESSAGE=libostree HTTP error from remote %s for <%s>: %s",
|
ot_journal_send ("MESSAGE=libostree HTTP error from remote %s for <%s>: %s",
|
||||||
remote_name, url, msg,
|
remote_name, url, msg,
|
||||||
"MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(OSTREE_HTTP_FAILURE_ID),
|
"MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(OSTREE_HTTP_FAILURE_ID),
|
||||||
"OSTREE_REMOTE=%s", remote_name,
|
"OSTREE_REMOTE=%s", remote_name,
|
||||||
"OSTREE_URL=%s", url,
|
"OSTREE_URL=%s", url,
|
||||||
"PRIORITY=%i", LOG_ERR,
|
"PRIORITY=%i", LOG_ERR,
|
||||||
NULL);
|
NULL);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check whether a particular operation should be retried. This is entirely
|
/* Check whether a particular operation should be retried. This is entirely
|
||||||
|
|
|
||||||
|
|
@ -4655,7 +4655,7 @@ ostree_repo_pull_with_options (OstreeRepo *self,
|
||||||
g_autofree char *formatted_xferred = g_format_size (bytes_transferred);
|
g_autofree char *formatted_xferred = g_format_size (bytes_transferred);
|
||||||
g_string_append_printf (msg, "\ntransfer: secs: %u size: %s", n_seconds, formatted_xferred);
|
g_string_append_printf (msg, "\ntransfer: secs: %u size: %s", n_seconds, formatted_xferred);
|
||||||
|
|
||||||
sd_journal_send ("MESSAGE=%s", msg->str,
|
ot_journal_send ("MESSAGE=%s", msg->str,
|
||||||
"MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(OSTREE_MESSAGE_FETCH_COMPLETE_ID),
|
"MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(OSTREE_MESSAGE_FETCH_COMPLETE_ID),
|
||||||
"OSTREE_REMOTE=%s", pull_data->remote_name,
|
"OSTREE_REMOTE=%s", pull_data->remote_name,
|
||||||
"OSTREE_GPG=%s", gpg_verify_state,
|
"OSTREE_GPG=%s", gpg_verify_state,
|
||||||
|
|
|
||||||
|
|
@ -447,14 +447,12 @@ merge_configuration_from (OstreeSysroot *sysroot,
|
||||||
{ g_autofree char *msg =
|
{ g_autofree char *msg =
|
||||||
g_strdup_printf ("Copying /etc changes: %u modified, %u removed, %u added",
|
g_strdup_printf ("Copying /etc changes: %u modified, %u removed, %u added",
|
||||||
modified->len, removed->len, added->len);
|
modified->len, removed->len, added->len);
|
||||||
#ifdef HAVE_LIBSYSTEMD
|
ot_journal_send ("MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(OSTREE_CONFIGMERGE_ID),
|
||||||
sd_journal_send ("MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(OSTREE_CONFIGMERGE_ID),
|
|
||||||
"MESSAGE=%s", msg,
|
"MESSAGE=%s", msg,
|
||||||
"ETC_N_MODIFIED=%u", modified->len,
|
"ETC_N_MODIFIED=%u", modified->len,
|
||||||
"ETC_N_REMOVED=%u", removed->len,
|
"ETC_N_REMOVED=%u", removed->len,
|
||||||
"ETC_N_ADDED=%u", added->len,
|
"ETC_N_ADDED=%u", added->len,
|
||||||
NULL);
|
NULL);
|
||||||
#endif
|
|
||||||
_ostree_sysroot_emit_journal_msg (sysroot, msg);
|
_ostree_sysroot_emit_journal_msg (sysroot, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -701,11 +699,9 @@ selinux_relabel_var_if_needed (OstreeSysroot *sysroot,
|
||||||
{
|
{
|
||||||
{ g_autofree char *msg =
|
{ g_autofree char *msg =
|
||||||
g_strdup_printf ("Relabeling /var (no stamp file '%s' found)", selabeled);
|
g_strdup_printf ("Relabeling /var (no stamp file '%s' found)", selabeled);
|
||||||
#ifdef HAVE_LIBSYSTEMD
|
ot_journal_send ("MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(OSTREE_VARRELABEL_ID),
|
||||||
sd_journal_send ("MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(OSTREE_VARRELABEL_ID),
|
|
||||||
"MESSAGE=%s", msg,
|
"MESSAGE=%s", msg,
|
||||||
NULL);
|
NULL);
|
||||||
#endif
|
|
||||||
_ostree_sysroot_emit_journal_msg (sysroot, msg);
|
_ostree_sysroot_emit_journal_msg (sysroot, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2387,8 +2383,7 @@ ostree_sysroot_write_deployments_with_options (OstreeSysroot *self,
|
||||||
(bootloader_is_atomic ? "Transaction complete" : "Bootloader updated"),
|
(bootloader_is_atomic ? "Transaction complete" : "Bootloader updated"),
|
||||||
requires_new_bootversion ? "yes" : "no",
|
requires_new_bootversion ? "yes" : "no",
|
||||||
new_deployments->len - self->deployments->len);
|
new_deployments->len - self->deployments->len);
|
||||||
#ifdef HAVE_LIBSYSTEMD
|
ot_journal_send ("MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(OSTREE_DEPLOYMENT_COMPLETE_ID),
|
||||||
sd_journal_send ("MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(OSTREE_DEPLOYMENT_COMPLETE_ID),
|
|
||||||
"MESSAGE=%s", msg,
|
"MESSAGE=%s", msg,
|
||||||
"OSTREE_BOOTLOADER=%s", bootloader ? _ostree_bootloader_get_name (bootloader) : "none",
|
"OSTREE_BOOTLOADER=%s", bootloader ? _ostree_bootloader_get_name (bootloader) : "none",
|
||||||
"OSTREE_BOOTLOADER_CONFIG=%s", bootloader_config,
|
"OSTREE_BOOTLOADER_CONFIG=%s", bootloader_config,
|
||||||
|
|
@ -2399,7 +2394,6 @@ ostree_sysroot_write_deployments_with_options (OstreeSysroot *self,
|
||||||
"OSTREE_SYNCFS_BOOT_MSEC=%" G_GUINT64_FORMAT, syncstats.boot_syncfs_msec,
|
"OSTREE_SYNCFS_BOOT_MSEC=%" G_GUINT64_FORMAT, syncstats.boot_syncfs_msec,
|
||||||
"OSTREE_SYNCFS_EXTRA_MSEC=%" G_GUINT64_FORMAT, syncstats.extra_syncfs_msec,
|
"OSTREE_SYNCFS_EXTRA_MSEC=%" G_GUINT64_FORMAT, syncstats.extra_syncfs_msec,
|
||||||
NULL);
|
NULL);
|
||||||
#endif
|
|
||||||
_ostree_sysroot_emit_journal_msg (self, msg);
|
_ostree_sysroot_emit_journal_msg (self, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2891,8 +2885,7 @@ _ostree_sysroot_finalize_staged (OstreeSysroot *self,
|
||||||
|
|
||||||
/* Notice we send this *after* the trivial `return TRUE` above; this msg implies we've
|
/* Notice we send this *after* the trivial `return TRUE` above; this msg implies we've
|
||||||
* committed to finalizing the deployment. */
|
* committed to finalizing the deployment. */
|
||||||
#ifdef HAVE_LIBSYSTEMD
|
ot_journal_send ("MESSAGE_ID=" SD_ID128_FORMAT_STR,
|
||||||
sd_journal_send ("MESSAGE_ID=" SD_ID128_FORMAT_STR,
|
|
||||||
SD_ID128_FORMAT_VAL(OSTREE_DEPLOYMENT_FINALIZING_ID),
|
SD_ID128_FORMAT_VAL(OSTREE_DEPLOYMENT_FINALIZING_ID),
|
||||||
"MESSAGE=Finalizing staged deployment",
|
"MESSAGE=Finalizing staged deployment",
|
||||||
"OSTREE_OSNAME=%s",
|
"OSTREE_OSNAME=%s",
|
||||||
|
|
@ -2902,7 +2895,6 @@ _ostree_sysroot_finalize_staged (OstreeSysroot *self,
|
||||||
"OSTREE_DEPLOYSERIAL=%u",
|
"OSTREE_DEPLOYSERIAL=%u",
|
||||||
ostree_deployment_get_deployserial (self->staged_deployment),
|
ostree_deployment_get_deployserial (self->staged_deployment),
|
||||||
NULL);
|
NULL);
|
||||||
#endif
|
|
||||||
|
|
||||||
g_assert (self->staged_deployment_data);
|
g_assert (self->staged_deployment_data);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,14 @@
|
||||||
} \
|
} \
|
||||||
} G_STMT_END;
|
} G_STMT_END;
|
||||||
|
|
||||||
|
#ifdef HAVE_LIBSYSTEMD
|
||||||
|
#define ot_journal_send(...) sd_journal_send(__VA_ARGS__)
|
||||||
|
#define ot_journal_print(...) sd_journal_print(__VA_ARGS__)
|
||||||
|
#else
|
||||||
|
#define ot_journal_send(...) {}
|
||||||
|
#define ot_journal_print(...) {}
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <ot-keyfile-utils.h>
|
#include <ot-keyfile-utils.h>
|
||||||
#include <ot-gio-utils.h>
|
#include <ot-gio-utils.h>
|
||||||
#include <ot-fs-utils.h>
|
#include <ot-fs-utils.h>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue