summaryrefslogtreecommitdiff
path: root/cesar/host
diff options
context:
space:
mode:
authorCeline Buret2012-01-13 16:27:58 +0100
committerCeline Buret2012-04-12 14:26:53 +0200
commite50c8cfc7de9e375c8d0ce4a1820860a52cb1e8f (patch)
tree5d1e21c3b5a63e0d8a43cd7dacfb726ad0355c2b /cesar/host
parentea8a5d730db3d1e20b35d20e7163f1427831e564 (diff)
cesar/{host,maximus}: warn user if log is truncated, refs #43
Until now, log was truncated silently if its length reached the max log length. With this commit, user is informed when the station log is too big and truncated.
Diffstat (limited to 'cesar/host')
-rw-r--r--cesar/host/station/src/station.c12
-rw-r--r--cesar/host/station/station.h1
2 files changed, 9 insertions, 4 deletions
diff --git a/cesar/host/station/src/station.c b/cesar/host/station/src/station.c
index dab17adb1a..f645eab1fe 100644
--- a/cesar/host/station/src/station.c
+++ b/cesar/host/station/src/station.c
@@ -36,6 +36,8 @@
#include <sys/un.h>
#endif
+#define STATION_BUFFER_SIZE (STATION_MAX_LOG_SIZE + 2)
+
/* awfull, but needed */
static sci_ctx_t _my_sci;
static netclock_ctx_t _my_netclock;
@@ -454,8 +456,8 @@ int station_log_set_level(station_ctx_t *station, station_log_level_t level)
...)
{
va_list va_args;
- int hdr_len;
- static char buffer[STATION_MAX_LOG_SIZE];
+ int hdr_len, ret = 0;
+ static char buffer[STATION_BUFFER_SIZE];
if((station == NULL)
|| (station->status == STATION_STATUS_INIT)
@@ -500,13 +502,15 @@ int station_log_set_level(station_ctx_t *station, station_log_level_t level)
write(station->pipe_log_fd, buffer, hdr_len);
/* build body and send it */
- buffer[STATION_MAX_LOG_SIZE - 1] = '\0';
+ buffer[STATION_BUFFER_SIZE - 1] = '\0';
va_start(va_args, format);
- vsnprintf(buffer, STATION_MAX_LOG_SIZE - 1, format, va_args);
+ ret = vsnprintf (buffer, STATION_BUFFER_SIZE - 1, format, va_args);
va_end (va_args);
write(station->pipe_log_fd, buffer, strlen(buffer));
/* send CR */
+ if (ret == STATION_MAX_LOG_SIZE)
+ write (station->pipe_log_fd, STATION_MAX_LOG_MSG, strlen (STATION_MAX_LOG_MSG));
write(station->pipe_log_fd, "\n", 1);
return;
diff --git a/cesar/host/station/station.h b/cesar/host/station/station.h
index 8f5c54999c..774caf8c2e 100644
--- a/cesar/host/station/station.h
+++ b/cesar/host/station/station.h
@@ -33,6 +33,7 @@
#define STATION_SOCK_PATH STATION_PIPE_PATH
#define STATION_SOCK_PREFIX STATION_PIPE_PREFIX
#define STATION_MAX_LOG_SIZE 4096
+#define STATION_MAX_LOG_MSG " [...] <WARNING> Log exceeds max size"
#define STATION_MAX_SOCK_BUFFER_SIZE (256*1024)
#define STATION_MAX_FD 16