include/SDL_log.h
author Sam Lantinga <slouken@libsdl.org>
Tue, 08 Feb 2011 23:13:58 -0800
changeset 5235 1e28342cb15d
parent 5221 2ee8112bfc6b
child 5262 b530ef003506
permissions -rw-r--r--
Added a way to replace the default logging mechanism
slouken@5221
     1
/*
slouken@5221
     2
    SDL - Simple DirectMedia Layer
slouken@5221
     3
    Copyright (C) 1997-2010 Sam Lantinga
slouken@5221
     4
slouken@5221
     5
    This library is free software; you can redistribute it and/or
slouken@5221
     6
    modify it under the terms of the GNU Lesser General Public
slouken@5221
     7
    License as published by the Free Software Foundation; either
slouken@5221
     8
    version 2.1 of the License, or (at your option) any later version.
slouken@5221
     9
slouken@5221
    10
    This library is distributed in the hope that it will be useful,
slouken@5221
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@5221
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@5221
    13
    Lesser General Public License for more details.
slouken@5221
    14
slouken@5221
    15
    You should have received a copy of the GNU Lesser General Public
slouken@5221
    16
    License along with this library; if not, write to the Free Software
slouken@5221
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
slouken@5221
    18
slouken@5221
    19
    Sam Lantinga
slouken@5221
    20
    slouken@libsdl.org
slouken@5221
    21
*/
slouken@5221
    22
slouken@5221
    23
/**
slouken@5221
    24
 *  \file SDL_log.h
slouken@5221
    25
 *  
slouken@5221
    26
 *  Simple log messages with categories and priorities.
slouken@5221
    27
 *
slouken@5221
    28
 *  By default logs are quiet, but if you're debugging SDL you might want:
slouken@5221
    29
 *
slouken@5221
    30
 *      SDL_LogSetAllPriority(SDL_LOG_PRIORITY_WARN);
slouken@5221
    31
 *
slouken@5221
    32
 *  Here's where the messages go on different platforms:
slouken@5221
    33
 *      Windows: debug output stream
slouken@5221
    34
 *      Android: log output
slouken@5221
    35
 *      Others: standard error output (stderr)
slouken@5221
    36
 */
slouken@5221
    37
slouken@5221
    38
#ifndef _SDL_log_h
slouken@5221
    39
#define _SDL_log_h
slouken@5221
    40
slouken@5221
    41
#include "SDL_stdinc.h"
slouken@5221
    42
slouken@5221
    43
#include "begin_code.h"
slouken@5221
    44
/* Set up for C function definitions, even when using C++ */
slouken@5221
    45
#ifdef __cplusplus
slouken@5221
    46
/* *INDENT-OFF* */
slouken@5221
    47
extern "C" {
slouken@5221
    48
/* *INDENT-ON* */
slouken@5221
    49
#endif
slouken@5221
    50
slouken@5221
    51
slouken@5221
    52
/**
slouken@5221
    53
 *  \brief The maximum size of a log message
slouken@5221
    54
 *
slouken@5221
    55
 *  Messages longer than the maximum size will be truncated
slouken@5221
    56
 */
slouken@5221
    57
#define SDL_MAX_LOG_MESSAGE 4096
slouken@5221
    58
slouken@5221
    59
/**
slouken@5221
    60
 *  \brief The predefined log categories
slouken@5221
    61
 *
slouken@5221
    62
 *  By default the application category is enabled at the INFO level,
slouken@5221
    63
 *  and all other categories are enabled at the CRITICAL level.
slouken@5221
    64
 */
slouken@5221
    65
enum
slouken@5221
    66
{
slouken@5221
    67
    SDL_LOG_CATEGORY_APPLICATION,
slouken@5221
    68
    SDL_LOG_CATEGORY_ERROR,
slouken@5221
    69
    SDL_LOG_CATEGORY_SYSTEM,
slouken@5221
    70
    SDL_LOG_CATEGORY_AUDIO,
slouken@5221
    71
    SDL_LOG_CATEGORY_VIDEO,
slouken@5221
    72
    SDL_LOG_CATEGORY_RENDER,
slouken@5221
    73
    SDL_LOG_CATEGORY_INPUT,
slouken@5221
    74
slouken@5221
    75
    /* Reserved for future SDL library use */
slouken@5221
    76
    SDL_LOG_CATEGORY_RESERVED1,
slouken@5221
    77
    SDL_LOG_CATEGORY_RESERVED2,
slouken@5221
    78
    SDL_LOG_CATEGORY_RESERVED3,
slouken@5221
    79
    SDL_LOG_CATEGORY_RESERVED4,
slouken@5221
    80
    SDL_LOG_CATEGORY_RESERVED5,
slouken@5221
    81
    SDL_LOG_CATEGORY_RESERVED6,
slouken@5221
    82
    SDL_LOG_CATEGORY_RESERVED7,
slouken@5221
    83
    SDL_LOG_CATEGORY_RESERVED8,
slouken@5221
    84
    SDL_LOG_CATEGORY_RESERVED9,
slouken@5221
    85
    SDL_LOG_CATEGORY_RESERVED10,
slouken@5221
    86
slouken@5221
    87
    /* Beyond this point is reserved for application use, e.g.
slouken@5221
    88
       enum {
slouken@5221
    89
           MYAPP_CATEGORY_AWESOME1 = SDL_LOG_CATEGORY_CUSTOM,
slouken@5221
    90
           MYAPP_CATEGORY_AWESOME2,
slouken@5221
    91
           MYAPP_CATEGORY_AWESOME3,
slouken@5221
    92
           ...
slouken@5221
    93
       };
slouken@5221
    94
     */
slouken@5221
    95
    SDL_LOG_CATEGORY_CUSTOM,
slouken@5221
    96
};
slouken@5221
    97
slouken@5221
    98
/**
slouken@5221
    99
 *  \brief The predefined log priorities
slouken@5221
   100
 */
slouken@5221
   101
typedef enum
slouken@5221
   102
{
slouken@5221
   103
    SDL_LOG_PRIORITY_VERBOSE = 1,
slouken@5221
   104
    SDL_LOG_PRIORITY_DEBUG,
slouken@5221
   105
    SDL_LOG_PRIORITY_INFO,
slouken@5221
   106
    SDL_LOG_PRIORITY_WARN,
slouken@5221
   107
    SDL_LOG_PRIORITY_ERROR,
slouken@5221
   108
    SDL_LOG_PRIORITY_CRITICAL,
slouken@5221
   109
    SDL_NUM_LOG_PRIORITIES
slouken@5221
   110
} SDL_LogPriority;
slouken@5221
   111
slouken@5221
   112
slouken@5221
   113
/**
slouken@5221
   114
 *  \brief Set the priority of all log categories
slouken@5221
   115
 */
slouken@5221
   116
extern DECLSPEC void SDLCALL SDL_LogSetAllPriority(SDL_LogPriority priority);
slouken@5221
   117
slouken@5221
   118
/**
slouken@5221
   119
 *  \brief Set the priority of a particular log category
slouken@5221
   120
 */
slouken@5221
   121
extern DECLSPEC void SDLCALL SDL_LogSetPriority(int category,
slouken@5221
   122
                                                SDL_LogPriority priority);
slouken@5221
   123
slouken@5221
   124
/**
slouken@5221
   125
 *  \brief Set the priority of a particular log category
slouken@5221
   126
 */
slouken@5221
   127
extern DECLSPEC SDL_LogPriority SDLCALL SDL_LogGetPriority(int category);
slouken@5221
   128
slouken@5221
   129
/**
slouken@5221
   130
 *  \brief Reset all priorities to default.
slouken@5221
   131
 *
slouken@5221
   132
 *  \note This is called in SDL_Quit().
slouken@5221
   133
 */
slouken@5221
   134
extern DECLSPEC void SDLCALL SDL_LogResetPriorities(void);
slouken@5221
   135
slouken@5221
   136
/**
slouken@5221
   137
 *  \brief Log a message with SDL_LOG_CATEGORY_APPLICATION and SDL_LOG_PRIORITY_INFO
slouken@5221
   138
 */
slouken@5221
   139
extern DECLSPEC void SDLCALL SDL_Log(const char *fmt, ...);
slouken@5221
   140
slouken@5221
   141
/**
slouken@5221
   142
 *  \brief Log a message with SDL_LOG_PRIORITY_VERBOSE
slouken@5221
   143
 */
slouken@5221
   144
extern DECLSPEC void SDLCALL SDL_LogVerbose(int category, const char *fmt, ...);
slouken@5221
   145
slouken@5221
   146
/**
slouken@5221
   147
 *  \brief Log a message with SDL_LOG_PRIORITY_INFO
slouken@5221
   148
 */
slouken@5221
   149
extern DECLSPEC void SDLCALL SDL_LogInfo(int category, const char *fmt, ...);
slouken@5221
   150
slouken@5221
   151
/**
slouken@5221
   152
 *  \brief Log a message with SDL_LOG_PRIORITY_WARN
slouken@5221
   153
 */
slouken@5221
   154
extern DECLSPEC void SDLCALL SDL_LogWarn(int category, const char *fmt, ...);
slouken@5221
   155
slouken@5221
   156
/**
slouken@5221
   157
 *  \brief Log a message with SDL_LOG_PRIORITY_ERROR
slouken@5221
   158
 */
slouken@5221
   159
extern DECLSPEC void SDLCALL SDL_LogError(int category, const char *fmt, ...);
slouken@5221
   160
slouken@5221
   161
/**
slouken@5221
   162
 *  \brief Log a message with SDL_LOG_PRIORITY_CRITICAL
slouken@5221
   163
 */
slouken@5221
   164
extern DECLSPEC void SDLCALL SDL_LogCritical(int category, const char *fmt, ...);
slouken@5221
   165
slouken@5221
   166
/**
slouken@5221
   167
 *  \brief Log a message with the specified category and priority.
slouken@5221
   168
 */
slouken@5221
   169
extern DECLSPEC void SDLCALL SDL_LogMessage(int category,
slouken@5221
   170
                                            SDL_LogPriority priority,
slouken@5221
   171
                                            const char *fmt, ...);
slouken@5221
   172
slouken@5221
   173
/**
slouken@5221
   174
 *  \brief Log a message with the specified category and priority.
slouken@5221
   175
 */
slouken@5221
   176
extern DECLSPEC void SDLCALL SDL_LogMessageV(int category,
slouken@5221
   177
                                             SDL_LogPriority priority,
slouken@5221
   178
                                             const char *fmt, va_list ap);
slouken@5221
   179
slouken@5235
   180
/**
slouken@5235
   181
 *  \brief The prototype for the log output function
slouken@5235
   182
 */
slouken@5235
   183
typedef void (*SDL_LogOutputFunction)(void *userdata, int category, SDL_LogPriority priority, const char *message);
slouken@5235
   184
slouken@5235
   185
/**
slouken@5235
   186
 *  \brief Get the current log output function.
slouken@5235
   187
 */
slouken@5235
   188
extern DECLSPEC void SDLCALL SDL_LogGetOutputFunction(SDL_LogOutputFunction *callback, void **userdata);
slouken@5235
   189
slouken@5235
   190
/**
slouken@5235
   191
 *  \brief This function allows you to replace the default log output
slouken@5235
   192
 *         function with one of your own.
slouken@5235
   193
 */
slouken@5235
   194
extern DECLSPEC void SDLCALL SDL_LogSetOutputFunction(SDL_LogOutputFunction callback, void *userdata);
slouken@5235
   195
slouken@5221
   196
slouken@5221
   197
/* Ends C function definitions when using C++ */
slouken@5221
   198
#ifdef __cplusplus
slouken@5221
   199
/* *INDENT-OFF* */
slouken@5221
   200
}
slouken@5221
   201
/* *INDENT-ON* */
slouken@5221
   202
#endif
slouken@5221
   203
#include "close_code.h"
slouken@5221
   204
slouken@5221
   205
#endif /* _SDL_log_h */
slouken@5221
   206
slouken@5221
   207
/* vi: set ts=4 sw=4 expandtab: */