METHOD(logger_t, log_, void,
private_file_logger_t *this, debug_t group, level_t level, int thread,
- ike_sa_t* ike_sa, char *message)
+ ike_sa_t* ike_sa, const char *message)
{
char timestr[128], namestr[128] = "";
- char *current = message, *next;
+ const char *current = message, *next;
struct tm tm;
time_t t;
/* prepend a prefix in front of every line */
this->mutex->lock(this->mutex);
- while (current)
+ while (TRUE)
{
next = strchr(current, '\n');
- if (next)
- {
- *(next++) = '\0';
- }
if (this->time_format)
{
- fprintf(this->out, "%s %.2d[%N]%s %s\n",
- timestr, thread, debug_names, group, namestr, current);
+ fprintf(this->out, "%s %.2d[%N]%s ",
+ timestr, thread, debug_names, group, namestr);
}
else
{
- fprintf(this->out, "%.2d[%N]%s %s\n",
- thread, debug_names, group, namestr, current);
+ fprintf(this->out, "%.2d[%N]%s ",
+ thread, debug_names, group, namestr);
+ }
+ if (next == NULL)
+ {
+ fprintf(this->out, "%s\n", current);
+ break;
}
- current = next;
+ fprintf(this->out, "%.*s\n", (int)(next - current), current);
+ current = next + 1;
}
this->mutex->unlock(this->mutex);
}
* @param message log message
*/
void (*log)(logger_t *this, debug_t group, level_t level, int thread,
- ike_sa_t *ike_sa, char* message);
+ ike_sa_t *ike_sa, const char *message);
/**
* Get the desired log level for a debug group. This is called during
METHOD(logger_t, log_, void,
private_sys_logger_t *this, debug_t group, level_t level, int thread,
- ike_sa_t* ike_sa, char *message)
+ ike_sa_t* ike_sa, const char *message)
{
char groupstr[4], namestr[128] = "";
- char *current = message, *next;
+ const char *current = message, *next;
/* cache group name and optional name string */
snprintf(groupstr, sizeof(groupstr), "%N", debug_names, group);
/* do a syslog for every line */
this->mutex->lock(this->mutex);
- while (current)
+ while (TRUE)
{
next = strchr(current, '\n');
- if (next)
+ if (next == NULL)
{
- *(next++) = '\0';
+ syslog(this->facility | LOG_INFO, "%.2d[%s]%s %s\n",
+ thread, groupstr, namestr, current);
+ break;
}
- syslog(this->facility|LOG_INFO, "%.2d[%s]%s %s\n",
- thread, groupstr, namestr, current);
- current = next;
+ syslog(this->facility | LOG_INFO, "%.2d[%s]%s %.*s\n",
+ thread, groupstr, namestr, (int)(next - current), current);
+ current = next + 1;
}
this->mutex->unlock(this->mutex);
}
METHOD(logger_t, listener_log, void,
interface_logger_t *this, debug_t group, level_t level, int thread,
- ike_sa_t *ike_sa, char* message)
+ ike_sa_t *ike_sa, const char *message)
{
ike_sa_t *target;
* See header
*/
bool controller_cb_empty(void *param, debug_t group, level_t level,
- ike_sa_t *ike_sa, char *message)
+ ike_sa_t *ike_sa, const char *message)
{
return TRUE;
}
* @return FALSE to return from called controller method
*/
typedef bool (*controller_cb_t)(void* param, debug_t group, level_t level,
- ike_sa_t* ike_sa, char* message);
+ ike_sa_t* ike_sa, const char *message);
/**
* Empty callback function for controller_t methods.
* this function to the controller methods.
*/
bool controller_cb_empty(void *param, debug_t group, level_t level,
- ike_sa_t *ike_sa, char *message);
+ ike_sa_t *ike_sa, const char *message);
typedef struct controller_t controller_t;
mutex_t *mutex;
};
-
METHOD(logger_t, log_, void,
private_android_logger_t *this, debug_t group, level_t level,
- int thread, ike_sa_t* ike_sa, char *message)
+ int thread, ike_sa_t* ike_sa, const char *message)
{
int prio = level > 1 ? ANDROID_LOG_DEBUG : ANDROID_LOG_INFO;
char sgroup[16];
- char *current = message, *next;
+ const char *current = message, *next;
snprintf(sgroup, sizeof(sgroup), "%N", debug_names, group);
this->mutex->lock(this->mutex);
- while (current)
+ while (TRUE)
{ /* log each line separately */
next = strchr(current, '\n');
- if (next)
+ if (next == NULL)
{
- *(next++) = '\0';
+ __android_log_print(prio, "charon", "%.2d[%s] %s\n",
+ thread, sgroup, current);
+ break;
}
- __android_log_print(prio, "charon", "%.2d[%s] %s\n",
- thread, sgroup, current);
- current = next;
+ __android_log_print(prio, "charon", "%.2d[%s] %.*s\n",
+ thread, sgroup, (int)(next - current), current);
+ current = next + 1;
}
this->mutex->unlock(this->mutex);
}
METHOD(logger_t, log_, void,
private_sql_logger_t *this, debug_t group, level_t level, int thread,
- ike_sa_t* ike_sa, char *message)
+ ike_sa_t* ike_sa, const char *message)
{
if (this->recursive->get(this->recursive))
{