tag_id3: use GLib logging

This commit is contained in:
Max Kellermann 2008-12-29 17:29:10 +01:00
parent 0a9f69eaaa
commit 46bef03e5a
1 changed files with 19 additions and 12 deletions

View File

@ -19,12 +19,14 @@
#include "tag_id3.h" #include "tag_id3.h"
#include "tag.h" #include "tag.h"
#include "utils.h" #include "utils.h"
#include "log.h"
#include "conf.h" #include "conf.h"
#include <glib.h> #include <glib.h>
#include <id3tag.h> #include <id3tag.h>
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "id3"
# define isId3v1(tag) (id3_tag_options(tag, 0, 0) & ID3_TAG_OPTION_ID3V1) # define isId3v1(tag) (id3_tag_options(tag, 0, 0) & ID3_TAG_OPTION_ID3V1)
# ifndef ID3_FRAME_COMPOSER # ifndef ID3_FRAME_COMPOSER
# define ID3_FRAME_COMPOSER "TCOM" # define ID3_FRAME_COMPOSER "TCOM"
@ -61,8 +63,8 @@ static id3_utf8_t * processID3FieldString (int is_id3v1, const id3_ucs4_t *ucs4,
encoding, "utf-8", encoding, "utf-8",
NULL, NULL, NULL, &error); NULL, NULL, NULL, &error);
if (utf8 == NULL) { if (utf8 == NULL) {
DEBUG("Unable to convert %s string to UTF-8: " g_debug("Unable to convert %s string to UTF-8: '%s'",
"'%s'\n", encoding, isostr); encoding, isostr);
g_error_free(error); g_error_free(error);
free(isostr); free(isostr);
return NULL; return NULL;
@ -99,7 +101,7 @@ static struct tag *getID3Info(
/* Check fields in frame */ /* Check fields in frame */
if(frame->nfields == 0) if(frame->nfields == 0)
{ {
DEBUG(__FILE__": Frame has no fields\n"); g_debug("Frame has no fields");
return mpdTag; return mpdTag;
} }
@ -114,7 +116,8 @@ static struct tag *getID3Info(
*/ */
if(frame->nfields != 2) if(frame->nfields != 2)
{ {
DEBUG(__FILE__": Invalid number '%i' of fields for TXX frame\n",frame->nfields); g_debug("Invalid number '%i' of fields for TXX frame",
frame->nfields);
return mpdTag; return mpdTag;
} }
field = &frame->fields[0]; field = &frame->fields[0];
@ -124,7 +127,8 @@ static struct tag *getID3Info(
*/ */
if(field->type != ID3_FIELD_TYPE_TEXTENCODING) if(field->type != ID3_FIELD_TYPE_TEXTENCODING)
{ {
DEBUG(__FILE__": Expected encoding, found: %i\n",field->type); g_debug("Expected encoding, found: %i",
field->type);
} }
/* Process remaining fields, should be only one */ /* Process remaining fields, should be only one */
field = &frame->fields[1]; field = &frame->fields[1];
@ -147,7 +151,8 @@ static struct tag *getID3Info(
} }
} }
else { else {
ERROR(__FILE__": Field type not processed: %i\n",(int)id3_field_gettextencoding(field)); g_warning("Field type not processed: %i",
(int)id3_field_gettextencoding(field));
} }
} }
/* A comment frame */ /* A comment frame */
@ -181,17 +186,19 @@ static struct tag *getID3Info(
} }
else else
{ {
DEBUG(__FILE__": 4th field in comment frame differs from expected, got '%i': ignoring\n",field->type); g_debug("4th field in comment frame differs from expected, got '%i': ignoring",
field->type);
} }
} }
else else
{ {
DEBUG(__FILE__": Invalid 'comments' tag, got '%i' fields instead of 4\n", frame->nfields); g_debug("Invalid 'comments' tag, got '%i' fields instead of 4",
frame->nfields);
} }
} }
/* Unsupported */ /* Unsupported */
else { else {
DEBUG(__FILE__": Unsupported tag type requrested\n"); g_debug("Unsupported tag type requrested");
return mpdTag; return mpdTag;
} }
@ -337,8 +344,8 @@ struct tag *tag_id3_load(const char *file)
stream = fopen(file, "r"); stream = fopen(file, "r");
if (!stream) { if (!stream) {
DEBUG("tag_id3_load: Failed to open file: '%s', %s\n", file, g_debug("tag_id3_load: Failed to open file: '%s', %s",
strerror(errno)); file, strerror(errno));
return NULL; return NULL;
} }