9 static const char rcsid[] __attribute__((used)) =
"$Id: SimpleLogFormat.cpp 1653 2016-02-28 19:54:59Z sella $";
11 #include "SimpleLogFormat.h"
13 #include "../Exception.h"
21 #define BUFFER_SIZE (64 * 1024)
23 using namespace sella::util;
29 const std::string SimpleLogFormat::format(
int priority,
const char *stamp,
const char *func,
const char *file,
int line,
const sella::Exception &e,
const char *message)
throw () {
30 char buffer[BUFFER_SIZE];
32 if (message == NULL || message[0] ==
'\0') {
33 snprintf(buffer,
sizeof(buffer),
"%s [%s:%d %s]", e.what(), e.getFile().c_str(), e.getLine(), e.getFunction().c_str());
35 snprintf(buffer,
sizeof(buffer),
"%s - %s [%s:%d %s]", message, e.what(), e.getFile().c_str(), e.getLine(), e.getFunction().c_str());
38 return std::string(buffer);
41 const std::string SimpleLogFormat::format(
int priority,
const char *stamp,
const char *func,
const char *file,
int line,
const char *message)
throw () {
42 char buffer[BUFFER_SIZE];
44 snprintf(buffer,
sizeof(buffer),
"%s", message);
46 return std::string(buffer);
49 const std::string SimpleLogFormat::format(
int priority,
const char *stamp,
const char *func,
const char *file,
int line,
const char *option,
const char *message)
throw () {
50 char buffer[BUFFER_SIZE];
52 snprintf(buffer,
sizeof(buffer),
"%s {%s}", message, option);
54 return std::string(buffer);