* 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 <https://www.gnu.org/licenses/>.
*/
#include <stdarg.h>
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.
*/
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);