1 /* @(#) $Id: ./src/shared/debug_op.c, 2011/09/08 dcid Exp $
4 /* Copyright (C) 2009 Trend Micro Inc.
7 * This program is a free software; you can redistribute it
8 * and/or modify it under the terms of the GNU General Public
9 * License (version 2) as published by the FSF - Free Software
14 #include "headers/shared.h"
25 /* For internal logs */
28 #define LOGFILE "/logs/ossec.log"
30 #define LOGFILE "ossec.log"
36 void _log(const char * msg,va_list args)
41 /* For the stderr print */
49 /* Duplicating args */
53 /* If under chroot, log directly to /logs/ossec.log */
56 fp = fopen(LOGFILE, "a");
62 snprintf(_logfile, 256, "%s%s", DEFAULTDIR, LOGFILE);
64 snprintf(_logfile, 256, "%s", LOGFILE);
66 fp = fopen(_logfile, "a");
69 /* Maybe log to syslog if the log file is not available. */
72 (void)fprintf(fp,"%d/%02d/%02d %02d:%02d:%02d ",
73 p->tm_year+1900,p->tm_mon+1,
74 p->tm_mday,p->tm_hour,p->tm_min,p->tm_sec);
75 (void)vfprintf(fp, msg, args);
77 (void)fprintf(fp, "\r\n");
79 (void)fprintf(fp, "\n");
86 /* Only if not in daemon mode */
90 (void)fprintf(stderr,"%d/%02d/%02d %02d:%02d:%02d ",
91 p->tm_year+1900,p->tm_mon+1 ,p->tm_mday,
92 p->tm_hour,p->tm_min,p->tm_sec);
93 (void)vfprintf(stderr, msg, args2);
95 (void)fprintf(stderr, "\r\n");
97 (void)fprintf(stderr, "\n");
102 /* args2 must be ended here */
107 void debug1(const char * msg,...)
120 void debug2(const char * msg,...)
131 void merror(const char * msg,... )
139 void verbose(const char * msg,... )
147 /* Only logs to a file */
148 void log2file(const char * msg,... )
154 /* We set daemon flag to 1, so nothing is printed to the terminal */
155 dbg_tmp = daemon_flag;
159 daemon_flag = dbg_tmp;
164 void ErrorExit(const char *msg, ...)
194 void print_out(const char *msg, ...)
199 /* Print to stderr */
200 (void)vfprintf(stderr, msg, args);
203 (void)fprintf(stderr, "\r\n");
205 (void)fprintf(stderr, "\n");