mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
refactored log faciltity macros
This commit is contained in:
parent
e7bf4e3f03
commit
84ebfda4e1
9 changed files with 44 additions and 41 deletions
|
@ -32,22 +32,25 @@
|
|||
*
|
||||
* To be or-ed with the debug level
|
||||
*/
|
||||
enum debug_facilities {
|
||||
DBG_POOL = (1 << 8),
|
||||
DBG_QUEUE = (1 << 9),
|
||||
DBG_CONFIG = (1 << 10),
|
||||
DBG_HOOK = (1 << 11),
|
||||
DBG_PATH = (1 << 12),
|
||||
DBG_MEM = (1 << 13),
|
||||
enum log_facilities {
|
||||
LOG_POOL = (1 << 8),
|
||||
LOG_QUEUE = (1 << 9),
|
||||
LOG_CONFIG = (1 << 10),
|
||||
LOG_HOOK = (1 << 11),
|
||||
LOG_PATH = (1 << 12),
|
||||
LOG_MEM = (1 << 13),
|
||||
|
||||
/* Node-types */
|
||||
DBG_SOCKET = (1 << 16),
|
||||
DBG_FILE = (1 << 17),
|
||||
DBG_FPGA = (1 << 18),
|
||||
DBG_NGSI = (1 << 19),
|
||||
DBG_WEBSOCKET = (1 << 20),
|
||||
DBG_OPAL = (1 << 21),
|
||||
DBG_NODE = (0xFF << 16)
|
||||
LOG_SOCKET = (1 << 16),
|
||||
LOG_FILE = (1 << 17),
|
||||
LOG_FPGA = (1 << 18),
|
||||
LOG_NGSI = (1 << 19),
|
||||
LOG_WEBSOCKET = (1 << 20),
|
||||
LOG_OPAL = (1 << 21),
|
||||
|
||||
/* Classes */
|
||||
LOG_NODE = (0xFF << 16),
|
||||
LOG_ALL = ~0xFF
|
||||
};
|
||||
|
||||
/** Change log indention for current thread.
|
||||
|
|
|
@ -42,7 +42,7 @@ int hook_run(struct path *p, struct sample *smps[], size_t cnt, int when)
|
|||
{
|
||||
list_foreach(struct hook *h, &p->hooks) {
|
||||
if (h->type & when) {
|
||||
debug(DBG_HOOK | 22, "Running hook when=%u '%s' prio=%u, cnt=%zu", when, h->name, h->priority, cnt);
|
||||
debug(LOG_HOOK | 22, "Running hook when=%u '%s' prio=%u, cnt=%zu", when, h->name, h->priority, cnt);
|
||||
|
||||
cnt = h->cb(p, h, when, smps, cnt);
|
||||
if (cnt == 0)
|
||||
|
|
|
@ -31,7 +31,7 @@ struct interface * if_create(struct rtnl_link *link)
|
|||
|
||||
i->nl_link = link;
|
||||
|
||||
debug(DBG_SOCKET | 3, "Created interface '%s'", rtnl_link_get_name(i->nl_link));
|
||||
debug(LOG_SOCKET | 3, "Created interface '%s'", rtnl_link_get_name(i->nl_link));
|
||||
|
||||
int n = if_get_irqs(i);
|
||||
if (n > 0)
|
||||
|
@ -94,7 +94,7 @@ int if_start(struct interface *i, int affinity)
|
|||
error("Failed to setup FW mark classifier: %s", nl_geterror(ret));
|
||||
|
||||
char *buf = tc_print(s->tc_qdisc);
|
||||
debug(DBG_SOCKET | 5, "Starting network emulation on interface '%s' for FW mark %u: %s",
|
||||
debug(LOG_SOCKET | 5, "Starting network emulation on interface '%s' for FW mark %u: %s",
|
||||
rtnl_link_get_name(i->nl_link), s->mark, buf);
|
||||
free(buf);
|
||||
|
||||
|
@ -195,7 +195,7 @@ int if_set_affinity(struct interface *i, int affinity)
|
|||
error("Failed to set affinity for IRQ %u", i->irqs[n]);
|
||||
|
||||
fclose(file);
|
||||
debug(DBG_SOCKET | 5, "Set affinity of IRQ %u for interface '%s' to %#x", i->irqs[n], rtnl_link_get_name(i->nl_link), affinity);
|
||||
debug(LOG_SOCKET | 5, "Set affinity of IRQ %u for interface '%s' to %#x", i->irqs[n], rtnl_link_get_name(i->nl_link), affinity);
|
||||
}
|
||||
else
|
||||
error("Failed to set affinity for interface '%s'", rtnl_link_get_name(i->nl_link));
|
||||
|
|
|
@ -19,20 +19,20 @@
|
|||
|
||||
void * memory_alloc(const struct memtype *m, size_t len)
|
||||
{
|
||||
debug(DBG_MEM | 2, "Allocating %#zx bytes of %s memory", len, m->name);
|
||||
debug(LOG_MEM | 2, "Allocating %#zx bytes of %s memory", len, m->name);
|
||||
return m->alloc(len);
|
||||
}
|
||||
|
||||
void * memory_alloc_aligned(const struct memtype *m, size_t len, size_t alignment)
|
||||
{
|
||||
debug(DBG_MEM | 2, "Allocating %#zx bytes of %#zx-byte-aligned %s memory", len, alignment, m->name);
|
||||
debug(LOG_MEM | 2, "Allocating %#zx bytes of %#zx-byte-aligned %s memory", len, alignment, m->name);
|
||||
warn("%s: not implemented yet!", __FUNCTION__);
|
||||
return memory_alloc(m, len);
|
||||
}
|
||||
|
||||
int memory_free(const struct memtype *m, void *ptr, size_t len)
|
||||
{
|
||||
debug(DBG_MEM | 2, "Releasing %#zx bytes of %s memory", len, m->name);
|
||||
debug(LOG_MEM | 2, "Releasing %#zx bytes of %s memory", len, m->name);
|
||||
return m->free(ptr, len);
|
||||
}
|
||||
|
||||
|
|
|
@ -287,7 +287,7 @@ static int ngsi_request(CURL *handle, const char *endpoint, const char *operatio
|
|||
curl_easy_setopt(handle, CURLOPT_POSTFIELDSIZE, strlen(post));
|
||||
curl_easy_setopt(handle, CURLOPT_POSTFIELDS, post);
|
||||
|
||||
debug(DBG_NGSI | 18, "Request to context broker: %s\n%s", url, post);
|
||||
debug(LOG_NGSI | 18, "Request to context broker: %s\n%s", url, post);
|
||||
|
||||
/* We don't want to leave the handle in an invalid state */
|
||||
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &old);
|
||||
|
@ -301,8 +301,8 @@ static int ngsi_request(CURL *handle, const char *endpoint, const char *operatio
|
|||
|
||||
curl_easy_getinfo(handle, CURLINFO_TOTAL_TIME, &time);
|
||||
|
||||
debug(DBG_NGSI | 16, "Request to context broker completed in %.4f seconds", time);
|
||||
debug(DBG_NGSI | 17, "Response from context broker:\n%s", chunk.data);
|
||||
debug(LOG_NGSI | 16, "Request to context broker completed in %.4f seconds", time);
|
||||
debug(LOG_NGSI | 17, "Response from context broker:\n%s", chunk.data);
|
||||
|
||||
*response = json_loads(chunk.data, 0, &err);
|
||||
if (!*response)
|
||||
|
|
|
@ -88,7 +88,7 @@ int opal_deinit()
|
|||
if (err != EOK)
|
||||
error("Failed to close shared memory area (%d)", err);
|
||||
|
||||
debug(DBG_OPAL | 4, "Closing OPAL shared memory mapping");
|
||||
debug(LOG_OPAL | 4, "Closing OPAL shared memory mapping");
|
||||
|
||||
err = OpalSystemCtrl_UnRegister(print_shmem_name);
|
||||
if (err != EOK)
|
||||
|
@ -104,7 +104,7 @@ int opal_deinit()
|
|||
|
||||
int opal_print_global()
|
||||
{
|
||||
debug(DBG_OPAL | 2, "Controller ID: %u", params.controllerID);
|
||||
debug(LOG_OPAL | 2, "Controller ID: %u", params.controllerID);
|
||||
|
||||
char *sbuf = alloc(send_icons * 5);
|
||||
char *rbuf = alloc(recv_icons * 5);
|
||||
|
@ -114,17 +114,17 @@ int opal_print_global()
|
|||
for (int i = 0; i < recv_icons; i++)
|
||||
strcatf(&rbuf, "%u ", recv_ids[i]);
|
||||
|
||||
debug(DBG_OPAL | 2, "Send Blocks: %s", sbuf);
|
||||
debug(DBG_OPAL | 2, "Receive Blocks: %s", rbuf);
|
||||
debug(LOG_OPAL | 2, "Send Blocks: %s", sbuf);
|
||||
debug(LOG_OPAL | 2, "Receive Blocks: %s", rbuf);
|
||||
|
||||
free(sbuf);
|
||||
free(rbuf);
|
||||
|
||||
debug(DBG_OPAL | 2, "Control Block Parameters:");
|
||||
debug(LOG_OPAL | 2, "Control Block Parameters:");
|
||||
for (int i = 0; i < GENASYNC_NB_FLOAT_PARAM; i++)
|
||||
debug(DBG_OPAL | 2, "FloatParam[]%u] = %f", i, params.FloatParam[i]);
|
||||
debug(LOG_OPAL | 2, "FloatParam[]%u] = %f", i, params.FloatParam[i]);
|
||||
for (int i = 0; i < GENASYNC_NB_STRING_PARAM; i++)
|
||||
debug(DBG_OPAL | 2, "StringParam[%u] = %s", i, params.StringParam[i]);
|
||||
debug(LOG_OPAL | 2, "StringParam[%u] = %s", i, params.StringParam[i]);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -165,7 +165,7 @@ int socket_open(struct node *n)
|
|||
if (ret)
|
||||
serror("Failed to set FW mark for outgoing packets");
|
||||
else
|
||||
debug(DBG_SOCKET | 4, "Set FW mark for socket (sd=%u) to %u", s->sd, s->mark);
|
||||
debug(LOG_SOCKET | 4, "Set FW mark for socket (sd=%u) to %u", s->sd, s->mark);
|
||||
}
|
||||
|
||||
/* Set socket priority, QoS or TOS IP options */
|
||||
|
@ -177,7 +177,7 @@ int socket_open(struct node *n)
|
|||
if (setsockopt(s->sd, IPPROTO_IP, IP_TOS, &prio, sizeof(prio)))
|
||||
serror("Failed to set type of service (QoS)");
|
||||
else
|
||||
debug(DBG_SOCKET | 4, "Set QoS/TOS IP option for node %s to %#x", node_name(n), prio);
|
||||
debug(LOG_SOCKET | 4, "Set QoS/TOS IP option for node %s to %#x", node_name(n), prio);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -185,7 +185,7 @@ int socket_open(struct node *n)
|
|||
if (setsockopt(s->sd, SOL_SOCKET, SO_PRIORITY, &prio, sizeof(prio)))
|
||||
serror("Failed to set socket priority");
|
||||
else
|
||||
debug(DBG_SOCKET | 4, "Set socket priority for node %s to %d", node_name(n), prio);
|
||||
debug(LOG_SOCKET | 4, "Set socket priority for node %s to %d", node_name(n), prio);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -388,7 +388,7 @@ int socket_read(struct node *n, struct sample *smps[], unsigned cnt)
|
|||
}
|
||||
}
|
||||
|
||||
debug(DBG_SOCKET | 17, "Received message of %zd bytes: %u samples", bytes, received);
|
||||
debug(LOG_SOCKET | 17, "Received message of %zd bytes: %u samples", bytes, received);
|
||||
|
||||
return received;
|
||||
}
|
||||
|
@ -430,7 +430,7 @@ int socket_write(struct node *n, struct sample *smps[], unsigned cnt)
|
|||
|
||||
sent++;
|
||||
|
||||
debug(DBG_SOCKET | 17, "Sent packet of %zd bytes with 1 sample", bytes);
|
||||
debug(LOG_SOCKET | 17, "Sent packet of %zd bytes with 1 sample", bytes);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -464,7 +464,7 @@ int socket_write(struct node *n, struct sample *smps[], unsigned cnt)
|
|||
|
||||
sent = cnt; /** @todo Find better way to determine how many values we actually sent */
|
||||
|
||||
debug(DBG_SOCKET | 17, "Sent packet of %zd bytes with %u samples", bytes, cnt);
|
||||
debug(LOG_SOCKET | 17, "Sent packet of %zd bytes with %u samples", bytes, cnt);
|
||||
}
|
||||
|
||||
return sent;
|
||||
|
|
|
@ -43,7 +43,7 @@ static void path_write(struct path *p, bool resend)
|
|||
else if (sent < tosend)
|
||||
warn("Partial write to node %s", node_name(n));
|
||||
|
||||
debug(DBG_PATH | 15, "Sent %u messages to node %s", sent, node_name(n));
|
||||
debug(LOG_PATH | 15, "Sent %u messages to node %s", sent, node_name(n));
|
||||
|
||||
released = pool_put_many(&p->pool, (void **) smps, sent);
|
||||
if (sent != released)
|
||||
|
@ -99,7 +99,7 @@ static void * path_run(void *arg)
|
|||
else if (recv < ready)
|
||||
warn("Partial read for path %s: read=%u expected=%u", path_name(p), recv, ready);
|
||||
|
||||
debug(DBG_PATH | 15, "Received %u messages from node %s", recv, node_name(p->in));
|
||||
debug(LOG_PATH | 15, "Received %u messages from node %s", recv, node_name(p->in));
|
||||
|
||||
/* Run preprocessing hooks for vector of samples */
|
||||
enqueue = hook_run(p, smps, recv, HOOK_READ);
|
||||
|
@ -114,7 +114,7 @@ static void * path_run(void *arg)
|
|||
|
||||
ready -= enqueued;
|
||||
|
||||
debug(DBG_PATH | 3, "Enqueuing %u samples to queue of path %s", enqueue, path_name(p));
|
||||
debug(LOG_PATH | 3, "Enqueuing %u samples to queue of path %s", enqueue, path_name(p));
|
||||
|
||||
/* At fixed rate mode, messages are send by another (asynchronous) thread */
|
||||
if (p->rate == 0)
|
||||
|
|
|
@ -26,7 +26,7 @@ int pool_init(struct pool *p, size_t cnt, size_t blocksz, const struct memtype *
|
|||
if (!p->buffer)
|
||||
serror("Failed to allocate memory for memory pool");
|
||||
else
|
||||
debug(DBG_POOL | 4, "Allocated %#zx bytes for memory pool", p->len);
|
||||
debug(LOG_POOL | 4, "Allocated %#zx bytes for memory pool", p->len);
|
||||
|
||||
ret = queue_init(&p->queue, cnt, m);
|
||||
if (ret)
|
||||
|
|
Loading…
Add table
Reference in a new issue