3 /* Copyright (C) 2009 Trend Micro Inc.
6 * This program is a free software; you can redistribute it
7 * and/or modify it under the terms of the GNU General Public
8 * License (version 2) as published by the FSF - Free Software
13 #include "headers/shared.h"
24 /* For internal logs */
27 #define LOGFILE "/logs/ossec.log"
29 #define LOGFILE "ossec.log"
35 void _log(const char * msg,va_list args)
40 /* For the stderr print */
48 /* Duplicating args */
52 /* If under chroot, log directly to /logs/ossec.log */
55 fp = fopen(LOGFILE, "a");
61 snprintf(_logfile, 256, "%s%s", DEFAULTDIR, LOGFILE);
63 snprintf(_logfile, 256, "%s", LOGFILE);
65 fp = fopen(_logfile, "a");
68 /* Maybe log to syslog if the log file is not available. */
71 (void)fprintf(fp,"%d/%02d/%02d %02d:%02d:%02d ",
72 p->tm_year+1900,p->tm_mon+1,
73 p->tm_mday,p->tm_hour,p->tm_min,p->tm_sec);
74 (void)vfprintf(fp, msg, args);
76 (void)fprintf(fp, "\r\n");
78 (void)fprintf(fp, "\n");
85 /* Only if not in daemon mode */
89 (void)fprintf(stderr,"%d/%02d/%02d %02d:%02d:%02d ",
90 p->tm_year+1900,p->tm_mon+1 ,p->tm_mday,
91 p->tm_hour,p->tm_min,p->tm_sec);
92 (void)vfprintf(stderr, msg, args2);
94 (void)fprintf(stderr, "\r\n");
96 (void)fprintf(stderr, "\n");
101 /* args2 must be ended here */
106 void debug1(const char * msg,...)
119 void debug2(const char * msg,...)
130 void merror(const char * msg,... )
138 void verbose(const char * msg,... )
146 /* Only logs to a file */
147 void log2file(const char * msg,... )
153 /* We set daemon flag to 1, so nothing is printed to the terminal */
154 dbg_tmp = daemon_flag;
158 daemon_flag = dbg_tmp;
163 void ErrorExit(const char *msg, ...)
193 void print_out(const char *msg, ...)
198 /* Print to stderr */
199 (void)vfprintf(stderr, msg, args);
202 (void)fprintf(stderr, "\r\n");
204 (void)fprintf(stderr, "\n");