Skip to content
Permalink
Browse files

Move tls/http statistics output to command/command.

This module already has the filtering required to keep these messages from being displayed by default for commands that output to stdout (e.g. info).
  • Loading branch information...
dwsteele committed May 28, 2019
1 parent 3e1b06a commit 3b3327eae6dd14f67f1002f094bd33ab7785f765
Showing with 23 additions and 24 deletions.
  1. +2 −2 src/Makefile.in
  2. +14 −0 src/command/command.c
  3. +0 −14 src/common/exit.c
  4. +6 −1 test/src/module/command/commandTest.c
  5. +1 −7 test/src/module/common/exitTest.c
@@ -212,7 +212,7 @@ command/archive/push/push.o: command/archive/push/push.c build.auto.h command/ar
command/backup/common.o: command/backup/common.c build.auto.h command/backup/common.h common/assert.h common/debug.h common/error.auto.h common/error.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/type/buffer.h common/type/convert.h common/type/string.h
$(CC) $(CFLAGS) $(CMAKE) -c command/backup/common.c -o command/backup/common.o

command/command.o: command/command.c build.auto.h common/assert.h common/debug.h common/error.auto.h common/error.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/time.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h config/config.auto.h config/config.h config/define.auto.h config/define.h version.h
command/command.o: command/command.c build.auto.h common/assert.h common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/http/client.h common/io/http/header.h common/io/http/query.h common/io/read.h common/io/tls/client.h common/io/write.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/time.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h config/config.auto.h config/config.h config/define.auto.h config/define.h version.h
$(CC) $(CFLAGS) $(CMAKE) -c command/command.c -o command/command.o

command/control/control.o: command/control/control.c build.auto.h command/control/control.h common/assert.h common/debug.h common/error.auto.h common/error.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/time.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h config/config.auto.h config/config.h config/define.auto.h config/define.h storage/helper.h storage/info.h storage/read.h storage/storage.h storage/write.h
@@ -269,7 +269,7 @@ common/error.o: common/error.c build.auto.h common/error.auto.c common/error.aut
common/exec.o: common/exec.c build.auto.h common/assert.h common/debug.h common/error.auto.h common/error.h common/exec.h common/io/filter/filter.h common/io/filter/group.h common/io/handleRead.h common/io/handleWrite.h common/io/io.h common/io/read.h common/io/read.intern.h common/io/write.h common/io/write.intern.h common/log.h common/logLevel.h common/macro.h common/memContext.h common/object.h common/stackTrace.h common/time.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/variant.h common/type/variantList.h common/wait.h
$(CC) $(CFLAGS) $(CMAKE) -c common/exec.c -o common/exec.o

common/exit.o: common/exit.c build.auto.h command/command.h common/assert.h common/debug.h common/error.auto.h common/error.h common/exit.h common/io/filter/filter.h common/io/filter/group.h common/io/http/client.h common/io/http/header.h common/io/http/query.h common/io/read.h common/io/tls/client.h common/io/write.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/time.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h config/config.auto.h config/config.h config/define.auto.h config/define.h perl/exec.h protocol/client.h protocol/command.h protocol/helper.h
common/exit.o: common/exit.c build.auto.h command/command.h common/assert.h common/debug.h common/error.auto.h common/error.h common/exit.h common/io/filter/filter.h common/io/filter/group.h common/io/read.h common/io/write.h common/lock.h common/log.h common/logLevel.h common/memContext.h common/stackTrace.h common/time.h common/type/buffer.h common/type/convert.h common/type/keyValue.h common/type/string.h common/type/stringList.h common/type/variant.h common/type/variantList.h config/config.auto.h config/config.h config/define.auto.h config/define.h perl/exec.h protocol/client.h protocol/command.h protocol/helper.h
$(CC) $(CFLAGS) $(CMAKE) -c common/exit.c -o common/exit.o

common/fork.o: common/fork.c build.auto.h common/assert.h common/debug.h common/error.auto.h common/error.h common/log.h common/logLevel.h common/stackTrace.h common/type/convert.h
@@ -7,6 +7,8 @@ Common Command Routines
#include <string.h>

#include "common/debug.h"
#include "common/io/http/client.h"
#include "common/io/tls/client.h"
#include "common/log.h"
#include "common/memContext.h"
#include "common/time.h"
@@ -179,6 +181,18 @@ cmdEnd(int code, const String *errorMessage)
{
MEM_CONTEXT_TEMP_BEGIN()
{
// Log tls statistics
String *tlsClientStat = tlsClientStatStr();

if (tlsClientStat != NULL)
LOG_DETAIL(strPtr(tlsClientStat));

// Log http statistics
String *httpClientStat = httpClientStatStr();

if (httpClientStat != NULL)
LOG_INFO(strPtr(httpClientStat));

// Basic info on command end
String *info = strNewFmt("%s command end: ", cfgCommandName(cfgCommand()));

@@ -10,8 +10,6 @@ Exit Routines
#include "common/debug.h"
#include "common/error.h"
#include "common/exit.h"
#include "common/io/http/client.h"
#include "common/io/tls/client.h"
#include "common/lock.h"
#include "common/log.h"
#include "config/config.h"
@@ -154,18 +152,6 @@ exitSafe(int result, bool error, SignalType signalType)
TRY_END();
#endif

// Log tls statistics
String *tlsClientStat = tlsClientStatStr();

if (tlsClientStat != NULL)
LOG_DETAIL(strPtr(tlsClientStat));

// Log http statistics
String *httpClientStat = httpClientStatStr();

if (httpClientStat != NULL)
LOG_INFO(strPtr(httpClientStat));

// Log command end if a command is set
if (cfgCommand() != cfgCmdNone)
{
@@ -116,8 +116,13 @@ testRun(void)

cfgOptionSet(cfgOptLogTimestamp, cfgSourceParam, varNewBool(true));

tlsClientNew(strNew("BOGUS"), 443, 1000, true, NULL, NULL);
httpClientNew(strNew("BOGUS"), 443, 1000, true, NULL, NULL);

TEST_RESULT_VOID(cmdEnd(0, NULL), "command end with success");
harnessLogResultRegExp("P00 INFO\\: archive-get command end: completed successfully \\([0-9]+ms\\)");
harnessLogResultRegExp(
"P00 INFO: http statistics: objects 1, sessions 0, requests 0, retries 0, closes 0\n"
"P00 INFO\\: archive-get command end: completed successfully \\([0-9]+ms\\)");
}

FUNCTION_HARNESS_RESULT_VOID();
@@ -2,7 +2,6 @@
Test Exit Routines
***********************************************************************************************************************************/
#include "common/error.h"
#include "common/io/tls/client.h"
#include "common/log.h"
#include "config/config.h"

@@ -127,14 +126,9 @@ testRun(void)
harnessLogResult("P00 INFO: archive-push command end: terminated on signal from child process");

// -------------------------------------------------------------------------------------------------------------------------
tlsClientNew(strNew("BOGUS"), 443, 1000, true, NULL, NULL);
httpClientNew(strNew("BOGUS"), 443, 1000, true, NULL, NULL);

TEST_RESULT_INT(
exitSafe(errorTypeCode(&TermError), false, signalTypeTerm), errorTypeCode(&TermError), "exit on term with SIGTERM");
harnessLogResult(
"P00 INFO: http statistics: objects 1, sessions 0, requests 0, retries 0, closes 0\n"
"P00 INFO: archive-push command end: terminated on signal [SIGTERM]");
harnessLogResult("P00 INFO: archive-push command end: terminated on signal [SIGTERM]");
}

FUNCTION_HARNESS_RESULT_VOID();

0 comments on commit 3b3327e

Please sign in to comment.
You can’t perform that action at this time.