1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

log: remove indention feature complete for better compatability with new C++ logger

This commit is contained in:
Steffen Vogel 2018-07-16 14:42:11 +02:00
parent 5edea6a09b
commit 77f3033007
15 changed files with 39 additions and 101 deletions

View file

@ -35,14 +35,6 @@ extern "C" {
#include "common.h"
#include "log_config.h"
#ifdef __GNUC__
#define INDENT int __attribute__ ((__cleanup__(log_outdent), unused)) _old_indent = log_indent(1);
#define NOINDENT int __attribute__ ((__cleanup__(log_outdent), unused)) _old_indent = log_noindent();
#else
#define INDENT ;
#define NOINDENT ;
#endif
/* The log level which is passed as first argument to print() */
#define LOG_LVL_DEBUG CLR_GRY("Debug")
#define LOG_LVL_INFO CLR_WHT("Info ")
@ -122,22 +114,6 @@ int log_close(struct log *l);
/** Destroy log object */
int log_destroy(struct log *l);
/** Change log indention for current thread.
*
* The argument level can be negative!
*/
int log_indent(int levels);
/** Disable log indention of current thread. */
int log_noindent();
/** A helper function the restore the previous log indention level.
*
* This function is usually called by a __cleanup__ handler (GCC C Extension).
* See INDENT macro.
*/
void log_outdent(int *);
/** Set logging facilities based on expression.
*
* Currently we support two types of expressions:

View file

@ -330,7 +330,7 @@ int api_stop(struct api *a)
lws_callback_on_writable(s->wsi);
}
for (int i = 0; i < 10 && list_length(&a->sessions) > 0; i++) { INDENT
for (int i = 0; i < 10 && list_length(&a->sessions) > 0; i++) {
info("Wait for API sessions to close");
usleep(1 * 1e6);
}

View file

@ -135,7 +135,7 @@ double hist_stddev(struct hist *h)
}
void hist_print(struct hist *h, int details)
{ INDENT
{
if (h->total > 0) {
hist_cnt_t missed = h->total - h->higher - h->lower;

View file

@ -71,7 +71,7 @@ int if_start(struct interface *i)
{
info("Starting interface '%s' which is used by %zu sockets", rtnl_link_get_name(i->nl_link), list_length(&i->sockets));
{ INDENT
{
/* Set affinity for network interfaces (skip _loopback_ dev) */
//if_set_affinity(i, i->affinity);
@ -124,12 +124,10 @@ int if_stop(struct interface *i)
{
info("Stopping interface '%s'", rtnl_link_get_name(i->nl_link));
{ INDENT
if_set_affinity(i, -1L);
if_set_affinity(i, -1L);
if (i->tc_qdisc)
tc_reset(i);
}
if (i->tc_qdisc)
tc_reset(i);
return 0;
}

View file

@ -35,7 +35,7 @@ int rt_init(int priority, int affinity)
{
info("Initialize real-time sub-system");
{ INDENT
{
#ifdef __linux__
int is_rt;

View file

@ -335,7 +335,7 @@ int vfio_pci_reset(struct vfio_device *d)
return ret;
debug(5, "VFIO: dependent devices for hot-reset:");
for (int i = 0; i < reset_info->count; i++) { INDENT
for (int i = 0; i < reset_info->count; i++) {
struct vfio_pci_dependent_device *dd = &reset_info->devices[i];
debug(5, "%04x:%02x:%02x.%01x: iommu_group=%u", dd->segment, dd->bus, PCI_SLOT(dd->devfn), PCI_FUNC(dd->devfn), dd->group_id);
@ -508,7 +508,7 @@ void vfio_dump(struct vfio_container *v)
);
for (size_t i = 0; i < list_length(&g->devices); i++) { INDENT
for (size_t i = 0; i < list_length(&g->devices); i++) {
struct vfio_device *d = (struct vfio_device *) list_at(&g->devices, i);
info("Device %s: regions=%u, irqs=%u, flags=%#x", d->name,
@ -517,7 +517,7 @@ void vfio_dump(struct vfio_container *v)
d->info.flags
);
for (int i = 0; i < d->info.num_regions && i < 8; i++) { INDENT
for (int i = 0; i < d->info.num_regions && i < 8; i++) {
struct vfio_region_info *region = &d->regions[i];
if (region->size > 0)
@ -529,7 +529,7 @@ void vfio_dump(struct vfio_container *v)
);
}
for (int i = 0; i < d->info.num_irqs; i++) { INDENT
for (int i = 0; i < d->info.num_irqs; i++) {
struct vfio_irq_info *irq = &d->irqs[i];
if (irq->count > 0)

View file

@ -89,30 +89,6 @@ static const char *facilities_strs[] = {
"ib", /* LOG_IB */
};
#ifdef __GNUC__
/** The current log indention level (per thread!). */
static __thread int indent = 0;
int log_indent(int levels)
{
int old = indent;
indent += levels;
return old;
}
int log_noindent()
{
int old = indent;
indent = 0;
return old;
}
void log_outdent(int *old)
{
indent = *old;
}
#endif
static void log_resize(int signal, siginfo_t *sinfo, void *ctx)
{
int ret;
@ -304,16 +280,6 @@ void log_vprint(struct log *l, const char *lvl, const char *fmt, va_list ap)
/* Timestamp & Severity */
strcatf(&buf, "%10.3f %-5s ", time_delta(&l->epoch, &ts), lvl);
/* Indention in case we log to the terminal */
#ifdef __GNUC__
if (l->file == stderr || l->file == stdout) {
for (int i = 0; i < indent; i++)
strcatf(&buf, "%s ", BOX_UD);
strcatf(&buf, "%s ", BOX_UDR);
}
#endif
/* Format String */
vstrcatf(&buf, fmt, ap);

View file

@ -89,7 +89,7 @@ void jerror(json_error_t *err, const char *fmt, ...)
va_end(ap);
log_print(l, LOG_LVL_ERROR, "%s:", buf);
{ INDENT
{
log_print(l, LOG_LVL_ERROR, "%s in %s:%d:%d", err->text, err->source, err->line, err->column);
if (l->syslog)

View file

@ -54,7 +54,7 @@ int memory_init(int hugepages)
struct rlimit l;
pagecnt = kernel_get_nr_hugepages();
if (pagecnt < hugepages) { INDENT
if (pagecnt < hugepages) {
if (getuid() == 0) {
kernel_set_nr_hugepages(hugepages);
debug(LOG_MEM | 2, "Increased number of reserved hugepages from %d to %d", pagecnt, hugepages);

View file

@ -326,7 +326,7 @@ int node_start(struct node *n)
assert(node_type(n)->state == STATE_STARTED);
info("Starting node %s", node_name_long(n));
{ INDENT
{
ret = node_direction_start(&n->in, n);
if (ret)
return ret;
@ -355,7 +355,7 @@ int node_stop(struct node *n)
return 0;
info("Stopping node %s", node_name(n));
{ INDENT
{
ret = node_direction_stop(&n->in, n);
if (ret)
return ret;

View file

@ -37,7 +37,7 @@ int node_type_start(struct node_type *vt, struct super_node *sn)
return 0;
info("Initializing " CLR_YEL("%s") " node type which is used by %zu nodes", node_type_name(vt), list_length(&vt->instances));
{ INDENT
{
ret = vt->type.start ? vt->type.start(sn) : 0;
}
@ -55,7 +55,7 @@ int node_type_stop(struct node_type *vt)
return 0;
info("De-initializing " CLR_YEL("%s") " node type", node_type_name(vt));
{ INDENT
{
ret = vt->type.stop ? vt->type.stop() : 0;
}

View file

@ -226,9 +226,8 @@ static int comedi_start_in(struct node *n)
if (ret < 0)
error("Invalid command for input subdevice of node '%s'", node_name(n));
info("Input command:"); { INDENT
comedi_dump_cmd(&cmd, 1);
}
info("Input command:")
comedi_dump_cmd(&cmd, 1);
ret = comedi_command(c->dev, &cmd);
if (ret < 0)
@ -319,9 +318,8 @@ static int comedi_start_out(struct node *n)
if (ret < 0)
error("Invalid command for input subdevice of node '%s'", node_name(n));
info("Output command:"); { INDENT
comedi_dump_cmd(&cmd, 1);
}
info("Output command:")
comedi_dump_cmd(&cmd, 1);
ret = comedi_command(c->dev, &cmd);
if (ret < 0)

View file

@ -79,7 +79,7 @@ int super_node_parse_uri(struct super_node *sn, const char *uri)
info("Parsing configuration");
if (uri) { INDENT
if (uri) {
FILE *f;
AFILE *af;
@ -110,7 +110,7 @@ int super_node_parse_uri(struct super_node *sn, const char *uri)
config_setting_t *json_root = NULL;
warn("Failed to parse JSON configuration. Re-trying with old libconfig format.");
{ INDENT
{
warn("Please consider migrating to the new format using the 'conf2json' command.");
}
@ -134,7 +134,7 @@ int super_node_parse_uri(struct super_node *sn, const char *uri)
ret = config_read(&cfg, f);
if (ret != CONFIG_TRUE) {
{ INDENT
{
warn("conf: %s in %s:%d", config_error_text(&cfg), uri, config_error_line(&cfg));
warn("json: %s in %s:%d:%d", err.text, err.source, err.line, err.column);
}
@ -163,7 +163,7 @@ int super_node_parse_uri(struct super_node *sn, const char *uri)
return super_node_parse_json(sn, sn->cfg);
}
else { INDENT
else {
warn("No configuration file specified. Starting unconfigured. Use the API to configure this instance.");
}
@ -355,7 +355,7 @@ int super_node_start(struct super_node *sn)
#endif
info("Starting node-types");
for (size_t i = 0; i < list_length(&sn->nodes); i++) { INDENT
for (size_t i = 0; i < list_length(&sn->nodes); i++) {
struct node *n = (struct node *) list_at(&sn->nodes, i);
ret = node_type_start(n->_vt, sn);
@ -364,11 +364,11 @@ int super_node_start(struct super_node *sn)
}
info("Starting nodes");
for (size_t i = 0; i < list_length(&sn->nodes); i++) { INDENT
for (size_t i = 0; i < list_length(&sn->nodes); i++) {
struct node *n = (struct node *) list_at(&sn->nodes, i);
int refs = list_count(&sn->paths, (cmp_cb_t) path_uses_node, n);
if (refs > 0) { INDENT
if (refs > 0) {
ret = node_start(n);
if (ret)
error("Failed to start node: %s", node_name(n));
@ -378,10 +378,10 @@ int super_node_start(struct super_node *sn)
}
info("Starting paths");
for (size_t i = 0; i < list_length(&sn->paths); i++) { INDENT
for (size_t i = 0; i < list_length(&sn->paths); i++) {
struct path *p = (struct path *) list_at(&sn->paths, i);
if (p->enabled) { INDENT
if (p->enabled) {
ret = path_init2(p);
if (ret)
error("Failed to start path: %s", path_name(p));
@ -404,7 +404,7 @@ int super_node_stop(struct super_node *sn)
int ret;
info("Stopping paths");
for (size_t i = 0; i < list_length(&sn->paths); i++) { INDENT
for (size_t i = 0; i < list_length(&sn->paths); i++) {
struct path *p = (struct path *) list_at(&sn->paths, i);
ret = path_stop(p);
@ -413,7 +413,7 @@ int super_node_stop(struct super_node *sn)
}
info("Stopping nodes");
for (size_t i = 0; i < list_length(&sn->nodes); i++) { INDENT
for (size_t i = 0; i < list_length(&sn->nodes); i++) {
struct node *n = (struct node *) list_at(&sn->nodes, i);
ret = node_stop(n);
@ -422,7 +422,7 @@ int super_node_stop(struct super_node *sn)
}
info("Stopping node-types");
for (size_t i = 0; i < list_length(&plugins); i++) { INDENT
for (size_t i = 0; i < list_length(&plugins); i++) {
struct plugin *p = (struct plugin *) list_at(&plugins, i);
if (p->type == PLUGIN_TYPE_NODE) {

View file

@ -61,7 +61,7 @@ static int table_resize(struct table *t, int width)
}
void table_header(struct table *t)
{ NOINDENT
{
struct log *l = global_log ? global_log : &default_log;
if (t->width != l->width)
@ -120,7 +120,7 @@ void table_header(struct table *t)
}
void table_row(struct table *t, ...)
{ NOINDENT
{
struct log *l = global_log ? global_log : &default_log;
if (t->width != l->width) {
@ -155,7 +155,7 @@ void table_row(struct table *t, ...)
}
void table_footer(struct table *t)
{ NOINDENT
{
struct log *l = global_log ? global_log : &default_log;
if (t->width != l->width)

View file

@ -242,7 +242,7 @@ int web_start(struct web *w)
info("Starting Web sub-system: webroot=%s", w->htdocs);
{ INDENT
{
/* update web root of mount point */
mounts[0].origin = w->htdocs;
@ -273,7 +273,7 @@ int web_stop(struct web *w)
info("Stopping Web sub-system");
{ INDENT
{
lws_cancel_service(w->context);
/** @todo Wait for all connections to be closed */
@ -297,7 +297,7 @@ int web_destroy(struct web *w)
if (w->state == STATE_DESTROYED)
return 0;
if (w->context) { INDENT
if (w->context) {
lws_context_destroy(w->context);
}