--- daemonlogger-1.2.1/daemonlogger.c	2008-11-24 14:56:48.000000000 -0500
+++ daemonlogger-1.2.1-datedir/daemonlogger.c	2009-09-29 02:02:39.000000000 -0400
@@ -230,6 +230,9 @@
 static char *chroot_dir;
 static char logdir[STDBUF];
 static char testpath[STDBUF];
+static char pathdatedir[STDBUF];
+char datedir[11] = {0};
+char datedir_cur[11] = {0};
 
 static size_t rollsize;
 static time_t lastroll;
@@ -411,27 +414,53 @@
     return SUCCESS;
 }
 
+void datedirfunc()
+{
+    struct tm *current;
+    time_t now;
+
+    time(&now);
+    current = localtime(&now);
+
+    snprintf(datedir_cur, 11, "%04d-%02d-%02d", (current->tm_year + 1900),
+    (current->tm_mon + 1), current->tm_mday);
+}
+
 char *get_filename()
 {
     time_t currtime;
 
     memset(logdir, 0, STDBUF);
     currtime = time(NULL);
+    datedirfunc();
     if(logpath != NULL)
     {
-        if(snprintf(logdir, 
+        if(strcmp(datedir, datedir_cur) != 0)
+        {
+            strncpy(datedir, datedir_cur, 11);
+            snprintf(pathdatedir, STDBUF, "%s/%s", logpath, datedir);
+            mkdir(pathdatedir, S_IRWXU | S_IRWXG);
+        }
+        if(snprintf(logdir,
                     STDBUF, 
-                    "%s/%s.%lu", 
+                    "%s/%s/%s.%lu", 
                     logpath, 
+                    datedir,
                     logfilename, 
                     (long unsigned int) currtime) < 0)
             return NULL;        
     }
     else
     {
+        if(strcmp(datedir, datedir_cur) != 0)
+        {
+            strncpy(datedir, datedir_cur, 11);
+            mkdir(datedir, S_IRWXU | S_IRWXG);
+        }
         if(snprintf(logdir, 
                     STDBUF, 
-                    "%s.%lu",
+                    "%s/%s.%lu",
+                    datedir,
                     logfilename,
                     (long unsigned int) currtime) < 0)
             return NULL;        

