include/SDL_log.h
author Andreas Schiffler <aschiffler@ferzkopp.net>
Fri, 30 Nov 2012 23:25:34 -0800
changeset 6717 2acd95060548
parent 6616 4f272256d172
child 6885 700f1b25f77f
permissions -rw-r--r--
Add log, assert and harness (partial) to test lib
slouken@5221
     1
/*
slouken@5535
     2
  Simple DirectMedia Layer
slouken@6138
     3
  Copyright (C) 1997-2012 Sam Lantinga <slouken@libsdl.org>
slouken@5221
     4
slouken@5535
     5
  This software is provided 'as-is', without any express or implied
slouken@5535
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@5535
     7
  arising from the use of this software.
slouken@5221
     8
slouken@5535
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@5535
    10
  including commercial applications, and to alter it and redistribute it
slouken@5535
    11
  freely, subject to the following restrictions:
slouken@5221
    12
slouken@5535
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@5535
    14
     claim that you wrote the original software. If you use this software
slouken@5535
    15
     in a product, an acknowledgment in the product documentation would be
slouken@5535
    16
     appreciated but is not required.
slouken@5535
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@5535
    18
     misrepresented as being the original software.
slouken@5535
    19
  3. This notice may not be removed or altered from any source distribution.
slouken@5221
    20
*/
slouken@5221
    21
slouken@5221
    22
/**
slouken@5221
    23
 *  \file SDL_log.h
slouken@5221
    24
 *  
slouken@5221
    25
 *  Simple log messages with categories and priorities.
slouken@5221
    26
 *
slouken@5221
    27
 *  By default logs are quiet, but if you're debugging SDL you might want:
slouken@5221
    28
 *
slouken@5221
    29
 *      SDL_LogSetAllPriority(SDL_LOG_PRIORITY_WARN);
slouken@5221
    30
 *
slouken@5221
    31
 *  Here's where the messages go on different platforms:
slouken@5221
    32
 *      Windows: debug output stream
slouken@5221
    33
 *      Android: log output
slouken@5221
    34
 *      Others: standard error output (stderr)
slouken@5221
    35
 */
slouken@5221
    36
slouken@5221
    37
#ifndef _SDL_log_h
slouken@5221
    38
#define _SDL_log_h
slouken@5221
    39
slouken@5221
    40
#include "SDL_stdinc.h"
slouken@5221
    41
slouken@5221
    42
#include "begin_code.h"
slouken@5221
    43
/* Set up for C function definitions, even when using C++ */
slouken@5221
    44
#ifdef __cplusplus
slouken@5221
    45
/* *INDENT-OFF* */
slouken@5221
    46
extern "C" {
slouken@5221
    47
/* *INDENT-ON* */
slouken@5221
    48
#endif
slouken@5221
    49
slouken@5221
    50
slouken@5221
    51
/**
slouken@5221
    52
 *  \brief The maximum size of a log message
slouken@5221
    53
 *
slouken@5221
    54
 *  Messages longer than the maximum size will be truncated
slouken@5221
    55
 */
slouken@5221
    56
#define SDL_MAX_LOG_MESSAGE 4096
slouken@5221
    57
slouken@5221
    58
/**
slouken@5221
    59
 *  \brief The predefined log categories
slouken@5221
    60
 *
slouken@5221
    61
 *  By default the application category is enabled at the INFO level,
aschiffler@6717
    62
 *  the assert category is enabled at the WARN level, test is enabled
aschiffler@6717
    63
 *  at the VERBOSE level and all other categories are enabled at the 
aschiffler@6717
    64
 *  CRITICAL level.
slouken@5221
    65
 */
slouken@5221
    66
enum
slouken@5221
    67
{
slouken@5221
    68
    SDL_LOG_CATEGORY_APPLICATION,
slouken@5221
    69
    SDL_LOG_CATEGORY_ERROR,
slouken@6616
    70
    SDL_LOG_CATEGORY_ASSERT,
slouken@5221
    71
    SDL_LOG_CATEGORY_SYSTEM,
slouken@5221
    72
    SDL_LOG_CATEGORY_AUDIO,
slouken@5221
    73
    SDL_LOG_CATEGORY_VIDEO,
slouken@5221
    74
    SDL_LOG_CATEGORY_RENDER,
slouken@5221
    75
    SDL_LOG_CATEGORY_INPUT,
aschiffler@6717
    76
    SDL_LOG_CATEGORY_TEST,
slouken@5221
    77
slouken@5221
    78
    /* Reserved for future SDL library use */
slouken@5221
    79
    SDL_LOG_CATEGORY_RESERVED1,
slouken@5221
    80
    SDL_LOG_CATEGORY_RESERVED2,
slouken@5221
    81
    SDL_LOG_CATEGORY_RESERVED3,
slouken@5221
    82
    SDL_LOG_CATEGORY_RESERVED4,
slouken@5221
    83
    SDL_LOG_CATEGORY_RESERVED5,
slouken@5221
    84
    SDL_LOG_CATEGORY_RESERVED6,
slouken@5221
    85
    SDL_LOG_CATEGORY_RESERVED7,
slouken@5221
    86
    SDL_LOG_CATEGORY_RESERVED8,
slouken@5221
    87
    SDL_LOG_CATEGORY_RESERVED9,
slouken@5221
    88
    SDL_LOG_CATEGORY_RESERVED10,
slouken@5221
    89
slouken@5221
    90
    /* Beyond this point is reserved for application use, e.g.
slouken@5221
    91
       enum {
slouken@5221
    92
           MYAPP_CATEGORY_AWESOME1 = SDL_LOG_CATEGORY_CUSTOM,
slouken@5221
    93
           MYAPP_CATEGORY_AWESOME2,
slouken@5221
    94
           MYAPP_CATEGORY_AWESOME3,
slouken@5221
    95
           ...
slouken@5221
    96
       };
slouken@5221
    97
     */
slouken@5303
    98
    SDL_LOG_CATEGORY_CUSTOM
slouken@5221
    99
};
slouken@5221
   100
slouken@5221
   101
/**
slouken@5221
   102
 *  \brief The predefined log priorities
slouken@5221
   103
 */
slouken@5221
   104
typedef enum
slouken@5221
   105
{
slouken@5221
   106
    SDL_LOG_PRIORITY_VERBOSE = 1,
slouken@5221
   107
    SDL_LOG_PRIORITY_DEBUG,
slouken@5221
   108
    SDL_LOG_PRIORITY_INFO,
slouken@5221
   109
    SDL_LOG_PRIORITY_WARN,
slouken@5221
   110
    SDL_LOG_PRIORITY_ERROR,
slouken@5221
   111
    SDL_LOG_PRIORITY_CRITICAL,
slouken@5221
   112
    SDL_NUM_LOG_PRIORITIES
slouken@5221
   113
} SDL_LogPriority;
slouken@5221
   114
slouken@5221
   115
slouken@5221
   116
/**
slouken@5221
   117
 *  \brief Set the priority of all log categories
slouken@5221
   118
 */
slouken@5221
   119
extern DECLSPEC void SDLCALL SDL_LogSetAllPriority(SDL_LogPriority priority);
slouken@5221
   120
slouken@5221
   121
/**
slouken@5221
   122
 *  \brief Set the priority of a particular log category
slouken@5221
   123
 */
slouken@5221
   124
extern DECLSPEC void SDLCALL SDL_LogSetPriority(int category,
slouken@5221
   125
                                                SDL_LogPriority priority);
slouken@5221
   126
slouken@5221
   127
/**
slouken@6038
   128
 *  \brief Get the priority of a particular log category
slouken@5221
   129
 */
slouken@5221
   130
extern DECLSPEC SDL_LogPriority SDLCALL SDL_LogGetPriority(int category);
slouken@5221
   131
slouken@5221
   132
/**
slouken@5221
   133
 *  \brief Reset all priorities to default.
slouken@5221
   134
 *
slouken@5221
   135
 *  \note This is called in SDL_Quit().
slouken@5221
   136
 */
slouken@5221
   137
extern DECLSPEC void SDLCALL SDL_LogResetPriorities(void);
slouken@5221
   138
slouken@5221
   139
/**
slouken@5221
   140
 *  \brief Log a message with SDL_LOG_CATEGORY_APPLICATION and SDL_LOG_PRIORITY_INFO
slouken@5221
   141
 */
slouken@5221
   142
extern DECLSPEC void SDLCALL SDL_Log(const char *fmt, ...);
slouken@5221
   143
slouken@5221
   144
/**
slouken@5221
   145
 *  \brief Log a message with SDL_LOG_PRIORITY_VERBOSE
slouken@5221
   146
 */
slouken@5221
   147
extern DECLSPEC void SDLCALL SDL_LogVerbose(int category, const char *fmt, ...);
slouken@5221
   148
slouken@5221
   149
/**
slouken@5348
   150
 *  \brief Log a message with SDL_LOG_PRIORITY_DEBUG
slouken@5348
   151
 */
slouken@5348
   152
extern DECLSPEC void SDLCALL SDL_LogDebug(int category, const char *fmt, ...);
slouken@5348
   153
slouken@5348
   154
/**
slouken@5221
   155
 *  \brief Log a message with SDL_LOG_PRIORITY_INFO
slouken@5221
   156
 */
slouken@5221
   157
extern DECLSPEC void SDLCALL SDL_LogInfo(int category, const char *fmt, ...);
slouken@5221
   158
slouken@5221
   159
/**
slouken@5221
   160
 *  \brief Log a message with SDL_LOG_PRIORITY_WARN
slouken@5221
   161
 */
slouken@5221
   162
extern DECLSPEC void SDLCALL SDL_LogWarn(int category, const char *fmt, ...);
slouken@5221
   163
slouken@5221
   164
/**
slouken@5221
   165
 *  \brief Log a message with SDL_LOG_PRIORITY_ERROR
slouken@5221
   166
 */
slouken@5221
   167
extern DECLSPEC void SDLCALL SDL_LogError(int category, const char *fmt, ...);
slouken@5221
   168
slouken@5221
   169
/**
slouken@5221
   170
 *  \brief Log a message with SDL_LOG_PRIORITY_CRITICAL
slouken@5221
   171
 */
slouken@5221
   172
extern DECLSPEC void SDLCALL SDL_LogCritical(int category, const char *fmt, ...);
slouken@5221
   173
slouken@5221
   174
/**
slouken@5221
   175
 *  \brief Log a message with the specified category and priority.
slouken@5221
   176
 */
slouken@5221
   177
extern DECLSPEC void SDLCALL SDL_LogMessage(int category,
slouken@5221
   178
                                            SDL_LogPriority priority,
slouken@5221
   179
                                            const char *fmt, ...);
slouken@5221
   180
slouken@5221
   181
/**
slouken@5221
   182
 *  \brief Log a message with the specified category and priority.
slouken@5221
   183
 */
slouken@5221
   184
extern DECLSPEC void SDLCALL SDL_LogMessageV(int category,
slouken@5221
   185
                                             SDL_LogPriority priority,
slouken@5221
   186
                                             const char *fmt, va_list ap);
slouken@5221
   187
slouken@5235
   188
/**
slouken@5235
   189
 *  \brief The prototype for the log output function
slouken@5235
   190
 */
slouken@5235
   191
typedef void (*SDL_LogOutputFunction)(void *userdata, int category, SDL_LogPriority priority, const char *message);
slouken@5235
   192
slouken@5235
   193
/**
slouken@5235
   194
 *  \brief Get the current log output function.
slouken@5235
   195
 */
slouken@5235
   196
extern DECLSPEC void SDLCALL SDL_LogGetOutputFunction(SDL_LogOutputFunction *callback, void **userdata);
slouken@5235
   197
slouken@5235
   198
/**
slouken@5235
   199
 *  \brief This function allows you to replace the default log output
slouken@5235
   200
 *         function with one of your own.
slouken@5235
   201
 */
slouken@5235
   202
extern DECLSPEC void SDLCALL SDL_LogSetOutputFunction(SDL_LogOutputFunction callback, void *userdata);
slouken@5235
   203
slouken@5221
   204
slouken@5221
   205
/* Ends C function definitions when using C++ */
slouken@5221
   206
#ifdef __cplusplus
slouken@5221
   207
/* *INDENT-OFF* */
slouken@5221
   208
}
slouken@5221
   209
/* *INDENT-ON* */
slouken@5221
   210
#endif
slouken@5221
   211
#include "close_code.h"
slouken@5221
   212
slouken@5221
   213
#endif /* _SDL_log_h */
slouken@5221
   214
slouken@5221
   215
/* vi: set ts=4 sw=4 expandtab: */