logsys: Support hires timestamp

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
This commit is contained in:
Jan Friesse 2018-10-26 15:39:10 +02:00
parent bd338449ac
commit bd2fff5bb3
3 changed files with 33 additions and 15 deletions

View File

@ -203,8 +203,15 @@ static int corosync_main_config_format_set (
"%t ", NULL)) {
err = logsys_format_set(new_format_buffer);
}
} else
if (strcmp (value, "off") == 0) {
#ifdef QB_FEATURE_LOG_HIRES_TIMESTAMPS
} else if (strcmp (value, "hires") == 0) {
if(!insert_into_buffer(new_format_buffer,
sizeof(new_format_buffer),
"%T ", NULL)) {
err = logsys_format_set(new_format_buffer);
}
#endif
} else if (strcmp (value, "off") == 0) {
/* nothing to do here */
} else {
error_reason = "unknown value for timestamp";

View File

@ -567,17 +567,25 @@ int logsys_config_file_set (
static void
logsys_file_format_get(char* file_format, int buf_len)
{
char *per_t;
char *format_buffer_start;
char *str_pos;
file_format[0] = '\0';
per_t = strstr(format_buffer, "%t");
if (per_t) {
strcpy(file_format, "%t [%P] %H %N");
per_t += 2;
strncat(file_format, per_t, buf_len - strlen("%t [%P] %H %N"));
} else {
strcpy(file_format, "[%P] %H %N");
strncat(file_format, format_buffer, buf_len - strlen("[%P] %H %N"));
format_buffer_start = format_buffer;
if ((str_pos = strstr(format_buffer, "%t"))) {
strcpy(file_format, "%t ");
format_buffer_start = str_pos + 2;
}
if ((str_pos = strstr(format_buffer, "%T"))) {
strcpy(file_format, "%T ");
format_buffer_start = str_pos + 2;
}
strcat(file_format, "[%P] %H %N");
strncat(file_format, format_buffer_start, buf_len - strlen(file_format));
}
int logsys_format_set (const char *format)
@ -609,7 +617,7 @@ int logsys_format_set (const char *format)
}
/*
* This just goes through and remove %t and %p from
* This just goes through and remove %t, %T and %p from
* the format string for syslog.
*/
w = 0;
@ -622,7 +630,8 @@ int logsys_format_set (const char *format)
continue;
}
if (format_buffer[c] == 't' ||
format_buffer[c] == 'p') {
format_buffer[c] == 'p' ||
format_buffer[c] == 'T') {
c++;
} else {
c = reminder;

View File

@ -32,7 +32,7 @@
.\" * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
.\" * THE POSSIBILITY OF SUCH DAMAGE.
.\" */
.TH COROSYNC_CONF 5 2018-10-02 "corosync Man Page" "Corosync Cluster Engine Programmer's Manual"
.TH COROSYNC_CONF 5 2018-10-26 "corosync Man Page" "Corosync Cluster Engine Programmer's Manual"
.SH NAME
corosync.conf - corosync executive configuration file
@ -525,7 +525,9 @@ The following 3 options are valid only for the top level logging directive:
.TP
timestamp
This specifies that a timestamp is placed on all log messages.
This specifies that a timestamp is placed on all log messages. It can be one
of off (no timestamp), on (second precision timestamp) or
hires (millisecond precision timestamp - only when supported by LibQB).
The default is off.