Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ The steps below show how the logging API is used in the

.. code-block:: c

static TSTextLogObject log;
static TSTextLogObject ts_log;

#. In ``TSPluginInit``, a new log object is allocated:

.. code-block:: c

TSReturnCode error = TSTextLogObjectCreate("denylist",
TS_LOG_MODE_ADD_TIMESTAMP, &log);
TS_LOG_MODE_ADD_TIMESTAMP, &ts_log);

The new log is named ``denylist.log``. Each entry written to the log
will have a timestamp. The ``nullptr`` argument specifies that the new
Expand Down
10 changes: 5 additions & 5 deletions example/plugins/c-api/denylist_1/denylist_1.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
static char *sites[MAX_NSITES];
static int nsites;
static TSMutex sites_mutex;
static TSTextLogObject log;
static TSTextLogObject ts_log;
static TSCont global_contp;

static void handle_txn_start(TSCont contp, TSHttpTxn txnp);
Expand Down Expand Up @@ -108,8 +108,8 @@ handle_dns(TSHttpTxn txnp, TSCont contp)

for (i = 0; i < nsites; i++) {
if (strncmp(host, sites[i], host_length) == 0) {
if (log) {
TSTextLogObjectWrite(log, "denylisting site: %s", sites[i]);
if (ts_log) {
TSTextLogObjectWrite(ts_log, "denylisting site: %s", sites[i]);
} else {
TSDebug(PLUGIN_NAME, "denylisting site: %s", sites[i]);
}
Expand Down Expand Up @@ -322,8 +322,8 @@ TSPluginInit(int argc ATS_UNUSED, const char *argv[] ATS_UNUSED)
}

/* create an TSTextLogObject to log denied requests to */
error = TSTextLogObjectCreate("denylist", TS_LOG_MODE_ADD_TIMESTAMP, &log);
if (!log || error == TS_ERROR) {
error = TSTextLogObjectCreate("denylist", TS_LOG_MODE_ADD_TIMESTAMP, &ts_log);
if (!ts_log || error == TS_ERROR) {
TSDebug(PLUGIN_NAME, "error while creating log");
}

Expand Down
14 changes: 7 additions & 7 deletions example/plugins/c-api/thread_pool/psi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ typedef enum {

extern Queue job_queue;

static TSTextLogObject log;
static TSTextLogObject ts_log;
static char psi_directory[PSI_PATH_MAX_SIZE];

static int trylock_handler(TSCont contp, TSEvent event, void *edata);
Expand Down Expand Up @@ -499,13 +499,13 @@ psi_include(TSCont contp, void *edata ATS_UNUSED)
}
TSfclose(filep);
data->psi_success = 1;
if (log) {
TSTextLogObjectWrite(log, "Successfully included file: %s", inc_file);
if (ts_log) {
TSTextLogObjectWrite(ts_log, "Successfully included file: %s", inc_file);
}
} else {
data->psi_success = 0;
if (log) {
TSTextLogObjectWrite(log, "Failed to include file: %s", inc_file);
if (ts_log) {
TSTextLogObjectWrite(ts_log, "Failed to include file: %s", inc_file);
}
}

Expand Down Expand Up @@ -972,10 +972,10 @@ TSPluginInit(int argc ATS_UNUSED, const char *argv[] ATS_UNUSED)
snprintf(psi_directory, sizeof(psi_directory), "%s/%s", TSPluginDirGet(), PSI_PATH);

/* create an TSTextLogObject to log any psi include */
retval = TSTextLogObjectCreate("psi", TS_LOG_MODE_ADD_TIMESTAMP, &log);
retval = TSTextLogObjectCreate("psi", TS_LOG_MODE_ADD_TIMESTAMP, &ts_log);
if (retval == TS_ERROR) {
TSError("[%s] Failed creating log for psi plugin", PLUGIN_NAME);
log = nullptr;
ts_log = nullptr;
}

/* Create working threads */
Expand Down
10 changes: 5 additions & 5 deletions src/traffic_server/InkAPITest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6462,7 +6462,7 @@ REGRESSION_TEST(SDK_API_TSTextLog)(RegressionTest *test, int /* atype ATS_UNUSED
{
*pstatus = REGRESSION_TEST_INPROGRESS;

TSTextLogObject log;
TSTextLogObject ts_log;
TSReturnCode retVal;

char logname[PATH_NAME_MAX];
Expand All @@ -6475,7 +6475,7 @@ REGRESSION_TEST(SDK_API_TSTextLog)(RegressionTest *test, int /* atype ATS_UNUSED
snprintf(fullpath_logname, sizeof(fullpath_logname), "%s/%s", (const char *)tmp, logname);

unlink(fullpath_logname);
retVal = TSTextLogObjectCreate(logname, TS_LOG_MODE_ADD_TIMESTAMP, &log);
retVal = TSTextLogObjectCreate(logname, TS_LOG_MODE_ADD_TIMESTAMP, &ts_log);
if (retVal != TS_SUCCESS) {
SDK_RPRINT(test, "TSTextLogObjectCreate", "TestCase1", TC_FAIL, "can not create log object");
*pstatus = REGRESSION_TEST_FAILED;
Expand All @@ -6484,7 +6484,7 @@ REGRESSION_TEST(SDK_API_TSTextLog)(RegressionTest *test, int /* atype ATS_UNUSED
SDK_RPRINT(test, "TSTextLogObjectCreate", "TestCase1", TC_PASS, "ok");
}

retVal = TSTextLogObjectWrite(log, (char *)LOG_TEST_PATTERN);
retVal = TSTextLogObjectWrite(ts_log, (char *)LOG_TEST_PATTERN);
if (retVal != TS_SUCCESS) {
SDK_RPRINT(test, "TSTextLogObjectWrite", "TestCase1", TC_FAIL, "can not write to log object");
*pstatus = REGRESSION_TEST_FAILED;
Expand All @@ -6493,7 +6493,7 @@ REGRESSION_TEST(SDK_API_TSTextLog)(RegressionTest *test, int /* atype ATS_UNUSED
SDK_RPRINT(test, "TSTextLogObjectWrite", "TestCase1", TC_PASS, "ok");
}

TSTextLogObjectFlush(log);
TSTextLogObjectFlush(ts_log);
SDK_RPRINT(test, "TSTextLogObjectFlush", "TestCase1", TC_PASS, "ok");

TSCont log_test_cont = TSContCreate(log_test_handler, TSMutexCreate());
Expand All @@ -6502,7 +6502,7 @@ REGRESSION_TEST(SDK_API_TSTextLog)(RegressionTest *test, int /* atype ATS_UNUSED
data->pstatus = pstatus;
data->fullpath_logname = TSstrdup(fullpath_logname);
data->magic = MAGIC_ALIVE;
data->log = log;
data->log = ts_log;
TSContDataSet(log_test_cont, data);

TSContScheduleOnPool(log_test_cont, 6000, TS_THREAD_POOL_NET);
Expand Down