NAME

gc_log_setopt - sets the logging options in the Game Carrier Framework.

SYNOPSIS

#include <game-carrier/client.h>

GC_CLIENT_API
void gc_log_setopt(
    GCT_INT level,
    GCT_CSTR file_name,
    GCT_INT flags);

Parameters:

  • level GCT_INT Sets the logging level.
  • file_name GCT_CSTR Filename where the logs will be saved.
  • flags GCT_INT Specifies the logging flags.

RETURN VALUE

None.

DESCRIPTION

The gc_log_setopt operation is used to set logging options in the Game Carrier framework. To set custom logging you must specify corresponding flags in the invocation and also invoke this function before initialization of the framework. Otherwise, the logging is automatically set to default options.

The level parameter sets the logging level to determine the severity of logs to be generated. Flags passed to the function must be separated by bitwise OR operator. You can easily combine any flags in the invocation. Supported values: GCL_NORMAL, GCL_VERBOSE, GCL_ERR, GCL_WARN, GCL_NOTICE, GCL_INFO, GCL_DEBUG, GCL_USER. The GCL_NORMAL flag represents the following combination of flags: GCL_ERR, GCL_WARN, GCL_NOTICE, GCL_USER. The GCL_VERBOSE flag sets the maximum logging level and it is a combination of all available flags.

The file_name parameter specifies the filename where the logs will be saved. Supported values: NULL or "" which stands for an empty string. If NULL is used in the invocation, then the naming convention of the log file is ``gc_client.%p.log. Where %p is the placeholder for the process ID number. In case an empty string "" is used in the invocation, then no logs are written to the file.

The flags parameter specifies the logging flags, whose value is a bitwise OR. Supported values: GCL_STANDARD_FLAGS, GCL_TO_STDERR, GCL_PRINT_THREAD_ID, GCL_AUTO_FLUSH, GCL_APPEND. The GCL_STANDARD_FLAGS flag represents the following combination of flags:

  • GCL_TO_STDERR outputs the log messages to the stderr stream.
  • GCL_PRINT_THREAD_ID adds a thread ID to a log message.
  • GCL_AUTO_FLUSH allows writing changes to the log file right after each invocation. This flag affects performance, but when the program crashes, all details are saved to the log file.
  • GCL_APPEND flag is used to preserve a log file between runs. New log messages will be appended to the end of the existing file.

EXAMPLE

#include <game-carrier/client.h>

int main(int argc, char * argv[])
{
    gc_log_setopt(GCL_ERR | GCL_WARN | GCL_NOTICE, "game.%p.log", GCL_TO_STDERR);

    gc_clients_init(GC_MODE_HYBRID);

    /* Continue working... */
    return 0;
}

SEE ALSO

gc_clients_init, gc_log_message, gcl_level, gcl_flags