X-Git-Url: https://the.earth.li/gitweb/?a=blobdiff_plain;f=log.c;h=7c6f2eeee5312e3e6e5dfd21fc4b976db5d2bc15;hb=810840e09b049f96ac706abb1cd7d4fb8f1c03a2;hp=7b17cb0d4191dc209fc1014a5c58df35f5d836c8;hpb=5e1b22d763640c4d7a09d07920403d8d491b4410;p=onak.git
diff --git a/log.c b/log.c
index 7b17cb0..7c6f2ee 100644
--- a/log.c
+++ b/log.c
@@ -13,8 +13,7 @@
* more details.
*
* You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * this program. If not, see .
*/
#include
@@ -111,6 +110,17 @@ loglevels setlogthreshold(loglevels loglevel)
return oldlevel;
}
+/*
+ * getlogthreshold - get the threshold for log output
+ *
+ * Returns the threshold for log output; anything logged with a log level
+ * lower than this will be silently dropped.
+ */
+loglevels getlogthreshold(void)
+{
+ return logthres;
+}
+
/*
* vflog - write a log entry to an already opened log file.
* @logfile: The FILE * handle of the open log file.
@@ -123,19 +133,19 @@ loglevels setlogthreshold(loglevels loglevel)
*/
static void vflog(FILE *logfile, const char *format, va_list ap)
{
- struct tm *timestamp = NULL;
- time_t timer = 0;
+ struct tm timestamp;
+ time_t timer = 0;
timer = time(NULL);
- timestamp = localtime(&timer);
+ localtime_r(&timer, ×tamp);
fprintf(logfile, "[%02d/%02d/%4d %02d:%02d:%02d] %s[%d]: ",
- timestamp->tm_mday,
- timestamp->tm_mon + 1,
- timestamp->tm_year + 1900,
- timestamp->tm_hour,
- timestamp->tm_min,
- timestamp->tm_sec,
+ timestamp.tm_mday,
+ timestamp.tm_mon + 1,
+ timestamp.tm_year + 1900,
+ timestamp.tm_hour,
+ timestamp.tm_min,
+ timestamp.tm_sec,
(logappname == NULL) ? "" : logappname,
getpid());
vfprintf(logfile, format, ap);