15
15
* You should have received a copy of the GNU General Public License
16
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
19
* Original author: Paul McCullagh (H&G2JCtL)
20
20
* Continued development: Barry Leslie
174
void CSLog::log_va(CSThread *self, int level, const char *func, const char *file, int line, const char *fmt, va_list ap)
176
char buffer[DEFAULT_LOG_BUFFER_SIZE];
177
char *log_string = NULL;
181
#if !defined(va_copy) || defined(OS_SOLARIS)
184
len = vsnprintf(buffer, DEFAULT_LOG_BUFFER_SIZE-1, fmt, ap);
185
if (len > DEFAULT_LOG_BUFFER_SIZE-1)
186
len = DEFAULT_LOG_BUFFER_SIZE-1;
190
/* Use the buffer, unless it is too small */
194
if (vsnprintf(buffer, DEFAULT_LOG_BUFFER_SIZE, fmt, ap) >= DEFAULT_LOG_BUFFER_SIZE) {
195
if (vasprintf(&log_string, fmt, ap2) == -1)
203
log(self, func, file, line, level, log_string);
205
if (log_string != buffer)
212
void CSLog::logf(CSThread *self, int level, const char *fmt, ...)
217
log_va(self, level, NULL, NULL, 0, fmt, ap);
221
void CSLog::logf(CSThread *self, int level, const char *func, const char *file, int line, const char *fmt, ...)
226
log_va(self, level, func, file, line, fmt, ap);