NCBI C++ ToolKit
Macros | Functions | Variables
log.c File Reference
#include <config.h>
#include <stdarg.h>
#include <freetds/time.h>
#include <assert.h>
#include <ctype.h>
#include <limits.h>
#include <stdio.h>
#include <freetds/tds.h>
#include <freetds/checks.h>
#include <freetds/thread.h>
+ Include dependency graph for log.c:

Go to the source code of this file.

Go to the SVN repository for this file.

Macros

#define BYTES_PER_LINE   16
 
#define tdsdump_dump_buf   TDSDUMP_BUF_FAST
 
#define tdsdump_log   TDSDUMP_LOG_FAST
 

Functions

static FILE * tdsdump_append (void)
 
void tdsdump_off (void)
 Temporarily turn off logging. More...
 
void tdsdump_on (void)
 Turn logging back on. More...
 
int tdsdump_state (void)
 Get the logging state. More...
 
int tdsdump_isopen ()
 
int tdsdump_open (const char *filename)
 Create and truncate a human readable dump file for the TDS traffic. More...
 
void tdsdump_close (void)
 Close the TDS dump log file. More...
 
static void tdsdump_start (FILE *file, const char *fname, int line)
 
void tdsdump_do_dump_buf (const char *file, unsigned int level_line, const char *msg, const void *buf, size_t length)
 Dump the contents of data into the log file in a human readable format. More...
 
void tdsdump_do_log (const char *file, unsigned int level_line, const char *fmt,...)
 Write a message to the debug log. More...
 
void tdsdump_col (const TDSCOLUMN *col)
 Write a column value to the debug log. More...
 

Variables

int tds_debug_flags = TDS_DBGFLAG_ALL | TDS_DBGFLAG_SOURCE
 
int tds_g_append_mode = 0
 
static char * g_dump_filename = NULL
 
int tds_write_dump = 0
 Tell if TDS debug logging is turned on or off. More...
 
int tdsdump_elided
 
static FILE * g_dumpfile = NULL
 

Macro Definition Documentation

◆ BYTES_PER_LINE

#define BYTES_PER_LINE   16

◆ tdsdump_dump_buf

#define tdsdump_dump_buf   TDSDUMP_BUF_FAST

Definition at line 359 of file log.c.

◆ tdsdump_log

#define tdsdump_log   TDSDUMP_LOG_FAST

Definition at line 416 of file log.c.

Function Documentation

◆ tdsdump_append()

static FILE * tdsdump_append ( void  )
static

Definition at line 189 of file log.c.

References g_dump_filename, NULL, and util::strcmp().

Referenced by tdsdump_do_dump_buf(), tdsdump_do_log(), and tdsdump_open().

◆ tdsdump_close()

void tdsdump_close ( void  )

Close the TDS dump log file.

Definition at line 207 of file log.c.

References g_dump_filename, g_dump_mutex, g_dumpfile, NULL, tds_mutex_lock, tds_mutex_unlock, tds_write_dump, and TDS_ZERO_FREE.

◆ tdsdump_col()

void tdsdump_col ( const TDSCOLUMN col)

◆ tdsdump_do_dump_buf()

void tdsdump_do_dump_buf ( const char *  file,
unsigned int  level_line,
const char *  msg,
const void *  buf,
size_t  length 
)

Dump the contents of data into the log file in a human readable format.

Parameters
filesource file name
level_lineline and level combined. This and file are automatically computed by TDS_DBG_* macros.
msgmessage to print before dump
bufbuffer to dump
lengthnumber of bytes in the buffer

Definition at line 270 of file log.c.

References buf, BYTES_PER_LINE, data, file, g_dump_filename, g_dump_mutex, g_dumpfile, i, isprint(), line_buf, NULL, tds_debug_flags, tds_g_append_mode, tds_mutex_lock, tds_mutex_unlock, tds_write_dump, tdsdump_append(), tdsdump_elided, and tdsdump_start().

◆ tdsdump_do_log()

void tdsdump_do_log ( const char *  file,
unsigned int  level_line,
const char *  fmt,
  ... 
)

Write a message to the debug log.

Parameters
filename of the log file
level_linekind of detail to be included
fmtprintf-like format string

Definition at line 370 of file log.c.

References file, g_dump_filename, g_dump_mutex, g_dumpfile, NULL, tds_debug_flags, tds_g_append_mode, tds_mutex_lock, tds_mutex_unlock, tds_write_dump, tdsdump_append(), and tdsdump_start().

◆ tdsdump_isopen()

int tdsdump_isopen ( void  )

Definition at line 111 of file log.c.

References g_dump_filename, and g_dumpfile.

Referenced by tdsdump_on().

◆ tdsdump_off()

void tdsdump_off ( void  )

Temporarily turn off logging.

Definition at line 81 of file log.c.

References g_dump_mutex, tds_mutex_lock, tds_mutex_unlock, and tds_write_dump.

◆ tdsdump_on()

void tdsdump_on ( void  )

Turn logging back on.

You must call tdsdump_open() before calling this routine.

Definition at line 93 of file log.c.

References g_dump_mutex, tds_mutex_lock, tds_mutex_unlock, tds_write_dump, and tdsdump_isopen().

◆ tdsdump_open()

int tdsdump_open ( const char *  filename)

Create and truncate a human readable dump file for the TDS traffic.

The name of the file is specified by the filename parameter. If that is given as NULL or an empty string, any existing log file will be closed.

Returns
true if the file was opened, false if it couldn't be opened.

Definition at line 126 of file log.c.

References g_dump_filename, g_dump_mutex, g_dumpfile, NULL, result, util::strcmp(), strdup, t, TDS_DBG_INFO1, tds_debug_flags, tds_g_append_mode, tds_localtime_r, tds_mutex_lock, tds_mutex_unlock, tds_write_dump, TDS_ZERO_FREE, tdsdump_append(), tdsdump_log, and VERSION.

◆ tdsdump_start()

static void tdsdump_start ( FILE *  file,
const char *  fname,
int  line 
)
static

◆ tdsdump_state()

int tdsdump_state ( void  )

Get the logging state.

Definition at line 105 of file log.c.

References tds_write_dump.

Variable Documentation

◆ g_dump_filename

char* g_dump_filename = NULL
static

◆ g_dumpfile

FILE* g_dumpfile = NULL
static

◆ tds_debug_flags

int tds_debug_flags = TDS_DBGFLAG_ALL | TDS_DBGFLAG_SOURCE

Definition at line 53 of file log.c.

Referenced by tdsdump_do_dump_buf(), tdsdump_do_log(), tdsdump_open(), and tdsdump_start().

◆ tds_g_append_mode

int tds_g_append_mode = 0

Definition at line 54 of file log.c.

Referenced by tdsdump_do_dump_buf(), tdsdump_do_log(), and tdsdump_open().

◆ tds_write_dump

int tds_write_dump = 0

Tell if TDS debug logging is turned on or off.

Definition at line 57 of file log.c.

Referenced by tdsdump_close(), tdsdump_do_dump_buf(), tdsdump_do_log(), tdsdump_off(), tdsdump_on(), tdsdump_open(), and tdsdump_state().

◆ tdsdump_elided

int tdsdump_elided

Definition at line 61 of file log.c.

Referenced by tdsdump_do_dump_buf().

Modified on Tue May 21 11:02:02 2024 by modify_doxy.py rev. 669887