summaryrefslogtreecommitdiffstats
path: root/src/server/memlog.c
diff options
context:
space:
mode:
authorsr2012-09-03 15:27:36 +0200
committersr2012-09-03 15:27:36 +0200
commita55be46ec7a281f5c3d41d48edf32e57ef5e4ba1 (patch)
treed375eaf63e03a6e1b5e199712735a68b448c6d97 /src/server/memlog.c
parent[SERVER] Add list of trusted servers and namespaces (load, display) (diff)
downloaddnbd3-a55be46ec7a281f5c3d41d48edf32e57ef5e4ba1.tar.gz
dnbd3-a55be46ec7a281f5c3d41d48edf32e57ef5e4ba1.tar.xz
dnbd3-a55be46ec7a281f5c3d41d48edf32e57ef5e4ba1.zip
[*] Fixed and unified formatting
Diffstat (limited to 'src/server/memlog.c')
-rw-r--r--src/server/memlog.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/server/memlog.c b/src/server/memlog.c
index 9809e64..6d4ec09 100644
--- a/src/server/memlog.c
+++ b/src/server/memlog.c
@@ -58,11 +58,11 @@ void memlogf(const char *fmt, ...)
va_list ap;
int ret;
time_t rawtime;
- struct tm * timeinfo;
+ struct tm *timeinfo;
time(&rawtime);
timeinfo = localtime(&rawtime);
pthread_spin_lock(&logLock);
- LogLine * const line = (LogLine *)&(logBuffer[bufferPos % LINE_COUNT]);
+ LogLine *const line = (LogLine *)&(logBuffer[bufferPos % LINE_COUNT]);
const size_t offset = strftime(line->text, LINE_LEN, "[%d.%m. %H:%M:%S] ", timeinfo);
if (offset == 0) *line->text = '\0';
va_start(ap, fmt);
@@ -79,7 +79,7 @@ void memlogf(const char *fmt, ...)
puts(line->text);
}
-char * fetchlog(int maxlines)
+char *fetchlog(int maxlines)
{
if (!logBuffer) return NULL;
if (maxlines <= 0 || maxlines > LINE_COUNT) maxlines = LINE_COUNT;
@@ -88,8 +88,10 @@ char * fetchlog(int maxlines)
//printf("Outputting log from %d to %d\n", start, bufferPos);
pthread_spin_lock(&logLock);
// Determine required buffer space for all log lines
- for (i = start; i < bufferPos; ++i) {
- if (logBuffer[i % LINE_COUNT].len > 0) {
+ for (i = start; i < bufferPos; ++i)
+ {
+ if (logBuffer[i % LINE_COUNT].len > 0)
+ {
len += logBuffer[i % LINE_COUNT].len + 1;
}
}
@@ -99,9 +101,11 @@ char * fetchlog(int maxlines)
if (retval == NULL) goto endFunction;
// Concatenate all log lines, delimit using '\n'
char *pos = retval;
- for (i = start; i < bufferPos; ++i) {
- LogLine * const line = (LogLine *)&(logBuffer[i % LINE_COUNT]);
- if (line->len > 0) {
+ for (i = start; i < bufferPos; ++i)
+ {
+ LogLine *const line = (LogLine *)&(logBuffer[i % LINE_COUNT]);
+ if (line->len > 0)
+ {
memcpy(pos, (char *)line->text, line->len);
pos += line->len;
*pos++ = '\n';