TTGlobal Reference

The TTGlobal class provides a logging facility within TTClasses.

Public Members

None

Public Methods

This section summarizes then describes the TTGlobal public methods.

Public Methods Summary

Method Description

disableLogging()

Disables TTClasses logging.

setLogLevel()

Specifies the verbosity level of TTClasses logging.

setLogStream()

Specifies where TTClasses logging information should be sent.

sqlhenv()

Returns the underlying ODBC environment object (type SQLHENV).

disableLogging()

static void disableLogging()

This method disables all TTClasses logging. Note that the following two statements are identical:

TTGlobal::disableLogging();  
TTGlobal::setLogLevel(TTLog::TTLOG_NIL);

setLogLevel()

static void setLogLevel(TTLog::TTLOG_LEVEL level)

This method specifies the verbosity level of TTClasses logging. Table 3-1 describes TTClasses logging levels. The levels are cumulative.

Table 3-1 TTClasses Logging Levels

Logging level Description

TTLog::TTLOG_NIL

There is no logging.

TTLog::TTLOG_FATAL_ERR

Logs fatal errors (serious misuse of TTClasses methods).

TTLog::TTLOG_ERR

Logs all errors, such as SQL_ERROR return codes.

TTLog::TTLOG_WARN

(Default) Also logs warnings and all calls to TTCmd::Prepare(), including the SQL string being prepared. Prints all database optimizer query plans.

TTLog::TTLOG_INFO

Also logs informational messages, such as calls to most methods on TTCmd and TTConnection objects, including the SQL string where appropriate.

TTLog::TTLOG_DEBUG

Also logs debugging information, such as all bound parameter values for each call to TTCmd::Execute().

To set the logging level to TTLog::TTLOG_ERR, for example, add the following line to your program:

TTGlobal::setLogLevel(TTLog::TTLOG_ERR);

setLogStream()

static void setLogStream(ostream& stream)

Specifies the file (ofstream object) where TTClasses logging information should be sent. By default, if TTClasses logging is enabled, logging is to stderr. Using this method, an application can specify logging to a file (or any other ostream&), such as in the following example that sets logging to app_log.txt:

ofstream log_file("app_log.txt");
TTGlobal::setLogStream(log_file);

sqlhenv()

static SQLHENV sqlhenv()

Retrieves the underlying ODBC environment object.