tport: added TPTAG_LOG() and TPTAG_DUMP().

Original patch by Roman Filonenko was slightly modified and re-recorded by
Pekka Pessi. Now letting environment variables override TPTAG_LOG() or
TPTAG_DUMP().

darcs-hash:20061222155506-a63cf-eb5cf7624c24f7db7fc66cfae29873f97a5fd88f.gz
parent cccde2bc
......@@ -265,6 +265,32 @@ TPORT_DLL extern tag_typedef_t tptag_tos;
TPORT_DLL extern tag_typedef_t tptag_tos_ref;
#define TPTAG_TOS_REF(x) tptag_tos_ref, tag_int_vr(&(x))
TPORT_DLL extern tag_typedef_t tptag_log;
/** If set, print out parsed or sent messages at transport layer.
*
* Use with tport_tcreate(), nua_create(), nta_agent_create(),
* nth_engine_create(), or initial nth_site_create().
*
* @sa #TPORT_DUMP, TPTAG_DUMP()
*/
#define TPTAG_LOG(x) tptag_log, tag_bool_v((x))
TPORT_DLL extern tag_typedef_t tptag_log_ref;
#define TPTAG_LOG_REF(x) tptag_log_ref, tag_bool_vr(&(x))
TPORT_DLL extern tag_typedef_t tptag_dump;
/** Filename for dumping unparsed messages from transport.
*
* Use with tport_tcreate(), nta_agent_create(), nua_create(),
* nth_engine_create(), or initial nth_site_create().
*
* @sa #TPORT_DUMP, TPTAG_LOG().
*/
#define TPTAG_DUMP(x) tptag_dump, tag_str_v((x))
TPORT_DLL extern tag_typedef_t tptag_dump_ref;
#define TPTAG_DUMP_REF(x) tptag_dump_ref, tag_str_vr(&(x))
SOFIA_END_DECLS
#endif /* !defined TPORT_TAG_H */
......@@ -90,14 +90,24 @@ su_log_t tport_log[] = {
/** Initialize logging. */
void tport_open_log(tport_master_t *mr, tagi_t *tags)
{
char const *log;
mr->mr_log =
getenv("MSG_STREAM_LOG") != NULL ||
getenv("TPORT_LOG") != NULL
? MSG_DO_EXTRACT_COPY : 0;
if ((log = getenv("TPORT_DUMP")) || (log = getenv("MSG_DUMP"))) {
char const *log = NULL;
int log_msg = 0;
tl_gets(tags, TPTAG_LOG_REF(log_msg), TAG_END());
if (getenv("MSG_STREAM_LOG") != NULL || getenv("TPORT_LOG") != NULL)
log_msg = 1;
mr->mr_log = log_msg ? MSG_DO_EXTRACT_COPY : 0;
tl_gets(tags, TPTAG_DUMP_REF(log), TAG_END());
if (getenv("MSG_DUMP"))
log = getenv("MSG_DUMP");
if (getenv("TPORT_DUMP"))
log = getenv("TPORT_DUMP");
if (log) {
time_t now;
if (strcmp(log, "-"))
......
......@@ -78,3 +78,6 @@ tag_typedef_t tptag_thrprqsize = UINTTAG_TYPEDEF(thrprqsize);
tag_typedef_t tptag_http_connect = STRTAG_TYPEDEF(http_connect);
tag_typedef_t tptag_stun_server = BOOLTAG_TYPEDEF(stun_server);
tag_typedef_t tptag_tos = INTTAG_TYPEDEF(tos);
tag_typedef_t tptag_log = INTTAG_TYPEDEF(log);
tag_typedef_t tptag_dump = STRTAG_TYPEDEF(dump);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment