Merge branch 'develop' into MXS-329-develop-20151111
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@ -18,6 +18,8 @@
|
||||
#if !defined(LOG_MANAGER_H)
|
||||
# define LOG_MANAGER_H
|
||||
|
||||
#include <syslog.h>
|
||||
|
||||
/*
|
||||
* We need a common.h file that is included by every component.
|
||||
*/
|
||||
@ -42,7 +44,6 @@ typedef enum
|
||||
LOGFILE_LAST = LOGFILE_DEBUG
|
||||
} logfile_id_t;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
FILEWRITER_INIT,
|
||||
@ -50,6 +51,13 @@ typedef enum
|
||||
FILEWRITER_DONE
|
||||
} filewriter_state_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
LOG_TARGET_DEFAULT = 0,
|
||||
LOG_TARGET_FS = 1, // File system
|
||||
LOG_TARGET_SHMEM = 2, // Shared memory
|
||||
} log_target_t;
|
||||
|
||||
/**
|
||||
* Thread-specific logging information.
|
||||
*/
|
||||
@ -124,78 +132,53 @@ typedef enum
|
||||
LOG_AUGMENTATION_MASK = (LOG_AUGMENT_WITH_FUNCTION)
|
||||
} log_augmentation_t;
|
||||
|
||||
/**
|
||||
* LOG_FLUSH_NO Do not flush after writing.
|
||||
* LOG_FLUSH_YES Flush after writing.
|
||||
*/
|
||||
enum log_flush
|
||||
{
|
||||
LOG_FLUSH_NO = 0,
|
||||
LOG_FLUSH_YES = 1
|
||||
};
|
||||
|
||||
EXTERN_C_BLOCK_BEGIN
|
||||
|
||||
extern int lm_enabled_logfiles_bitmask;
|
||||
extern ssize_t log_ses_count[];
|
||||
extern __thread log_info_t tls_log_info;
|
||||
|
||||
bool mxs_log_init(const char* ident, const char* logdir, log_target_t target);
|
||||
void mxs_log_finish(void);
|
||||
|
||||
int mxs_log_flush();
|
||||
int mxs_log_flush_sync();
|
||||
int mxs_log_rotate();
|
||||
int mxs_log_enable_priority(int priority);
|
||||
int mxs_log_disable_priority(int priority);
|
||||
|
||||
bool skygw_logmanager_init(const char* logdir, int argc, char* argv[]);
|
||||
void skygw_logmanager_done(void);
|
||||
void skygw_logmanager_exit(void);
|
||||
int mxs_log_set_priority_enabled(int priority, bool enabled);
|
||||
void mxs_log_set_syslog_enabled(bool enabled);
|
||||
void mxs_log_set_maxscalelog_enabled(bool enabled);
|
||||
void mxs_log_set_highprecision_enabled(bool enabled);
|
||||
void mxs_log_set_augmentation(int bits);
|
||||
|
||||
int mxs_log_message(int priority,
|
||||
const char* file, int line, const char* function,
|
||||
const char* format, ...);
|
||||
|
||||
/**
|
||||
* free private write buffer list
|
||||
*/
|
||||
void skygw_log_done(void);
|
||||
int skygw_log_write_context(logfile_id_t id,
|
||||
enum log_flush flush,
|
||||
const char* file, int line, const char* function,
|
||||
const char* format, ...);
|
||||
int skygw_log_flush(logfile_id_t id);
|
||||
void skygw_log_sync_all(void);
|
||||
int skygw_log_rotate(logfile_id_t id);
|
||||
int skygw_log_enable(logfile_id_t id);
|
||||
int skygw_log_disable(logfile_id_t id);
|
||||
void skygw_log_sync_all(void);
|
||||
void skygw_set_highp(int);
|
||||
void logmanager_enable_syslog(int);
|
||||
void logmanager_enable_maxscalelog(int);
|
||||
|
||||
inline int mxs_log_id_to_priority(logfile_id_t id)
|
||||
{
|
||||
if (id & LOGFILE_ERROR) return LOG_ERR;
|
||||
if (id & LOGFILE_MESSAGE) return LOG_NOTICE;
|
||||
if (id & LOGFILE_TRACE) return LOG_INFO;
|
||||
if (id & LOGFILE_DEBUG) return LOG_DEBUG;
|
||||
return LOG_ERR;
|
||||
}
|
||||
|
||||
#define skygw_log_write(id, format, ...)\
|
||||
skygw_log_write_context(id, LOG_FLUSH_NO, __FILE__, __LINE__, __func__, format, ##__VA_ARGS__)
|
||||
mxs_log_message(mxs_log_id_to_priority(id), __FILE__, __LINE__, __func__, format, ##__VA_ARGS__)
|
||||
|
||||
#define skygw_log_write_flush(id, format, ...)\
|
||||
skygw_log_write_context(id, LOG_FLUSH_YES, __FILE__, __LINE__, __func__, format, ##__VA_ARGS__)
|
||||
|
||||
/**
|
||||
* What augmentation if any should a logged message be augmented with.
|
||||
*
|
||||
* Currently this is a global setting and affects all loggers.
|
||||
*/
|
||||
void skygw_log_set_augmentation(int bits);
|
||||
int skygw_log_get_augmentation();
|
||||
#define skygw_log_write_flush(id, format, ...) skygw_log_write(id, format, ##__VA_ARGS__)
|
||||
|
||||
EXTERN_C_BLOCK_END
|
||||
|
||||
const char* get_logpath_default(void);
|
||||
|
||||
/**
|
||||
* Helper, not to be called directly.
|
||||
*/
|
||||
#define MXS_MESSAGE_FLUSH(id, format, ...)\
|
||||
do { if (LOG_IS_ENABLED(id)) { skygw_log_write_flush(id, format, ##__VA_ARGS__); } } while (false)
|
||||
|
||||
/**
|
||||
* Helper, not to be called directly.
|
||||
*/
|
||||
#define MXS_MESSAGE(id, format, ...)\
|
||||
do { if (LOG_IS_ENABLED(id)) { skygw_log_write(id, format, ##__VA_ARGS__); } } while (false)
|
||||
#define MXS_LOG_MESSAGE(priority, format, ...)\
|
||||
mxs_log_message(priority, __FILE__, __LINE__, __func__, format, ##__VA_ARGS__)
|
||||
|
||||
/**
|
||||
* Log an error, warning, notice, info, or debug message.
|
||||
@ -203,10 +186,10 @@ const char* get_logpath_default(void);
|
||||
* @param format The printf format of the message.
|
||||
* @param ... Arguments, depending on the format.
|
||||
*/
|
||||
#define MXS_ERROR(format, ...) MXS_MESSAGE_FLUSH(LOGFILE_ERROR, format, ##__VA_ARGS__)
|
||||
#define MXS_WARNING(format, ...) MXS_MESSAGE(LOGFILE_ERROR, format, ##__VA_ARGS__)
|
||||
#define MXS_NOTICE(format, ...) MXS_MESSAGE(LOGFILE_MESSAGE, format, ##__VA_ARGS__)
|
||||
#define MXS_INFO(format, ...) MXS_MESSAGE(LOGFILE_TRACE, format, ##__VA_ARGS__)
|
||||
#define MXS_DEBUG(format, ...) MXS_MESSAGE(LOGFILE_DEBUG, format, ##__VA_ARGS__)
|
||||
#define MXS_ERROR(format, ...) MXS_LOG_MESSAGE(LOG_ERR, format, ##__VA_ARGS__)
|
||||
#define MXS_WARNING(format, ...) MXS_LOG_MESSAGE(LOG_WARNING, format, ##__VA_ARGS__)
|
||||
#define MXS_NOTICE(format, ...) MXS_LOG_MESSAGE(LOG_NOTICE, format, ##__VA_ARGS__)
|
||||
#define MXS_INFO(format, ...) MXS_LOG_MESSAGE(LOG_INFO, format, ##__VA_ARGS__)
|
||||
#define MXS_DEBUG(format, ...) MXS_LOG_MESSAGE(LOG_DEBUG, format, ##__VA_ARGS__)
|
||||
|
||||
#endif /** LOG_MANAGER_H */
|
||||
|
@ -3,3 +3,4 @@ add_executable(testorder testorder.c ../../server/core/random_jkiss.c)
|
||||
target_link_libraries(testlog pthread log_manager utils fullcore)
|
||||
target_link_libraries(testorder pthread log_manager utils fullcore)
|
||||
add_test(NAME Internal-TestLogOrder COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/logorder.sh 200 0 1000 ${CMAKE_CURRENT_BINARY_DIR}/logorder.log)
|
||||
add_test(Internal-TestLog testlog)
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <libgen.h>
|
||||
#include <skygw_utils.h>
|
||||
#include <log_manager.h>
|
||||
|
||||
@ -52,6 +53,15 @@ static void* thr_run_morelog(void* data);
|
||||
#define TEST3
|
||||
#define TEST4
|
||||
|
||||
const char USAGE[]=
|
||||
"usage: %s [-t <#threads>]\n"
|
||||
"\n"
|
||||
"-t: Number of threads. Default is %d.\n";
|
||||
const int N_THR = 4;
|
||||
|
||||
#define TEST_ERROR(msg)\
|
||||
do { fprintf(stderr, "[%s:%d]: %s\n", basename(__FILE__), __LINE__, msg); } while (false)
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
int err = 0;
|
||||
@ -66,30 +76,34 @@ int main(int argc, char* argv[])
|
||||
time_t t;
|
||||
struct tm tm;
|
||||
char c;
|
||||
int nthr = 0;
|
||||
int log_argc = 0;
|
||||
char** log_argv = NULL;
|
||||
int nthr = N_THR;
|
||||
|
||||
while ((c = getopt(argc, argv, "t:")) != -1)
|
||||
{
|
||||
switch (c) {
|
||||
case 't':
|
||||
nthr = atoi(optarg);
|
||||
if (nthr <= 0)
|
||||
{
|
||||
err = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
err = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (nthr <= 0)
|
||||
if (err != 0)
|
||||
{
|
||||
fprintf(stderr, "Thread count argument is zero or "
|
||||
"negative. Exiting.\n");
|
||||
fprintf(stderr, USAGE, argv[0], N_THR);
|
||||
err = 1;
|
||||
goto return_err;
|
||||
}
|
||||
|
||||
printf("Using %d threads.\n", nthr);
|
||||
|
||||
thr = (thread_t **)calloc(1, nthr*sizeof(thread_t*));
|
||||
|
||||
if (thr == NULL)
|
||||
@ -99,14 +113,14 @@ int main(int argc, char* argv[])
|
||||
err = 1;
|
||||
goto return_err;
|
||||
}
|
||||
i = atexit(skygw_logmanager_exit);
|
||||
i = atexit(mxs_log_finish);
|
||||
|
||||
if (i != 0)
|
||||
{
|
||||
fprintf(stderr, "Couldn't register exit function.\n");
|
||||
}
|
||||
|
||||
succp = skygw_logmanager_init("/tmp", log_argc, log_argv);
|
||||
succp = mxs_log_init(NULL, "/tmp", LOG_TARGET_FS);
|
||||
|
||||
if (!succp)
|
||||
{
|
||||
@ -125,7 +139,7 @@ int main(int argc, char* argv[])
|
||||
tm.tm_min,
|
||||
tm.tm_sec);
|
||||
|
||||
skygw_logmanager_init("/tmp", log_argc, log_argv);
|
||||
mxs_log_init(NULL, "/tmp", LOG_TARGET_FS);
|
||||
logstr = ("First write with flush.");
|
||||
err = skygw_log_write_flush(LOGFILE_ERROR, logstr);
|
||||
|
||||
@ -138,14 +152,14 @@ int main(int argc, char* argv[])
|
||||
logstr = ("Fourth write, no flush. Next flush only.");
|
||||
err = skygw_log_write(LOGFILE_ERROR, logstr);
|
||||
|
||||
err = skygw_log_flush(LOGFILE_ERROR);
|
||||
err = mxs_log_flush();
|
||||
|
||||
logstr = "My name is %s %d years and %d months.";
|
||||
#if !defined(SS_DEBUG)
|
||||
skygw_log_enable(LOGFILE_TRACE);
|
||||
#endif
|
||||
err = skygw_log_write(LOGFILE_TRACE, logstr, "TraceyTracey", 3, 7);
|
||||
skygw_log_flush(LOGFILE_TRACE);
|
||||
mxs_log_flush();
|
||||
#if !defined(SS_DEBUG)
|
||||
skygw_log_enable(LOGFILE_TRACE);
|
||||
#endif
|
||||
@ -156,7 +170,7 @@ int main(int argc, char* argv[])
|
||||
#endif
|
||||
logstr = "My name is Stacey %s";
|
||||
err = skygw_log_write_flush(LOGFILE_TRACE, logstr, " ");
|
||||
skygw_logmanager_done();
|
||||
mxs_log_finish();
|
||||
#if !defined(SS_DEBUG)
|
||||
skygw_log_enable(LOGFILE_TRACE);
|
||||
#endif
|
||||
@ -173,7 +187,7 @@ int main(int argc, char* argv[])
|
||||
logstr = "Ph%dlip.";
|
||||
err = skygw_log_write(LOGFILE_TRACE, logstr, 1);
|
||||
|
||||
skygw_logmanager_init("/tmp", log_argc, log_argv);
|
||||
mxs_log_init(NULL, "/tmp", LOG_TARGET_FS);
|
||||
logstr = ("A terrible error has occurred!");
|
||||
err = skygw_log_write_flush(LOGFILE_ERROR, logstr);
|
||||
|
||||
@ -195,7 +209,7 @@ int main(int argc, char* argv[])
|
||||
"with us. Just me and my mom - and you, of course. Then, if you wish, we could "
|
||||
"listen to the radio and keep company for our little Steven, my mom's cat, you know.");
|
||||
err = skygw_log_write(LOGFILE_MESSAGE, logstr);
|
||||
skygw_logmanager_done();
|
||||
mxs_log_finish();
|
||||
|
||||
#if defined(TEST1)
|
||||
mes = skygw_message_init();
|
||||
@ -238,7 +252,7 @@ int main(int argc, char* argv[])
|
||||
pthread_join(thr[i]->tid, NULL);
|
||||
}
|
||||
/** This is to release memory */
|
||||
skygw_logmanager_done();
|
||||
mxs_log_finish();
|
||||
|
||||
simple_mutex_unlock(mtx);
|
||||
|
||||
@ -295,7 +309,7 @@ int main(int argc, char* argv[])
|
||||
pthread_join(thr[i]->tid, NULL);
|
||||
}
|
||||
/** This is to release memory */
|
||||
skygw_logmanager_done();
|
||||
mxs_log_finish();
|
||||
|
||||
simple_mutex_unlock(mtx);
|
||||
|
||||
@ -319,20 +333,20 @@ int main(int argc, char* argv[])
|
||||
#if !defined(SS_DEBUG)
|
||||
skygw_log_enable(LOGFILE_TRACE);
|
||||
#endif
|
||||
succp = mxs_log_init(NULL, "/tmp", LOG_TARGET_FS);
|
||||
ss_dassert(succp);
|
||||
|
||||
logstr = ("\tTEST 3 - test enabling and disabling logs.");
|
||||
err = skygw_log_write(LOGFILE_ERROR, logstr);
|
||||
ss_dassert(err == 0);
|
||||
|
||||
succp = skygw_logmanager_init("/tmp", log_argc, log_argv);
|
||||
ss_dassert(succp);
|
||||
|
||||
skygw_log_disable(LOGFILE_TRACE);
|
||||
|
||||
logstr = ("1.\tWrite once to ERROR and twice to MESSAGE log.");
|
||||
err = skygw_log_write(LOGFILE_MESSAGE, logstr);
|
||||
ss_dassert(err == 0);
|
||||
err = skygw_log_write(LOGFILE_TRACE, logstr);
|
||||
ss_dassert(err != 0); /**< Must fail */
|
||||
ss_dassert(err == 0);
|
||||
err = skygw_log_write(LOGFILE_ERROR, logstr);
|
||||
ss_dassert(err == 0);
|
||||
|
||||
@ -355,18 +369,18 @@ int main(int argc, char* argv[])
|
||||
err = skygw_log_write(LOGFILE_TRACE, logstr);
|
||||
ss_dassert(err == 0);
|
||||
err = skygw_log_write(LOGFILE_ERROR, logstr);
|
||||
ss_dassert(err != 0); /**< Must fail */
|
||||
ss_dassert(err == 0);
|
||||
|
||||
skygw_log_disable(LOGFILE_MESSAGE);
|
||||
skygw_log_disable(LOGFILE_TRACE);
|
||||
|
||||
logstr = ("4.\tWrite to none.");
|
||||
err = skygw_log_write(LOGFILE_MESSAGE, logstr);
|
||||
ss_dassert(err != 0); /**< Must fail */
|
||||
ss_dassert(err == 0);
|
||||
err = skygw_log_write(LOGFILE_TRACE, logstr);
|
||||
ss_dassert(err != 0); /**< Must fail */
|
||||
ss_dassert(err == 0);
|
||||
err = skygw_log_write(LOGFILE_ERROR, logstr);
|
||||
ss_dassert(err != 0); /**< Must fail */
|
||||
ss_dassert(err == 0);
|
||||
|
||||
skygw_log_enable(LOGFILE_ERROR);
|
||||
skygw_log_enable(LOGFILE_MESSAGE);
|
||||
@ -375,16 +389,16 @@ int main(int argc, char* argv[])
|
||||
err = skygw_log_write(LOGFILE_MESSAGE, logstr);
|
||||
ss_dassert(err == 0);
|
||||
err = skygw_log_write(LOGFILE_TRACE, logstr);
|
||||
ss_dassert(err != 0); /**< Must fail */
|
||||
ss_dassert(err == 0);
|
||||
err = skygw_log_write(LOGFILE_ERROR, logstr);
|
||||
ss_dassert(err == 0);
|
||||
|
||||
skygw_logmanager_done();
|
||||
mxs_log_finish();
|
||||
|
||||
#endif /* TEST 3 */
|
||||
|
||||
#if defined(TEST4)
|
||||
succp = skygw_logmanager_init("/tmp", log_argc, log_argv);
|
||||
succp = mxs_log_init(NULL, "/tmp", LOG_TARGET_FS);
|
||||
ss_dassert(succp);
|
||||
#if !defined(SS_DEBUG)
|
||||
skygw_log_enable(LOGFILE_TRACE);
|
||||
@ -401,6 +415,7 @@ int main(int argc, char* argv[])
|
||||
err = skygw_log_write(LOGFILE_MESSAGE, logstr);
|
||||
ss_dassert(err == 0);
|
||||
|
||||
skygw_log_enable(LOGFILE_TRACE);
|
||||
logstr = ("3.\tWrite to TRACE log only.");
|
||||
err = skygw_log_write(LOGFILE_TRACE, logstr);
|
||||
ss_dassert(err == 0);
|
||||
@ -415,11 +430,11 @@ int main(int argc, char* argv[])
|
||||
logstr = ("5.\tThis should not appear anywhere since MESSAGE "
|
||||
"is disabled.");
|
||||
err = skygw_log_write(LOGFILE_MESSAGE, logstr);
|
||||
ss_dassert(err != 0);
|
||||
ss_dassert(err == 0);
|
||||
|
||||
skygw_logmanager_done();
|
||||
mxs_log_finish();
|
||||
|
||||
succp = skygw_logmanager_init("/tmp", log_argc, log_argv);
|
||||
succp = mxs_log_init(NULL, "/tmp", LOG_TARGET_FS);
|
||||
ss_dassert(succp);
|
||||
#if !defined(SS_DEBUG)
|
||||
skygw_log_enable(LOGFILE_TRACE);
|
||||
@ -447,7 +462,7 @@ int main(int argc, char* argv[])
|
||||
logstr = ("10.\tThis should not appear anywhere since MESSAGE is "
|
||||
"disabled.");
|
||||
err = skygw_log_write_flush(LOGFILE_MESSAGE, logstr);
|
||||
ss_dassert(err != 0);
|
||||
ss_dassert(err == 0);
|
||||
|
||||
skygw_log_enable(LOGFILE_MESSAGE);
|
||||
|
||||
@ -473,7 +488,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
ss_dassert(err == 0);
|
||||
|
||||
skygw_logmanager_done();
|
||||
mxs_log_finish();
|
||||
|
||||
#endif /* TEST 4 */
|
||||
fprintf(stderr, ".. done.\n");
|
||||
@ -492,20 +507,18 @@ static void* thr_run(void* data)
|
||||
char* logstr;
|
||||
int err;
|
||||
|
||||
skygw_logmanager_init("/tmp", 0, NULL);
|
||||
skygw_logmanager_done();
|
||||
skygw_log_flush(LOGFILE_MESSAGE);
|
||||
mxs_log_init(NULL, "/tmp", LOG_TARGET_FS);
|
||||
mxs_log_flush();
|
||||
logstr = ("Hi, how are you?");
|
||||
err = skygw_log_write(LOGFILE_MESSAGE, logstr);
|
||||
|
||||
if (err != 0)
|
||||
{
|
||||
fprintf(stderr,"Error, log write failed.\n");
|
||||
TEST_ERROR("Error, log write failed.");
|
||||
}
|
||||
ss_dassert(err == 0);
|
||||
skygw_logmanager_done();
|
||||
skygw_log_flush(LOGFILE_TRACE);
|
||||
skygw_log_flush(LOGFILE_MESSAGE);
|
||||
mxs_log_finish();
|
||||
mxs_log_flush();
|
||||
logstr = ("I was wondering, you know, it has been such a lovely weather whole morning and "
|
||||
"I thought that would you like to come to my place and have a little piece of "
|
||||
"cheese with us. Just me and my mom - and you, of course. Then, if you wish, "
|
||||
@ -513,32 +526,34 @@ static void* thr_run(void* data)
|
||||
"cat, you know.");
|
||||
if (err != 0)
|
||||
{
|
||||
fprintf(stderr,"Error, log write failed.\n");
|
||||
TEST_ERROR("Error, log write failed.");
|
||||
}
|
||||
ss_dassert(err == 0);
|
||||
err = skygw_log_write(LOGFILE_MESSAGE, logstr);
|
||||
skygw_logmanager_init("/tmp", 0, NULL);
|
||||
mxs_log_init(NULL, "/tmp", LOG_TARGET_FS);
|
||||
logstr = ("Testing. One, two, three\n");
|
||||
err = skygw_log_write(LOGFILE_ERROR, logstr);
|
||||
if (err != 0)
|
||||
{
|
||||
fprintf(stderr,"Error, log write failed.\n");
|
||||
TEST_ERROR("Error, log write failed.");
|
||||
}
|
||||
ss_dassert(err == 0);
|
||||
skygw_logmanager_init("/tmp", 0, NULL);
|
||||
skygw_logmanager_init("/tmp", 0, NULL);
|
||||
skygw_log_flush(LOGFILE_ERROR);
|
||||
mxs_log_init(NULL, "/tmp", LOG_TARGET_FS);
|
||||
mxs_log_init(NULL, "/tmp", LOG_TARGET_FS);
|
||||
mxs_log_flush();
|
||||
logstr = ("For automatic and register variables, it is done each time the function or block is entered.");
|
||||
|
||||
#if !defined(SS_DEBUG)
|
||||
skygw_log_enable(LOGFILE_TRACE);
|
||||
#endif
|
||||
err = skygw_log_write(LOGFILE_TRACE, logstr);
|
||||
if (err != 0)
|
||||
{
|
||||
fprintf(stderr,"Error, log write failed.\n");
|
||||
TEST_ERROR("Error, log write failed.");
|
||||
}
|
||||
ss_dassert(err == 0);
|
||||
skygw_logmanager_done();
|
||||
skygw_logmanager_init("/tmp", 0, NULL);
|
||||
mxs_log_finish();
|
||||
mxs_log_init(NULL, "/tmp", LOG_TARGET_FS);
|
||||
logstr = ("Rather more surprising, at least at first sight, is the fact that a reference "
|
||||
"to a[i] can also be written as *(a+i). In evaluating a[i], C converts it to *(a+i) "
|
||||
"immediately; the two forms are equivalent. Applying the operatos & to both parts "
|
||||
@ -547,23 +562,23 @@ static void* thr_run(void* data)
|
||||
err = skygw_log_write(LOGFILE_ERROR, logstr);
|
||||
if (err != 0)
|
||||
{
|
||||
fprintf(stderr,"Error, log write failed.\n");
|
||||
TEST_ERROR("Error, log write failed.");
|
||||
}
|
||||
ss_dassert(err == 0);
|
||||
skygw_logmanager_init("/tmp", 0, NULL);
|
||||
skygw_logmanager_done();
|
||||
skygw_log_flush(LOGFILE_ERROR);
|
||||
skygw_logmanager_done();
|
||||
skygw_logmanager_done();
|
||||
mxs_log_init(NULL, "/tmp", LOG_TARGET_FS);
|
||||
mxs_log_finish();
|
||||
mxs_log_flush();
|
||||
mxs_log_finish();
|
||||
mxs_log_init(NULL, "/tmp", LOG_TARGET_FS);
|
||||
logstr = ("..and you?");
|
||||
err = skygw_log_write(LOGFILE_MESSAGE, logstr);
|
||||
if (err != 0)
|
||||
{
|
||||
fprintf(stderr,"Error, log write failed.\n");
|
||||
TEST_ERROR("Error, log write failed.");
|
||||
}
|
||||
ss_dassert(err == 0);
|
||||
skygw_logmanager_init("/tmp", 0, NULL);
|
||||
skygw_logmanager_init("/tmp", 0, NULL);
|
||||
mxs_log_finish();
|
||||
mxs_log_init(NULL, "/tmp", LOG_TARGET_FS);
|
||||
logstr = ("For automatic and register variables, it is done each time the function or block is entered.");
|
||||
#if !defined(SS_DEBUG)
|
||||
skygw_log_enable(LOGFILE_TRACE);
|
||||
@ -571,10 +586,10 @@ static void* thr_run(void* data)
|
||||
err = skygw_log_write(LOGFILE_TRACE, logstr);
|
||||
if (err != 0)
|
||||
{
|
||||
fprintf(stderr,"Error, log write failed.\n");
|
||||
TEST_ERROR("Error, log write failed.");
|
||||
}
|
||||
ss_dassert(err == 0);
|
||||
skygw_logmanager_init("/tmp", 0, NULL);
|
||||
mxs_log_init(NULL, "/tmp", LOG_TARGET_FS);
|
||||
logstr = ("Rather more surprising, at least at first sight, is the fact that a reference to "
|
||||
"a[i] can also be written as *(a+i). In evaluating a[i], C converts it to *(a+i) "
|
||||
"immediately; the two forms are equivalent. Applying the operatos & to both parts "
|
||||
@ -583,22 +598,23 @@ static void* thr_run(void* data)
|
||||
err = skygw_log_write(LOGFILE_ERROR, logstr);
|
||||
if (err != 0)
|
||||
{
|
||||
fprintf(stderr,"Error, log write failed.\n");
|
||||
TEST_ERROR("Error, log write failed.");
|
||||
}
|
||||
ss_dassert(err == 0);
|
||||
skygw_logmanager_init("/tmp", 0, NULL);
|
||||
mxs_log_init(NULL, "/tmp", LOG_TARGET_FS);
|
||||
logstr = ("..... and you too?");
|
||||
err = skygw_log_write(LOGFILE_MESSAGE, logstr);
|
||||
if (err != 0)
|
||||
{
|
||||
fprintf(stderr,"Error, log write failed.\n");
|
||||
TEST_ERROR("Error, log write failed.");
|
||||
}
|
||||
ss_dassert(err == 0);
|
||||
skygw_logmanager_done();
|
||||
mxs_log_finish();
|
||||
mxs_log_init(NULL, "/tmp", LOG_TARGET_FS);
|
||||
#if !defined(SS_DEBUG)
|
||||
skygw_log_enable(LOGFILE_TRACE);
|
||||
#endif
|
||||
skygw_log_flush(LOGFILE_TRACE);
|
||||
mxs_log_flush();
|
||||
logstr = ("For automatic and register variables, it is done each time the function or block is entered.");
|
||||
#if !defined(SS_DEBUG)
|
||||
skygw_log_enable(LOGFILE_TRACE);
|
||||
@ -606,28 +622,30 @@ static void* thr_run(void* data)
|
||||
err = skygw_log_write(LOGFILE_TRACE, logstr);
|
||||
if (err != 0)
|
||||
{
|
||||
fprintf(stderr,"Error, log write failed.\n");
|
||||
TEST_ERROR("Error, log write failed.");
|
||||
}
|
||||
ss_dassert(err == 0);
|
||||
skygw_logmanager_done();
|
||||
mxs_log_finish();
|
||||
mxs_log_init(NULL, "/tmp", LOG_TARGET_FS);
|
||||
logstr = ("Testing. One, two, three, four\n");
|
||||
err = skygw_log_write(LOGFILE_ERROR, logstr);
|
||||
if (err != 0)
|
||||
{
|
||||
fprintf(stderr,"Error, log write failed.\n");
|
||||
TEST_ERROR("Error, log write failed.");
|
||||
}
|
||||
ss_dassert(err == 0);
|
||||
skygw_logmanager_init("/tmp", 0, NULL);
|
||||
mxs_log_finish();
|
||||
mxs_log_init(NULL, "/tmp", LOG_TARGET_FS);
|
||||
logstr = ("Testing. One, two, three, .. where was I?\n");
|
||||
err = skygw_log_write(LOGFILE_ERROR, logstr);
|
||||
if (err != 0)
|
||||
{
|
||||
fprintf(stderr,"Error, log write failed.\n");
|
||||
TEST_ERROR("Error, log write failed.");
|
||||
}
|
||||
ss_dassert(err == 0);
|
||||
skygw_logmanager_init("/tmp", 0, NULL);
|
||||
skygw_logmanager_init("/tmp", 0, NULL);
|
||||
skygw_logmanager_done();
|
||||
mxs_log_finish();
|
||||
mxs_log_init(NULL, "/tmp", LOG_TARGET_FS);
|
||||
mxs_log_finish();
|
||||
simple_mutex_lock(td->mtx, true);
|
||||
*td->nactive -= 1;
|
||||
simple_mutex_unlock(td->mtx);
|
||||
|
@ -31,7 +31,6 @@ int main(int argc, char** argv)
|
||||
char cwd[1024];
|
||||
char tmp[2048];
|
||||
char *message;
|
||||
char** optstr;
|
||||
long msg_index = 1;
|
||||
struct timespec ts1;
|
||||
ts1.tv_sec = 0;
|
||||
@ -55,7 +54,6 @@ int main(int argc, char** argv)
|
||||
}
|
||||
|
||||
if (getcwd(cwd, sizeof(cwd)) == NULL ||
|
||||
(optstr = (char**)malloc(sizeof(char*) * 4)) == NULL ||
|
||||
(message = (char*)malloc(sizeof(char) * block_size)) == NULL)
|
||||
{
|
||||
fprintf(stderr,"Fatal Error, exiting...");
|
||||
@ -65,13 +63,11 @@ int main(int argc, char** argv)
|
||||
memset(tmp, 0, 1024);
|
||||
|
||||
sprintf(tmp, "%s", cwd);
|
||||
optstr[0] = strdup("log_manager");
|
||||
optstr[1] = NULL;
|
||||
|
||||
iterations = atoi(argv[1]);
|
||||
interval = atoi(argv[2]);
|
||||
|
||||
succp = skygw_logmanager_init(tmp, 1, optstr);
|
||||
succp = mxs_log_init(NULL, tmp, LOG_TARGET_FS);
|
||||
|
||||
if (!succp)
|
||||
{
|
||||
@ -111,13 +107,8 @@ int main(int argc, char** argv)
|
||||
nanosleep(&ts1, NULL);
|
||||
}
|
||||
|
||||
skygw_log_flush(LOGFILE_ERROR);
|
||||
skygw_logmanager_done();
|
||||
mxs_log_flush();
|
||||
mxs_log_finish();
|
||||
free(message);
|
||||
free(optstr[0]);
|
||||
free(optstr[1]);
|
||||
free(optstr[2]);
|
||||
free(optstr[3]);
|
||||
free(optstr);
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user