Каталог приложений

Руководство EasySQL 1.0.4

Исторические материалы EasySQL.


[Previous] [Next] [Contents]

    6.3. Miscellaneous methods used both in C and C++ applications
      --- Setting log file

int easysql_set_log_file(char const *file)

Changes a file to which logging information is written. May be ``stderr'' (messages are directed to standart error stream), ``none'' (no logging is permitted) or a path to file - relative to EasySQL home in case of no leading slash or to root directory otherwise. Default value is inherited from global configuration.

Returns `true' (non-zero) in case of success (may not fall in current version).

      --- Retrieving log file name

char const *easysql_get_log_file()

Returns a path to currently used log file, `stderr' in case of logging to standart error stream or `none' if logging is completely disabled.

      --- Reopening log file

char const *easysql_reopen_log()

Closes and reopens log file (if it is not an `stderr' stream). Useful as a reaction to `kill -hup' or something similar. Allows renaming/chopping/deleting of log file.

      --- Setting log level

void easysql_set_log_level(unsigned level)

Sets level of logging to the given value. Value may be combined by binary OR operator from following codes:

  • log depth - from EASYSQL_D_L1 (lowest volume) to EASYSQL_D_L4 (highest volume).
  • log sections:
    EASYSQL_D_SQL

    SQL queries and their results;

    EASYSQL_D_DRV

    driver loader, calling, stubs etc;

    EASYSQL_D_IDRV

    driver's internal logging - what to log depends on exact driver;

    EASYSQL_D_C

    C language stubs logging;

    EASYSQL_D_MISC

    miscellaneous internal functions - memory allocating, logging etc.

  • useful shortcuts (not to be ORed with something):
    EASYSQL_D_NONE

    no logging allowed at all, even error messages are skipped (same effect may be achieved by setting log file name to `none');

    EASYSQL_D_ERROR

    only errors are logged, this is the default;

    EASYSQL_D_ALL

    any and all messages and warnings are logged.

An example:

int main()
{ easysql_set_log_file("/tmp/driver-debug");
  easysql_set_log_level(D_IDRV|D_L4);
  ...
}

      --- Retrieving log level

unsigned easysql_get_log_level()

Return currently used log level. Usually used for temporary changes of a structure like this:

...
unsigned level=easysql_get_log_level(); // Saving current value
easysql_set_log_level(D_ALL);
...                                     // Some vital actions
easysql_set_log_level(level);           // Restoring from saved value
...

      --- Setting log flush mode

int easysql_set_log_flush(int flag)

`Flag' is a boolean value. To force EasySQL to flush every line of log output set it to non-zero value -- very useful if your program locks up and you see nothing in the log because of buffering.

The default is buffered output and no forced flush.


[Previous] [Next] [Contents]

Оригинал в Вебархиве