Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
tvhlog: change subsys from string to int and more cleanups
  • Loading branch information
perexg committed Aug 16, 2016
1 parent 09e982e commit d908f32
Show file tree
Hide file tree
Showing 136 changed files with 2,026 additions and 1,923 deletions.
15 changes: 7 additions & 8 deletions src/access.c
Expand Up @@ -492,7 +492,7 @@ access_dump_a(access_t *a)
tvh_strlcatf(buf, sizeof(buf), l, ", tag=ANY");
}

tvhtrace("access", "%s", buf);
tvhtrace(LS_ACCESS, "%s", buf);
}

/*
Expand Down Expand Up @@ -995,7 +995,7 @@ access_entry_create(const char *uuid, htsmsg_t *conf)

if (idnode_insert(&ae->ae_id, uuid, &access_entry_class, 0)) {
if (uuid)
tvherror("access", "invalid uuid '%s'", uuid);
tvherror(LS_ACCESS, "invalid uuid '%s'", uuid);
free(ae);
return NULL;
}
Expand Down Expand Up @@ -1700,7 +1700,7 @@ passwd_entry_create(const char *uuid, htsmsg_t *conf)

if (idnode_insert(&pw->pw_id, uuid, &passwd_entry_class, 0)) {
if (uuid)
tvherror("access", "invalid uuid '%s'", uuid);
tvherror(LS_ACCESS, "invalid uuid '%s'", uuid);
free(pw);
return NULL;
}
Expand Down Expand Up @@ -1887,7 +1887,7 @@ ipblock_entry_create(const char *uuid, htsmsg_t *conf)

if (idnode_insert(&ib->ib_id, uuid, &ipblock_entry_class, 0)) {
if (uuid)
tvherror("access", "invalid uuid '%s'", uuid);
tvherror(LS_ACCESS, "invalid uuid '%s'", uuid);
free(ib);
return NULL;
}
Expand Down Expand Up @@ -2012,7 +2012,7 @@ access_init(int createdefault, int noacl)

access_noacl = noacl;
if (noacl)
tvhlog(LOG_WARNING, "access", "Access control checking disabled");
tvhwarn(LS_ACCESS, "Access control checking disabled");

TAILQ_INIT(&access_entries);
TAILQ_INIT(&access_tickets);
Expand Down Expand Up @@ -2073,12 +2073,11 @@ access_init(int createdefault, int noacl)

idnode_changed(&ae->ae_id);

tvhlog(LOG_WARNING, "access",
"Created default wide open access controle entry");
tvhwarn(LS_ACCESS, "Created default wide open access controle entry");
}

if(!TAILQ_FIRST(&access_entries) && !noacl)
tvherror("access", "No access entries loaded");
tvherror(LS_ACCESS, "No access entries loaded");

/* Load superuser account */

Expand Down
4 changes: 2 additions & 2 deletions src/api.c
Expand Up @@ -45,7 +45,7 @@ api_register ( const api_hook_t *hook )
api_skel->hook = hook;
t = RB_INSERT_SORTED(&api_hook_tree, api_skel, link, ah_cmp);
if (t) {
tvherror("api", "trying to re-register subsystem");
tvherror(LS_API, "trying to re-register subsystem");
} else {
SKEL_USED(api_skel);
}
Expand Down Expand Up @@ -80,7 +80,7 @@ api_exec ( access_t *perm, const char *subsystem,
ah = RB_FIND(&api_hook_tree, &skel, link, ah_cmp);

if (!ah) {
tvhwarn("api", "failed to find subsystem [%s]", subsystem);
tvhwarn(LS_API, "failed to find subsystem [%s]", subsystem);
return ENOSYS; // TODO: is this really the right error code?
}

Expand Down
2 changes: 1 addition & 1 deletion src/api/api_input.c
Expand Up @@ -46,7 +46,7 @@ api_input_satip_discover
if (op == NULL || strcmp(op, "all"))
return -EINVAL;

tvhinfo("satip", "Triggered new server discovery");
tvhinfo(LS_SATIP, "Triggered new server discovery");

pthread_mutex_lock(&global_lock);
satip_device_discovery_start();
Expand Down
2 changes: 0 additions & 2 deletions src/api/api_mpegts.c
Expand Up @@ -50,8 +50,6 @@ api_mpegts_input_network_list
if (!mi)
goto exit;

tvhtrace("mpegts", "network-list: found input '%s'", mi->mi_name ?: "");

htsmsg_t *l = htsmsg_create_list();
if ((is = mi->mi_network_list(mi))) {
for (i = 0; i < is->is_count; i++) {
Expand Down
46 changes: 21 additions & 25 deletions src/avahi.c
Expand Up @@ -74,8 +74,7 @@ entry_group_callback(AvahiEntryGroup *g, AvahiEntryGroupState state,
switch (state) {
case AVAHI_ENTRY_GROUP_ESTABLISHED :
/* The entry group has been established successfully */
tvhlog(LOG_INFO, "AVAHI",
"Service '%s' successfully established.", name);
tvhoinfo(LS_AVAHI, "Service '%s' successfully established.", name);
break;

case AVAHI_ENTRY_GROUP_COLLISION : {
Expand All @@ -87,18 +86,17 @@ entry_group_callback(AvahiEntryGroup *g, AvahiEntryGroupState state,
avahi_free(name);
name = n;

tvhlog(LOG_ERR, "AVAHI",
"Service name collision, renaming service to '%s'", name);
tvherror(LS_AVAHI, "Service name collision, renaming service to '%s'", name);

/* And recreate the services */
create_services(avahi_entry_group_get_client(g));
break;
}

case AVAHI_ENTRY_GROUP_FAILURE :
tvhlog(LOG_ERR, "AVAHI",
"Entry group failure: %s",
avahi_strerror(avahi_client_errno(avahi_entry_group_get_client(g))));
tvherror(LS_AVAHI,
"Entry group failure: %s",
avahi_strerror(avahi_client_errno(avahi_entry_group_get_client(g))));
break;

case AVAHI_ENTRY_GROUP_UNCOMMITED:
Expand All @@ -124,17 +122,17 @@ create_services(AvahiClient *c)

if (!group)
if (!(group = avahi_entry_group_new(c, entry_group_callback, NULL))) {
tvhlog(LOG_ERR, "AVAHI",
"avahi_enty_group_new() failed: %s",
avahi_strerror(avahi_client_errno(c)));
tvherror(LS_AVAHI,
"avahi_enty_group_new() failed: %s",
avahi_strerror(avahi_client_errno(c)));
goto fail;
}

/* If the group is empty (either because it was just created, or
* because it was reset previously, add our entries. */

if (avahi_entry_group_is_empty(group)) {
tvhlog(LOG_DEBUG, "AVAHI", "Adding service '%s'", name);
tvhdebug(LS_AVAHI, "Adding service '%s'", name);

/* Add the service for HTSP */
if ((ret = avahi_entry_group_add_service(group, AVAHI_IF_UNSPEC,
Expand All @@ -145,9 +143,9 @@ create_services(AvahiClient *c)
if (ret == AVAHI_ERR_COLLISION)
goto collision;

tvhlog(LOG_ERR, "AVAHI",
"Failed to add _htsp._tcp service: %s",
avahi_strerror(ret));
tvherror(LS_AVAHI,
"Failed to add _htsp._tcp service: %s",
avahi_strerror(ret));
goto fail;
}

Expand All @@ -168,17 +166,17 @@ create_services(AvahiClient *c)
if (ret == AVAHI_ERR_COLLISION)
goto collision;

tvhlog(LOG_ERR, "AVAHI",
"Failed to add _http._tcp service: %s",
avahi_strerror(ret));
tvherror(LS_AVAHI,
"Failed to add _http._tcp service: %s",
avahi_strerror(ret));
goto fail;
}

/* Tell the server to register the service */
if ((ret = avahi_entry_group_commit(group)) < 0) {
tvhlog(LOG_ERR, "AVAHI",
"Failed to commit entry group: %s",
avahi_strerror(ret));
tvherror(LS_AVAHI,
"Failed to commit entry group: %s",
avahi_strerror(ret));
goto fail;
}
}
Expand All @@ -194,8 +192,7 @@ create_services(AvahiClient *c)
avahi_free(name);
name = n;

tvhlog(LOG_ERR, "AVAHI",
"Service name collision, renaming service to '%s'", name);
tvherror(LS_AVAHI, "Service name collision, renaming service to '%s'", name);

avahi_entry_group_reset(group);

Expand Down Expand Up @@ -226,8 +223,7 @@ client_callback(AvahiClient *c, AvahiClientState state, void *userdata)
break;

case AVAHI_CLIENT_FAILURE:
tvhlog(LOG_ERR, "AVAHI", "Client failure: %s",
avahi_strerror(avahi_client_errno(c)));
tvherror(LS_AVAHI, "Client failure: %s", avahi_strerror(avahi_client_errno(c)));
break;

case AVAHI_CLIENT_S_COLLISION:
Expand Down Expand Up @@ -271,7 +267,7 @@ avahi_thread(void *aux)
avahi_poll = avahi_simple_poll_get(avahi_asp);

if(avahi_do_restart) {
tvhlog(LOG_INFO, "AVAHI", "Service restarted.");
tvhinfo(LS_AVAHI, "Service restarted.");
avahi_do_restart = 0;
group = NULL;
}
Expand Down
14 changes: 7 additions & 7 deletions src/bonjour.c
Expand Up @@ -37,8 +37,8 @@ static void
bonjour_callback(CFNetServiceRef theService, CFStreamError* error, void* info)
{
if (error->error) {
tvhlog(LOG_ERR, "bonjour", "callback error (domain = %ld, error =%d)",
error->domain, error->error);
tvherror(LS_BONJOUR, "callback error (domain = %ld, error =%d)",
error->domain, error->error);
}
}

Expand All @@ -56,7 +56,7 @@ bonjour_start_service(CFNetServiceRef *svc, char *service_type,

*svc = CFNetServiceCreate(NULL, CFSTR(""), str, CFSTR("Tvheadend"), port);
if (!*svc) {
tvhlog(LOG_ERR, "bonjour", "service creation failed");
tvherror(LS_BONJOUR, "service creation failed");
return;
}

Expand Down Expand Up @@ -84,11 +84,11 @@ bonjour_start_service(CFNetServiceRef *svc, char *service_type,
}

if (!CFNetServiceRegisterWithOptions(*svc, 0, &error))
tvhlog(LOG_ERR, "bonjour", "registration failed (service type = %s, "
"domain = %ld, error =%d)", service_type, error.domain, error.error);
tvherror(LS_BONJOUR, "registration failed (service type = %s, "
"domain = %ld, error =%d)", service_type, error.domain, error.error);
else
tvhlog(LOG_INFO, "bonjour", "service '%s' successfully established",
service_type);
tvherror(LS_BONJOUR, "service '%s' successfully established",
service_type);
}

static void
Expand Down
20 changes: 10 additions & 10 deletions src/bouquet.c
Expand Up @@ -98,7 +98,7 @@ bouquet_create(const char *uuid, htsmsg_t *conf,

if (idnode_insert(&bq->bq_id, uuid, &bouquet_class, 0)) {
if (uuid)
tvherror("bouquet", "invalid uuid '%s'", uuid);
tvherror(LS_BOUQUET, "invalid uuid '%s'", uuid);
bouquet_free(bq);
return NULL;
}
Expand Down Expand Up @@ -131,7 +131,7 @@ bouquet_create(const char *uuid, htsmsg_t *conf,
bq->bq_src = strdup(buf);
bq->bq_download = bqd = calloc(1, sizeof(*bqd));
bqd->bq = bq;
download_init(&bqd->download, "bouquet");
download_init(&bqd->download, LS_BOUQUET);
bqd->download.process = bouquet_download_process;
bqd->download.stop = bouquet_download_stop;
bouquet_change_comment(bq, bq->bq_ext_url, 0);
Expand All @@ -140,7 +140,7 @@ bouquet_create(const char *uuid, htsmsg_t *conf,

bq2 = RB_INSERT_SORTED(&bouquets, bq, bq_link, _bq_cmp);
if (bq2) {
tvherror("bouquet", "found duplicate source id: '%s', remove duplicate config", bq->bq_src);
tvherror(LS_BOUQUET, "found duplicate source id: '%s', remove duplicate config", bq->bq_src);
bouquet_free(bq);
return NULL;
}
Expand Down Expand Up @@ -219,7 +219,7 @@ bouquet_find_by_source(const char *name, const char *src, int create)
bq = RB_FIND(&bouquets, &bqs, bq_link, _bq_cmp);
if (bq) {
if (name && *name && bq->bq_name && strcmp(name, bq->bq_name)) {
tvhwarn("bouquet", "bouquet name '%s' changed to '%s'", bq->bq_name ?: "", name);
tvhwarn(LS_BOUQUET, "bouquet name '%s' changed to '%s'", bq->bq_name ?: "", name);
free(bq->bq_name);
bq->bq_name = strdup(name);
idnode_changed(&bq->bq_id);
Expand All @@ -228,7 +228,7 @@ bouquet_find_by_source(const char *name, const char *src, int create)
}
if (create && name) {
bq = bouquet_create(NULL, NULL, name, src);
tvhinfo("bouquet", "new bouquet '%s'", name);
tvhinfo(LS_BOUQUET, "new bouquet '%s'", name);
return bq;
}
return NULL;
Expand Down Expand Up @@ -337,7 +337,7 @@ bouquet_add_service(bouquet_t *bq, service_t *s, uint64_t lcn, const char *tag)
return;

if (!idnode_set_exists(bq->bq_services, &s->s_id)) {
tvhtrace("bouquet", "add service %s to %s", s->s_nicename, bq->bq_name ?: "<unknown>");
tvhtrace(LS_BOUQUET, "add service %s to %s", s->s_nicename, bq->bq_name ?: "<unknown>");
idnode_set_add(bq->bq_services, &s->s_id, NULL, NULL);
bq->bq_saveflag = 1;
}
Expand Down Expand Up @@ -388,7 +388,7 @@ bouquet_unmap_channel(bouquet_t *bq, service_t *t)
while (ilm) {
ilm_next = LIST_NEXT(ilm, ilm_in1_link);
if (((channel_t *)ilm->ilm_in2)->ch_bouquet == bq) {
tvhinfo("bouquet", "%s / %s: unmapped from %s",
tvhinfo(LS_BOUQUET, "%s / %s: unmapped from %s",
channel_get_name((channel_t *)ilm->ilm_in2), t->s_nicename,
bq->bq_name ?: "<unknown>");
channel_delete((channel_t *)ilm->ilm_in2, 1);
Expand Down Expand Up @@ -422,7 +422,7 @@ bouquet_notify_service_enabled(service_t *t)
static void
bouquet_remove_service(bouquet_t *bq, service_t *s, int delconf)
{
tvhtrace("bouquet", "remove service %s from %s",
tvhtrace(LS_BOUQUET, "remove service %s from %s",
s->s_nicename, bq->bq_name ?: "<unknown>");
idnode_set_remove(bq->bq_services, &s->s_id);
if (delconf)
Expand All @@ -448,7 +448,7 @@ bouquet_completed(bouquet_t *bq, uint32_t seen)
bq->bq_saveflag = 1;
}

tvhtrace("bouquet", "%s: completed: enabled=%d active=%zi old=%zi seen=%u",
tvhtrace(LS_BOUQUET, "%s: completed: enabled=%d active=%zi old=%zi seen=%u",
bq->bq_name ?: "", bq->bq_enabled, bq->bq_active_services->is_count,
bq->bq_services->is_count, seen);

Expand Down Expand Up @@ -1190,7 +1190,7 @@ parse_enigma2(bouquet_t *bq, char *data)
while (*data && (*data == '\r' || *data == '\n')) data++;
}
bouquet_completed(bq, seen);
tvhinfo("bouquet", "parsed Enigma%d bouquet %s (%d services)", ver, bq->bq_name, seen);
tvhinfo(LS_BOUQUET, "parsed Enigma%d bouquet %s (%d services)", ver, bq->bq_name, seen);
return 0;
}

Expand Down
8 changes: 4 additions & 4 deletions src/channels.c
Expand Up @@ -976,12 +976,12 @@ channel_create0

if (idnode_insert(&ch->ch_id, uuid, idc, IDNODE_SHORT_UUID)) {
if (uuid)
tvherror("channel", "invalid uuid '%s'", uuid);
tvherror(LS_CHANNEL, "invalid uuid '%s'", uuid);
free(ch);
return NULL;
}
if (RB_INSERT_SORTED(&channels, ch, ch_link, ch_id_cmp)) {
tvherror("channel", "id collision!");
tvherror(LS_CHANNEL, "id collision!");
abort();
}

Expand Down Expand Up @@ -1028,7 +1028,7 @@ channel_delete ( channel_t *ch, int delconf )
idnode_save_check(&ch->ch_id, delconf);

if (delconf)
tvhinfo("channel", "%s - deleting", channel_get_name(ch));
tvhinfo(LS_CHANNEL, "%s - deleting", channel_get_name(ch));

/* Tags */
while((ilm = LIST_FIRST(&ch->ch_ctms)) != NULL)
Expand Down Expand Up @@ -1241,7 +1241,7 @@ channel_tag_create(const char *uuid, htsmsg_t *conf)

if (idnode_insert(&ct->ct_id, uuid, &channel_tag_class, IDNODE_SHORT_UUID)) {
if (uuid)
tvherror("channel", "invalid tag uuid '%s'", uuid);
tvherror(LS_CHANNEL, "invalid tag uuid '%s'", uuid);
free(ct);
return NULL;
}
Expand Down

0 comments on commit d908f32

Please sign in to comment.