Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/azatoth/minidlna.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Maggard <jmaggard@users.sourceforce.net>2012-02-14 22:25:39 +0400
committerJustin Maggard <jmaggard@users.sourceforce.net>2012-02-14 22:25:39 +0400
commitf1fb0bfc683177860d6fcd97c81e72655e9c6735 (patch)
tree394a95e6cb2fde2dded8c1520263791b28411215
parentcf8db09de07482aad3617b2934552b22b30203b1 (diff)
* Add support for user-configurable log level settings.
-rw-r--r--log.c7
-rw-r--r--minidlna.c17
-rw-r--r--minidlna.conf4
-rw-r--r--minissdp.c11
-rw-r--r--options.c1
-rw-r--r--options.h1
-rw-r--r--utils.c25
-rw-r--r--utils.h3
8 files changed, 53 insertions, 16 deletions
diff --git a/log.c b/log.c
index ef21e8f..91aa564 100644
--- a/log.c
+++ b/log.c
@@ -62,11 +62,11 @@ log_init(const char *fname, const char *debug)
if (debug)
{
- char *rhs, *lhs, *p;
+ const char *rhs, *lhs, *nlhs, *p;
int n;
int level, facility;
memset(&log_level_set, 0, sizeof(log_level_set));
- rhs = lhs = (char*) debug;
+ rhs = nlhs = debug;
while (rhs && (rhs = strchr(rhs, '='))) {
rhs++;
p = strchr(rhs, ',');
@@ -75,7 +75,8 @@ log_init(const char *fname, const char *debug)
if (!(strncasecmp(level_name[level], rhs, n)))
break;
}
- rhs = p;
+ lhs = nlhs;
+ rhs = nlhs = p;
if (!(level_name[level])) {
// unknown level
continue;
diff --git a/minidlna.c b/minidlna.c
index 9e3feb8..f35519d 100644
--- a/minidlna.c
+++ b/minidlna.c
@@ -350,6 +350,7 @@ init(int argc, char * * argv)
char buf[PATH_MAX];
char ip_addr[INET_ADDRSTRLEN + 3] = {'\0'};
char log_str[72] = "general,artwork,database,inotify,scanner,metadata,http,ssdp,tivo=warn";
+ char *log_level = NULL;
/* first check if "-f" option is used */
for(i=2; i<argc; i++)
@@ -541,6 +542,9 @@ init(int argc, char * * argv)
}
strncpyt(log_path, path, PATH_MAX);
break;
+ case UPNPLOGLEVEL:
+ log_level = ary_options[i].value;
+ break;
case UPNPINOTIFY:
if( (strcmp(ary_options[i].value, "yes") != 0) && !atoi(ary_options[i].value) )
CLEARFLAG(INOTIFY_MASK);
@@ -777,22 +781,29 @@ init(int argc, char * * argv)
}
if( verbose_flag )
+ {
strcpy(log_str+65, "debug");
+ log_level = log_str;
+ }
+ else if( !log_level )
+ {
+ log_level = log_str;
+ }
if(debug_flag)
{
pid = getpid();
- log_init(NULL, log_str);
+ log_init(NULL, log_level);
}
else
{
pid = daemonize();
#ifdef READYNAS
- log_init("/var/log/upnp-av.log", log_str);
+ log_init("/var/log/upnp-av.log", log_level);
#else
if( access(db_path, F_OK) != 0 )
make_dir(db_path, S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO);
sprintf(buf, "%s/minidlna.log", log_path);
- log_init(buf, log_str);
+ log_init(buf, log_level);
#endif
}
diff --git a/minidlna.conf b/minidlna.conf
index 377e9b2..798d303 100644
--- a/minidlna.conf
+++ b/minidlna.conf
@@ -22,6 +22,10 @@ media_dir=/opt
# set this if you would like to specify the directory where you want MiniDLNA to store its log file
#log_dir=/var/log
+# set this to change the verbosity of the information that is logged
+# each section can use a different level: off, fatal, error, warn, info, or debug
+#log_level=general,artwork,database,inotify,scanner,metadata,http,ssdp,tivo=warn
+
# this should be a list of file names to check for when searching for album art
# note: names should be delimited with a forward slash ("/")
album_art_names=Cover.jpg/cover.jpg/AlbumArtSmall.jpg/albumartsmall.jpg/AlbumArt.jpg/albumart.jpg/Album.jpg/album.jpg/Folder.jpg/folder.jpg/Thumb.jpg/thumb.jpg
diff --git a/minissdp.c b/minissdp.c
index da21141..81ae23e 100644
--- a/minissdp.c
+++ b/minissdp.c
@@ -516,8 +516,6 @@ close:
* process SSDP M-SEARCH requests and responds to them */
void
ProcessSSDPRequest(int s, unsigned short port)
-/*ProcessSSDPRequest(int s, struct lan_addr_s * lan_addr, int n_lan_addr,
- unsigned short port)*/
{
int n;
char bufr[1500];
@@ -547,10 +545,8 @@ ProcessSSDPRequest(int s, unsigned short port)
if( bufr[i] == '*' )
break;
}
- if( !strcasestr(bufr+i, "HTTP/1.1") )
- {
+ if( !strcasestrc(bufr+i, "HTTP/1.1", '\r') )
return;
- }
while(i < n)
{
while((i < n - 2) && (bufr[i] != '\r' || bufr[i+1] != '\n'))
@@ -601,7 +597,6 @@ ProcessSSDPRequest(int s, unsigned short port)
}
ParseUPnPClient(loc);
}
- return;
}
else if(memcmp(bufr, "M-SEARCH", 8) == 0)
{
@@ -612,10 +607,8 @@ ProcessSSDPRequest(int s, unsigned short port)
if( bufr[i] == '*' )
break;
}
- if( !strcasestr(bufr+i, "HTTP/1.1") )
- {
+ if( !strcasestrc(bufr+i, "HTTP/1.1", '\r') )
return;
- }
while(i < n)
{
while((i < n - 2) && (bufr[i] != '\r' || bufr[i+1] != '\n'))
diff --git a/options.c b/options.c
index d36f948..74b8254 100644
--- a/options.c
+++ b/options.c
@@ -57,6 +57,7 @@ static const struct {
{ UPNPINOTIFY, "inotify" },
{ UPNPDBDIR, "db_dir" },
{ UPNPLOGDIR, "log_dir" },
+ { UPNPLOGLEVEL, "log_level" },
{ UPNPMINISSDPDSOCKET, "minissdpdsocket"},
{ ENABLE_TIVO, "enable_tivo" },
{ ENABLE_DLNA_STRICT, "strict_dlna" },
diff --git a/options.h b/options.h
index bce4070..c5f0897 100644
--- a/options.h
+++ b/options.h
@@ -51,6 +51,7 @@ enum upnpconfigoptions {
UPNPINOTIFY, /* enable inotify on the media directories */
UPNPDBDIR, /* base directory to store the database and album art cache */
UPNPLOGDIR, /* base directory to store the log file */
+ UPNPLOGLEVEL, /* logging verbosity */
UPNPMINISSDPDSOCKET, /* minissdpdsocket */
ENABLE_TIVO, /* enable support for streaming images and music to TiVo */
ENABLE_DLNA_STRICT, /* strictly adhere to DLNA specs */
diff --git a/utils.c b/utils.c
index 2c95587..60d7146 100644
--- a/utils.c
+++ b/utils.c
@@ -106,7 +106,7 @@ strstrc(const char *s, const char *p, const char t)
endptr = strchr(s, t);
if (!endptr)
- return NULL;
+ return strstr(s, p);
plen = strlen(p);
slen = endptr - s;
@@ -122,6 +122,29 @@ strstrc(const char *s, const char *p, const char t)
}
char *
+strcasestrc(const char *s, const char *p, const char t)
+{
+ char *endptr;
+ size_t slen, plen;
+
+ endptr = strchr(s, t);
+ if (!endptr)
+ return strcasestr(s, p);
+
+ plen = strlen(p);
+ slen = endptr - s;
+ while (slen >= plen)
+ {
+ if (*s == *p && strncasecmp(s+1, p+1, plen-1) == 0)
+ return (char*)s;
+ s++;
+ slen--;
+ }
+
+ return NULL;
+}
+
+char *
modifyString(char * string, const char * before, const char * after, short like)
{
int oldlen, newlen, chgcnt = 0;
diff --git a/utils.h b/utils.h
index 67790b5..fbd0a91 100644
--- a/utils.h
+++ b/utils.h
@@ -40,6 +40,9 @@ char *
strstrc(const char *s, const char *p, const char t);
char *
+strcasestrc(const char *s, const char *p, const char t);
+
+char *
modifyString(char * string, const char * before, const char * after, short like);
char *