doveadm-log.c revision a10ed8c47534b4c6b6bf2711ccfe577e720a47b4
/* Copyright (c) 2010-2012 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "ioloop.h"
#include "istream.h"
#include "hash.h"
#include "str.h"
#include "strescape.h"
#include "time-util.h"
#include "master-service-private.h"
#include "master-service-settings.h"
#include "doveadm.h"
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <dirent.h>
#include <signal.h>
#define LAST_LOG_TYPE LOG_TYPE_PANIC
#define TEST_LOG_MSG_PREFIX "This is Dovecot's "
#define LOG_ERRORS_FNAME "log-errors"
#define LOG_TIMESTAMP_FORMAT "%b %d %H:%M:%S"
static void ATTR_NULL(2)
{
struct failure_context ctx;
unsigned int i;
for (i = 0; i < LAST_LOG_TYPE; i++) {
const char *prefix = failure_log_type_prefixes[i];
/* add timestamp so that syslog won't just write
"repeated message" text */
(unsigned int)ioloop_time);
}
}
{
}
struct log_find_file {
const char *path;
/* 1 << enum log_type */
unsigned int mask;
};
struct log_find_context {
struct hash_table *files;
};
{
struct log_find_file *file;
char *key;
}
}
static void
{
struct log_find_file *file;
struct dirent *d;
char *key;
unsigned int dir_len;
return;
}
if (d->d_name[0] == '.')
continue;
continue;
/* recursively go through all subdirectories */
}
}
}
{
for (i = 0; i < LAST_LOG_TYPE; i++) {
*type_r = i;
return TRUE;
}
}
return FALSE;
}
{
const char *line, *p;
int fd;
if (fd == -1)
return;
if (p == NULL)
continue;
p += strlen(TEST_LOG_MSG_PREFIX);
/* <type> log */
T_BEGIN {
} T_END;
}
}
{
struct hash_iterate_context *iter;
continue;
}
}
static void
{
const char *log_dir;
if (argc > 1)
else
return;
cmd_log_test(0, NULL);
/* give syslog some time to write the messages to files */
sleep(1);
}
{
const struct master_service_settings *set;
const char *log_file_path;
struct log_find_context ctx;
unsigned int i;
/* first get the paths that we know are used */
log_file_path = "";
if (*log_file_path != '\0') {
}
if (*log_file_path != '\0')
}
if (*log_file_path != '\0')
}
/* at least some logs were logged via syslog */
}
/* print them */
for (i = 0; i < LAST_LOG_TYPE; i++) {
struct hash_iterate_context *iter;
}
}
if (!found)
}
}
static void cmd_log_error_write(const char *const *args)
{
/* <type> <timestamp> <prefix> <text> */
const char *type_prefix = "?";
unsigned int type;
time_t t;
/* find type's prefix */
break;
}
}
t = 0;
}
}
{
int fd;
if (fd == -1)
else {
}
} T_END;
}
struct doveadm_cmd doveadm_cmd_log[] = {
};
void doveadm_register_log_commands(void)
{
unsigned int i;
for (i = 0; i < N_ELEMENTS(doveadm_cmd_log); i++)
}