summaryrefslogtreecommitdiff
path: root/openvpn/src
diff options
context:
space:
mode:
Diffstat (limited to 'openvpn/src')
-rw-r--r--openvpn/src/openvpn/error.c29
-rw-r--r--openvpn/src/openvpn/error.h2
-rw-r--r--openvpn/src/openvpn/manage.h2
-rw-r--r--openvpn/src/openvpn/options.c8
-rw-r--r--openvpn/src/openvpn/options.h1
5 files changed, 40 insertions, 2 deletions
diff --git a/openvpn/src/openvpn/error.c b/openvpn/src/openvpn/error.c
index 98611a1b..106213db 100644
--- a/openvpn/src/openvpn/error.c
+++ b/openvpn/src/openvpn/error.c
@@ -86,6 +86,10 @@ static bool std_redir; /* GLOBAL */
/* Should messages be written to the syslog? */
static bool use_syslog; /* GLOBAL */
+/* Should stdout/stderr be be parsable and always be prefixed with time
+ * and message flags */
+static bool parsable_output; /* GLOBAL */
+
/* Should timestamps be included on messages to stdout/stderr? */
static bool suppress_timestamps; /* GLOBAL */
@@ -159,10 +163,18 @@ set_suppress_timestamps (bool suppressed)
}
void
+set_parsable_output (bool parsable)
+{
+ parsable_output = parsable;
+}
+
+
+void
error_reset ()
{
use_syslog = std_redir = false;
suppress_timestamps = false;
+ parsable_output = false;
x_debug_level = 1;
mute_cutoff = 0;
mute_count = 0;
@@ -334,7 +346,22 @@ void x_msg_va (const unsigned int flags, const char *format, va_list arglist)
FILE *fp = msg_fp(flags);
const bool show_usec = check_debug_level (DEBUG_LEVEL_USEC_TIME);
- if ((flags & M_NOPREFIX) || suppress_timestamps)
+ if (parsable_output)
+ {
+ struct timeval tv;
+ gettimeofday (&tv, NULL);
+
+ fprintf (fp, "%ld.%06d %x %s%s%s%s",
+ tv.tv_sec,
+ tv.tv_usec,
+ flags,
+ prefix,
+ prefix_sep,
+ m1,
+ (flags&M_NOLF) ? "" : "\n");
+
+ }
+ else if ((flags & M_NOPREFIX) || suppress_timestamps)
{
fprintf (fp, "%s%s%s%s",
prefix,
diff --git a/openvpn/src/openvpn/error.h b/openvpn/src/openvpn/error.h
index 27c48b69..5571bfdb 100644
--- a/openvpn/src/openvpn/error.h
+++ b/openvpn/src/openvpn/error.h
@@ -194,6 +194,8 @@ void error_reset (void);
void errors_to_stderr (void);
void set_suppress_timestamps (bool suppressed);
+void set_parsable_output (bool parsable);
+
#define SDL_CONSTRAIN (1<<0)
bool set_debug_level (const int level, const unsigned int flags);
diff --git a/openvpn/src/openvpn/manage.h b/openvpn/src/openvpn/manage.h
index 962b5bc4..dc3ade10 100644
--- a/openvpn/src/openvpn/manage.h
+++ b/openvpn/src/openvpn/manage.h
@@ -34,7 +34,7 @@
#define MANAGEMENT_VERSION 1
#define MANAGEMENT_N_PASSWORD_RETRIES 3
-#define MANAGEMENT_LOG_HISTORY_INITIAL_SIZE 100
+#define MANAGEMENT_LOG_HISTORY_INITIAL_SIZE 200
#define MANAGEMENT_ECHO_BUFFER_SIZE 100
#define MANAGEMENT_STATE_BUFFER_SIZE 100
diff --git a/openvpn/src/openvpn/options.c b/openvpn/src/openvpn/options.c
index d1c5583f..66fb8962 100644
--- a/openvpn/src/openvpn/options.c
+++ b/openvpn/src/openvpn/options.c
@@ -342,6 +342,7 @@ static const char usage_message[] =
"--log file : Output log to file which is created/truncated on open.\n"
"--log-append file : Append log to file, or create file if nonexistent.\n"
"--suppress-timestamps : Don't log timestamps to stdout/stderr.\n"
+ "--parsable-output : Always log timestamp, message flags to stdout/stderr.\n"
"--writepid file : Write main process ID to file.\n"
"--nice n : Change process priority (>0 = lower, <0 = higher).\n"
"--echo [parms ...] : Echo parameters to log output.\n"
@@ -1510,6 +1511,7 @@ show_settings (const struct options *o)
SHOW_INT (inetd);
SHOW_BOOL (log);
SHOW_BOOL (suppress_timestamps);
+ SHOW_BOOL (parsable_output);
SHOW_INT (nice);
SHOW_INT (verbosity);
SHOW_INT (mute);
@@ -4658,6 +4660,12 @@ add_option (struct options *options,
options->suppress_timestamps = true;
set_suppress_timestamps(true);
}
+ else if (streq (p[0], "parsable-output"))
+ {
+ VERIFY_PERMISSION (OPT_P_GENERAL);
+ options->parsable_output = true;
+ set_parsable_output(true);
+ }
else if (streq (p[0], "log-append") && p[1])
{
VERIFY_PERMISSION (OPT_P_GENERAL);
diff --git a/openvpn/src/openvpn/options.h b/openvpn/src/openvpn/options.h
index 86760bbf..99877da7 100644
--- a/openvpn/src/openvpn/options.h
+++ b/openvpn/src/openvpn/options.h
@@ -304,6 +304,7 @@ struct options
bool log;
bool suppress_timestamps;
+ bool parsable_output;
int nice;
int verbosity;
int mute;