Added optional millisecond precision to logfiles and created the changelog document.

This commit is contained in:
Markus Makela 2015-02-24 18:10:16 +02:00
parent b4fa4cc1c1
commit ad49c5f402
7 changed files with 106 additions and 9 deletions

View File

@ -0,0 +1,11 @@
#Changelog
These are the changes introduced in MaxScale version 1.0.6
* New modules added
* Binlog router
* Firewall filter
* Multi-Master monitor
* RabbitMQ logging filter
* Added option to use high precision timestamps in logging
* Readwritesplit router now returns the master server's response

View File

@ -56,6 +56,16 @@ threads=1
It should be noted that additional threads will be created to execute other internal services within MaxScale. This setting is used to configure the number of threads that will be used to manage the user connections.
### `ms_timestamp`
Enable or disable the high precision timestamps in logfiles. Enabling this adds millisecond precision to all logfile timestamps.
```
# Valid options are:
# ms_timestamp=<0|1>
ms_timestamp=1
```
### `log_messages`
Enable or disable logging of status messages. This logfile is enabled by default and contains information about the modules MaxScale is using and details about the configuration.

View File

@ -51,6 +51,7 @@ static int block_start_index;
static int prevval;
static simple_mutex_t msg_mutex;
#endif
static int highprec = 0;
/**
* Variable holding the enabled logfiles information.
* Used from log users to check enabled logs prior calling
@ -696,9 +697,11 @@ static int logmanager_write_log(
else
{
sesid_str_len = 0;
}
timestamp_len = get_timestamp_len();
}
if(highprec)
timestamp_len = get_timestamp_len_hp();
else
timestamp_len = get_timestamp_len();
cmplen = sesid_str_len > 0 ? sesid_str_len - sizeof(char) : 0;
/** Find out how much can be safely written with current block size */
@ -758,8 +761,10 @@ static int logmanager_write_log(
* to wp.
* Returned timestamp_len doesn't include terminating null.
*/
timestamp_len = snprint_timestamp(wp, timestamp_len);
if(highprec)
timestamp_len = snprint_timestamp_hp(wp, timestamp_len);
else
timestamp_len = snprint_timestamp(wp, timestamp_len);
if (sesid_str_len != 0)
{
/**
@ -3077,3 +3082,8 @@ void skygw_log_sync_all(void)
skygw_message_send(lm->lm_logmes);
skygw_message_wait(lm->lm_clientmes);
}
void skygw_set_highp(int val)
{
highprec = val;
}

View File

@ -119,7 +119,7 @@ int skygw_log_write_flush(logfile_id_t id, const char* format, ...);
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);
EXTERN_C_BLOCK_END
const char* get_trace_prefix_default(void);

View File

@ -1219,6 +1219,10 @@ int i;
{
gateway.pollsleep = atoi(value);
}
else if (strcmp(name, "ms_timestamp") == 0)
{
skygw_set_highp(atoi(value));
}
else
{
for (i = 0; lognames[i].logname; i++)

View File

@ -27,12 +27,18 @@
#include <regex.h>
#include "skygw_debug.h"
#include <skygw_types.h>
#include <sys/time.h>
#include "skygw_utils.h"
const char* timestamp_formatstr = "%04d-%02d-%02d %02d:%02d:%02d ";
/** One for terminating '\0' */
const size_t timestamp_len = (4+1 +2+1 +2+1 +2+1 +2+1 +2+3 +1) * sizeof(char);
const char* timestamp_formatstr_hp = "%04d-%02d-%02d %02d:%02d:%02d.%03d ";
/** One for terminating '\0' */
const size_t timestamp_len_hp = (4+1 +2+1 +2+1 +2+1 +2+1 +2+1+3+3 +1) * sizeof(char);
/** Single-linked list for storing test cases */
struct slist_node_st {
@ -667,6 +673,10 @@ size_t get_timestamp_len(void)
return timestamp_len;
}
size_t get_timestamp_len_hp(void)
{
return timestamp_len_hp;
}
/**
* @node Generate and write a timestamp to location passed as argument
* by using at most tslen characters.
@ -689,15 +699,16 @@ size_t snprint_timestamp(
time_t t;
struct tm tm;
size_t rval;
struct timeval tv;
if (p_ts == NULL) {
rval = 0;
goto retblock;
}
/** Generate timestamp */
t = time(NULL);
tm = *(localtime(&t));
gettimeofday(&tv,NULL);
tm = *(localtime(&tv.tv_sec));
snprintf(p_ts,
MIN(tslen,timestamp_len),
timestamp_formatstr,
@ -707,7 +718,56 @@ size_t snprint_timestamp(
tm.tm_hour,
tm.tm_min,
tm.tm_sec);
rval = strlen(p_ts)*sizeof(char);
retblock:
return rval;
}
/**
* @node Generate and write a timestamp to location passed as argument
* by using at most tslen characters. This will use millisecond precision.
*
* Parameters:
* @param p_ts - in, use
* Write position in memory. Must be filled with at least
* <timestamp_len> zeroes
*
* @return Length of string written to p_ts. Length includes terminating '\0'.
*
*
* @details (write detailed description here)
*
*/
size_t snprint_timestamp_hp(
char* p_ts,
size_t tslen)
{
time_t t;
struct tm tm;
size_t rval;
struct timeval tv;
int usec;
if (p_ts == NULL) {
rval = 0;
goto retblock;
}
/** Generate timestamp */
gettimeofday(&tv,NULL);
tm = *(localtime(&tv.tv_sec));
usec = tv.tv_usec/1000;
snprintf(p_ts,
MIN(tslen,timestamp_len_hp),
timestamp_formatstr_hp,
tm.tm_year+1900,
tm.tm_mon+1,
tm.tm_mday,
tm.tm_hour,
tm.tm_min,
tm.tm_sec,
usec);
rval = strlen(p_ts)*sizeof(char);
retblock:
return rval;

View File

@ -125,7 +125,9 @@ skygw_thr_state_t skygw_thread_get_state(skygw_thread_t* thr);
pthread_t skygw_thread_gettid(skygw_thread_t* thr);
size_t get_timestamp_len(void);
size_t get_timestamp_len_hp(void);
size_t snprint_timestamp(char* p_ts, size_t tslen);
size_t snprint_timestamp_hp(char* p_ts, size_t tslen);
EXTERN_C_BLOCK_BEGIN