src/SDL_log.c
author Philipp Wiesemann <philipp.wiesemann@arcor.de>
Sat, 27 Jul 2013 14:06:06 +0200
changeset 7532 2c54272792e2
parent 7350 302af2a46a66
child 7614 af0bd07212bd
permissions -rw-r--r--
Removed C++ macro setup in internal header for Android port which is only C now.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5221
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     1
/*
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5348
diff changeset
     2
  Simple DirectMedia Layer
6885
700f1b25f77f Happy New Year!
Sam Lantinga <slouken@libsdl.org>
parents: 6717
diff changeset
     3
  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
5221
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     4
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5348
diff changeset
     5
  This software is provided 'as-is', without any express or implied
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5348
diff changeset
     6
  warranty.  In no event will the authors be held liable for any damages
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5348
diff changeset
     7
  arising from the use of this software.
5221
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     8
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5348
diff changeset
     9
  Permission is granted to anyone to use this software for any purpose,
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5348
diff changeset
    10
  including commercial applications, and to alter it and redistribute it
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5348
diff changeset
    11
  freely, subject to the following restrictions:
5221
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    12
5535
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5348
diff changeset
    13
  1. The origin of this software must not be misrepresented; you must not
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5348
diff changeset
    14
     claim that you wrote the original software. If you use this software
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5348
diff changeset
    15
     in a product, an acknowledgment in the product documentation would be
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5348
diff changeset
    16
     appreciated but is not required.
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5348
diff changeset
    17
  2. Altered source versions must be plainly marked as such, and must not be
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5348
diff changeset
    18
     misrepresented as being the original software.
96594ac5fd1a SDL 1.3 is now under the zlib license.
Sam Lantinga <slouken@libsdl.org>
parents: 5348
diff changeset
    19
  3. This notice may not be removed or altered from any source distribution.
5221
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    20
*/
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    21
#include "SDL_config.h"
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    22
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    23
/* Simple log messages in SDL */
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    24
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    25
#include "SDL_log.h"
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    26
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    27
#if HAVE_STDIO_H
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    28
#include <stdio.h>
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    29
#endif
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    30
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    31
#if defined(__WIN32__)
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    32
#include "core/windows/SDL_windows.h"
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    33
#elif defined(__ANDROID__)
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    34
#include <android/log.h>
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    35
#endif
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    36
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    37
#define DEFAULT_PRIORITY                SDL_LOG_PRIORITY_CRITICAL
6616
4f272256d172 Added an assert log category, and NSLog support on Mac OS X and iOS
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
    38
#define DEFAULT_ASSERT_PRIORITY         SDL_LOG_PRIORITY_WARN
5221
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    39
#define DEFAULT_APPLICATION_PRIORITY    SDL_LOG_PRIORITY_INFO
6717
2acd95060548 Add log, assert and harness (partial) to test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6616
diff changeset
    40
#define DEFAULT_TEST_PRIORITY           SDL_LOG_PRIORITY_VERBOSE
5221
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    41
7274
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
    42
/* Forward definition of error function */
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
    43
extern int SDL_SetError(const char *fmt, ...);
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
    44
5221
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    45
typedef struct SDL_LogLevel
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    46
{
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    47
    int category;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    48
    SDL_LogPriority priority;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    49
    struct SDL_LogLevel *next;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    50
} SDL_LogLevel;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    51
5235
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
    52
/* The default log output function */
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
    53
static void SDL_LogOutput(void *userdata,
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
    54
                          int category, SDL_LogPriority priority,
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
    55
                          const char *message);
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
    56
5221
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    57
static SDL_LogLevel *SDL_loglevels;
6616
4f272256d172 Added an assert log category, and NSLog support on Mac OS X and iOS
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
    58
static SDL_LogPriority SDL_default_priority = DEFAULT_PRIORITY;
4f272256d172 Added an assert log category, and NSLog support on Mac OS X and iOS
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
    59
static SDL_LogPriority SDL_assert_priority = DEFAULT_ASSERT_PRIORITY;
5221
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    60
static SDL_LogPriority SDL_application_priority = DEFAULT_APPLICATION_PRIORITY;
6717
2acd95060548 Add log, assert and harness (partial) to test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6616
diff changeset
    61
static SDL_LogPriority SDL_test_priority = DEFAULT_TEST_PRIORITY;
5235
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
    62
static SDL_LogOutputFunction SDL_log_function = SDL_LogOutput;
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
    63
static void *SDL_log_userdata = NULL;
5221
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    64
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    65
static const char *SDL_priority_prefixes[SDL_NUM_LOG_PRIORITIES] = {
5235
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
    66
    NULL,
5221
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    67
    "VERBOSE",
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    68
    "DEBUG",
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    69
    "INFO",
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    70
    "WARN",
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    71
    "ERROR",
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    72
    "CRITICAL"
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    73
};
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    74
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    75
#ifdef __ANDROID__
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    76
static const char *SDL_category_prefixes[SDL_LOG_CATEGORY_RESERVED1] = {
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    77
    "APP",
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    78
    "ERROR",
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    79
    "SYSTEM",
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    80
    "AUDIO",
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    81
    "VIDEO",
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    82
    "RENDER",
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    83
    "INPUT"
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    84
};
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    85
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    86
static int SDL_android_priority[SDL_NUM_LOG_PRIORITIES] = {
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    87
    ANDROID_LOG_VERBOSE,
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    88
    ANDROID_LOG_DEBUG,
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    89
    ANDROID_LOG_INFO,
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    90
    ANDROID_LOG_WARN,
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    91
    ANDROID_LOG_ERROR,
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    92
    ANDROID_LOG_FATAL
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    93
};
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    94
#endif /* __ANDROID__ */
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    95
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    96
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    97
void
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    98
SDL_LogSetAllPriority(SDL_LogPriority priority)
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    99
{
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   100
    SDL_LogLevel *entry;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   101
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   102
    for (entry = SDL_loglevels; entry; entry = entry->next) {
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   103
        entry->priority = priority;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   104
    }
6616
4f272256d172 Added an assert log category, and NSLog support on Mac OS X and iOS
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   105
    SDL_default_priority = priority;
4f272256d172 Added an assert log category, and NSLog support on Mac OS X and iOS
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   106
    SDL_assert_priority = priority;
4f272256d172 Added an assert log category, and NSLog support on Mac OS X and iOS
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   107
    SDL_application_priority = priority;
5221
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   108
}
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   109
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   110
void
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   111
SDL_LogSetPriority(int category, SDL_LogPriority priority)
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   112
{
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   113
    SDL_LogLevel *entry;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   114
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   115
    for (entry = SDL_loglevels; entry; entry = entry->next) {
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   116
        if (entry->category == category) {
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   117
            entry->priority = priority;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   118
            return;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   119
        }
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   120
    }
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   121
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   122
    /* Create a new entry */
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   123
    entry = (SDL_LogLevel *)SDL_malloc(sizeof(*entry));
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   124
    if (entry) {
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   125
        entry->category = category;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   126
        entry->priority = priority;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   127
        entry->next = SDL_loglevels;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   128
        SDL_loglevels = entry;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   129
    }
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   130
}
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   131
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   132
SDL_LogPriority
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   133
SDL_LogGetPriority(int category)
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   134
{
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   135
    SDL_LogLevel *entry;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   136
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   137
    for (entry = SDL_loglevels; entry; entry = entry->next) {
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   138
        if (entry->category == category) {
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   139
            return entry->priority;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   140
        }
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   141
    }
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   142
6717
2acd95060548 Add log, assert and harness (partial) to test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6616
diff changeset
   143
    if (category == SDL_LOG_CATEGORY_TEST) {
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7009
diff changeset
   144
        return SDL_test_priority;
6717
2acd95060548 Add log, assert and harness (partial) to test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6616
diff changeset
   145
    } else if (category == SDL_LOG_CATEGORY_APPLICATION) {
5221
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   146
        return SDL_application_priority;
6616
4f272256d172 Added an assert log category, and NSLog support on Mac OS X and iOS
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   147
    } else if (category == SDL_LOG_CATEGORY_ASSERT) {
4f272256d172 Added an assert log category, and NSLog support on Mac OS X and iOS
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   148
        return SDL_assert_priority;
5221
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   149
    } else {
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   150
        return SDL_default_priority;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   151
    }
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   152
}
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   153
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   154
void
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   155
SDL_LogResetPriorities(void)
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   156
{
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   157
    SDL_LogLevel *entry;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   158
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   159
    while (SDL_loglevels) {
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   160
        entry = SDL_loglevels;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   161
        SDL_loglevels = entry->next;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   162
        SDL_free(entry);
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   163
    }
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   164
6616
4f272256d172 Added an assert log category, and NSLog support on Mac OS X and iOS
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   165
    SDL_default_priority = DEFAULT_PRIORITY;
4f272256d172 Added an assert log category, and NSLog support on Mac OS X and iOS
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   166
    SDL_assert_priority = DEFAULT_ASSERT_PRIORITY;
5221
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   167
    SDL_application_priority = DEFAULT_APPLICATION_PRIORITY;
6717
2acd95060548 Add log, assert and harness (partial) to test lib
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 6616
diff changeset
   168
    SDL_test_priority = DEFAULT_TEST_PRIORITY;
5221
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   169
}
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   170
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   171
void
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   172
SDL_Log(const char *fmt, ...)
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   173
{
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   174
    va_list ap;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   175
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   176
    va_start(ap, fmt);
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   177
    SDL_LogMessageV(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, fmt, ap);
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   178
    va_end(ap);
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   179
}
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   180
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   181
void
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   182
SDL_LogVerbose(int category, const char *fmt, ...)
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   183
{
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   184
    va_list ap;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   185
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   186
    va_start(ap, fmt);
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   187
    SDL_LogMessageV(category, SDL_LOG_PRIORITY_VERBOSE, fmt, ap);
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   188
    va_end(ap);
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   189
}
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   190
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   191
void
5348
16202b090a63 Added missing log debug function
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   192
SDL_LogDebug(int category, const char *fmt, ...)
16202b090a63 Added missing log debug function
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   193
{
16202b090a63 Added missing log debug function
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   194
    va_list ap;
16202b090a63 Added missing log debug function
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   195
16202b090a63 Added missing log debug function
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   196
    va_start(ap, fmt);
16202b090a63 Added missing log debug function
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   197
    SDL_LogMessageV(category, SDL_LOG_PRIORITY_DEBUG, fmt, ap);
16202b090a63 Added missing log debug function
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   198
    va_end(ap);
16202b090a63 Added missing log debug function
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   199
}
16202b090a63 Added missing log debug function
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   200
16202b090a63 Added missing log debug function
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   201
void
5221
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   202
SDL_LogInfo(int category, const char *fmt, ...)
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   203
{
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   204
    va_list ap;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   205
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   206
    va_start(ap, fmt);
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   207
    SDL_LogMessageV(category, SDL_LOG_PRIORITY_INFO, fmt, ap);
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   208
    va_end(ap);
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   209
}
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   210
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   211
void
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   212
SDL_LogWarn(int category, const char *fmt, ...)
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   213
{
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   214
    va_list ap;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   215
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   216
    va_start(ap, fmt);
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   217
    SDL_LogMessageV(category, SDL_LOG_PRIORITY_WARN, fmt, ap);
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   218
    va_end(ap);
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   219
}
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   220
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   221
void
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   222
SDL_LogError(int category, const char *fmt, ...)
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   223
{
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   224
    va_list ap;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   225
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   226
    va_start(ap, fmt);
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   227
    SDL_LogMessageV(category, SDL_LOG_PRIORITY_ERROR, fmt, ap);
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   228
    va_end(ap);
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   229
}
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   230
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   231
void
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   232
SDL_LogCritical(int category, const char *fmt, ...)
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   233
{
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   234
    va_list ap;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   235
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   236
    va_start(ap, fmt);
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   237
    SDL_LogMessageV(category, SDL_LOG_PRIORITY_CRITICAL, fmt, ap);
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   238
    va_end(ap);
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   239
}
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   240
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   241
void
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   242
SDL_LogMessage(int category, SDL_LogPriority priority, const char *fmt, ...)
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   243
{
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   244
    va_list ap;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   245
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   246
    va_start(ap, fmt);
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   247
    SDL_LogMessageV(category, priority, fmt, ap);
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   248
    va_end(ap);
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   249
}
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   250
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   251
#ifdef __ANDROID__
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   252
static const char *
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   253
GetCategoryPrefix(int category)
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   254
{
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   255
    if (category < SDL_LOG_CATEGORY_RESERVED1) {
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   256
        return SDL_category_prefixes[category];
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   257
    }
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   258
    if (category < SDL_LOG_CATEGORY_CUSTOM) {
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   259
        return "RESERVED";
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   260
    }
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   261
    return "CUSTOM";
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   262
}
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   263
#endif /* __ANDROID__ */
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   264
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   265
void
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   266
SDL_LogMessageV(int category, SDL_LogPriority priority, const char *fmt, va_list ap)
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   267
{
5223
ab0d7cecc0f6 Fixed stack overflow on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 5221
diff changeset
   268
    char *message;
7344
3d9397262c10 Strip newlines from messages in SDL_Log*() before calling logging function.
Ryan C. Gordon <icculus@icculus.org>
parents: 7343
diff changeset
   269
    size_t len;
5221
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   270
5235
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   271
    /* Nothing to do if we don't have an output function */
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   272
    if (!SDL_log_function) {
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   273
        return;
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   274
    }
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   275
5221
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   276
    /* Make sure we don't exceed array bounds */
6040
08aa9c1dfed6 Fixed warnings on iOS
Sam Lantinga <slouken@libsdl.org>
parents: 5535
diff changeset
   277
    if ((int)priority < 0 || priority >= SDL_NUM_LOG_PRIORITIES) {
5221
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   278
        return;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   279
    }
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   280
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   281
    /* See if we want to do anything with this message */
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   282
    if (priority < SDL_LogGetPriority(category)) {
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   283
        return;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   284
    }
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   285
5223
ab0d7cecc0f6 Fixed stack overflow on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 5221
diff changeset
   286
    message = SDL_stack_alloc(char, SDL_MAX_LOG_MESSAGE);
ab0d7cecc0f6 Fixed stack overflow on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 5221
diff changeset
   287
    if (!message) {
ab0d7cecc0f6 Fixed stack overflow on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 5221
diff changeset
   288
        return;
ab0d7cecc0f6 Fixed stack overflow on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 5221
diff changeset
   289
    }
7344
3d9397262c10 Strip newlines from messages in SDL_Log*() before calling logging function.
Ryan C. Gordon <icculus@icculus.org>
parents: 7343
diff changeset
   290
5223
ab0d7cecc0f6 Fixed stack overflow on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 5221
diff changeset
   291
    SDL_vsnprintf(message, SDL_MAX_LOG_MESSAGE, fmt, ap);
7344
3d9397262c10 Strip newlines from messages in SDL_Log*() before calling logging function.
Ryan C. Gordon <icculus@icculus.org>
parents: 7343
diff changeset
   292
3d9397262c10 Strip newlines from messages in SDL_Log*() before calling logging function.
Ryan C. Gordon <icculus@icculus.org>
parents: 7343
diff changeset
   293
    /* Chop off final endline. */
3d9397262c10 Strip newlines from messages in SDL_Log*() before calling logging function.
Ryan C. Gordon <icculus@icculus.org>
parents: 7343
diff changeset
   294
    len = SDL_strlen(message);
3d9397262c10 Strip newlines from messages in SDL_Log*() before calling logging function.
Ryan C. Gordon <icculus@icculus.org>
parents: 7343
diff changeset
   295
    if ((len > 0) && (message[len-1] == '\n')) {
3d9397262c10 Strip newlines from messages in SDL_Log*() before calling logging function.
Ryan C. Gordon <icculus@icculus.org>
parents: 7343
diff changeset
   296
        message[--len] = '\0';
3d9397262c10 Strip newlines from messages in SDL_Log*() before calling logging function.
Ryan C. Gordon <icculus@icculus.org>
parents: 7343
diff changeset
   297
        if ((len > 0) && (message[len-1] == '\r')) {  /* catch "\r\n", too. */
3d9397262c10 Strip newlines from messages in SDL_Log*() before calling logging function.
Ryan C. Gordon <icculus@icculus.org>
parents: 7343
diff changeset
   298
            message[--len] = '\0';
3d9397262c10 Strip newlines from messages in SDL_Log*() before calling logging function.
Ryan C. Gordon <icculus@icculus.org>
parents: 7343
diff changeset
   299
        }
3d9397262c10 Strip newlines from messages in SDL_Log*() before calling logging function.
Ryan C. Gordon <icculus@icculus.org>
parents: 7343
diff changeset
   300
    }
3d9397262c10 Strip newlines from messages in SDL_Log*() before calling logging function.
Ryan C. Gordon <icculus@icculus.org>
parents: 7343
diff changeset
   301
5235
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   302
    SDL_log_function(SDL_log_userdata, category, priority, message);
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   303
    SDL_stack_free(message);
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   304
}
5221
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   305
7274
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
   306
#if defined(__WIN32__)
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
   307
/* Flag tracking the attachment of the console: 0=unattached, 1=attached, -1=error */
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
   308
static int consoleAttached = 0;
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
   309
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
   310
/* Handle to stderr output of console. */
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
   311
static HANDLE stderrHandle = NULL;
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
   312
#endif
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
   313
5235
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   314
static void
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   315
SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority,
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   316
              const char *message)
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   317
{
5221
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   318
#if defined(__WIN32__)
5223
ab0d7cecc0f6 Fixed stack overflow on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 5221
diff changeset
   319
    /* Way too many allocations here, urgh */
5221
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   320
    {
5223
ab0d7cecc0f6 Fixed stack overflow on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 5221
diff changeset
   321
        char *output;
ab0d7cecc0f6 Fixed stack overflow on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 5221
diff changeset
   322
        size_t length;
5221
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   323
        LPTSTR tstr;
7274
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
   324
        BOOL attachResult;
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
   325
        DWORD attachError;
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
   326
        unsigned long charsWritten; 
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
   327
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
   328
        /* Maybe attach console and get stderr handle */
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
   329
        if (consoleAttached == 0) {
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
   330
            attachResult = AttachConsole(ATTACH_PARENT_PROCESS);
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
   331
            if (!attachResult) {
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
   332
                    attachError = GetLastError();
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
   333
                    if (attachError == ERROR_INVALID_HANDLE) {
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
   334
                        SDL_SetError("Parent process has no console");
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
   335
                        consoleAttached = -1;
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
   336
                    } else if (attachError == ERROR_GEN_FAILURE) {
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
   337
                         SDL_SetError("Could not attach to console of parent process");
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
   338
                         consoleAttached = -1;
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
   339
                    } else if (attachError == ERROR_ACCESS_DENIED) {  
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
   340
                         /* Already attached */
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
   341
                        consoleAttached = 1;
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
   342
                    } else {
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
   343
                        SDL_SetError("Error %d attaching console", attachError);
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
   344
                        consoleAttached = -1;
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
   345
                    }
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
   346
                } else {
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
   347
                    /* Newly attached */
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
   348
                    consoleAttached = 1;
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
   349
                }
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
   350
			
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
   351
                if (consoleAttached == 1) {
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
   352
                        stderrHandle = GetStdHandle(STD_ERROR_HANDLE);
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
   353
                }
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
   354
        }
5221
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   355
7215
41e739a52f69 Added a newline to OutputDebugString(), fixes output on Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   356
        length = SDL_strlen(SDL_priority_prefixes[priority]) + 2 + SDL_strlen(message) + 1 + 1;
5223
ab0d7cecc0f6 Fixed stack overflow on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 5221
diff changeset
   357
        output = SDL_stack_alloc(char, length);
7215
41e739a52f69 Added a newline to OutputDebugString(), fixes output on Visual Studio 2008
Sam Lantinga <slouken@libsdl.org>
parents: 7191
diff changeset
   358
        SDL_snprintf(output, length, "%s: %s\n", SDL_priority_prefixes[priority], message);
5221
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   359
        tstr = WIN_UTF8ToString(output);
7274
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
   360
        
7292
fdf42e4cdcec Remove unnecessary debugger detection logic again from Win32 SDL_LogOutput
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7274
diff changeset
   361
        /* Output to debugger */
fdf42e4cdcec Remove unnecessary debugger detection logic again from Win32 SDL_LogOutput
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7274
diff changeset
   362
        OutputDebugString(tstr);
7274
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
   363
       
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
   364
        /* Screen output to stderr, if console was attached. */
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
   365
        if (consoleAttached == 1) {
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
   366
                if (!WriteConsole(stderrHandle, tstr, lstrlen(tstr), &charsWritten, NULL)) {
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
   367
                    SDL_SetError("Error %d calling WriteConsole", GetLastError());
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
   368
                }
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
   369
                if (charsWritten == ERROR_NOT_ENOUGH_MEMORY) {
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
   370
                    SDL_SetError("Insufficient heap memory to write message of size %d", length);
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
   371
                }
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
   372
        }
d9ef44d91559 Update SDL_LogOutput for WIN32 so it writes to the console
Andreas Schiffler <aschiffler@ferzkopp.net>
parents: 7215
diff changeset
   373
5221
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   374
        SDL_free(tstr);
5223
ab0d7cecc0f6 Fixed stack overflow on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 5221
diff changeset
   375
        SDL_stack_free(output);
5221
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   376
    }
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   377
#elif defined(__ANDROID__)
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   378
    {
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   379
        char tag[32];
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   380
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   381
        SDL_snprintf(tag, SDL_arraysize(tag), "SDL/%s", GetCategoryPrefix(category));
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   382
        __android_log_write(SDL_android_priority[priority], tag, message);
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   383
    }
7307
5d6b7b9432d3 Fixed SDL building with the minimal configuration
Sam Lantinga <slouken@libsdl.org>
parents: 7292
diff changeset
   384
#elif defined(__APPLE__) && defined(SDL_VIDEO_DRIVER_COCOA)
5d6b7b9432d3 Fixed SDL building with the minimal configuration
Sam Lantinga <slouken@libsdl.org>
parents: 7292
diff changeset
   385
    /* Technically we don't need SDL_VIDEO_DRIVER_COCOA, but that's where this function is defined for now.
5d6b7b9432d3 Fixed SDL building with the minimal configuration
Sam Lantinga <slouken@libsdl.org>
parents: 7292
diff changeset
   386
    */
6616
4f272256d172 Added an assert log category, and NSLog support on Mac OS X and iOS
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   387
    extern void SDL_NSLog(const char *text);
4f272256d172 Added an assert log category, and NSLog support on Mac OS X and iOS
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   388
    {
4f272256d172 Added an assert log category, and NSLog support on Mac OS X and iOS
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   389
        char *text;
4f272256d172 Added an assert log category, and NSLog support on Mac OS X and iOS
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   390
4f272256d172 Added an assert log category, and NSLog support on Mac OS X and iOS
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   391
        text = SDL_stack_alloc(char, SDL_MAX_LOG_MESSAGE);
4f272256d172 Added an assert log category, and NSLog support on Mac OS X and iOS
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   392
        if (text) {
4f272256d172 Added an assert log category, and NSLog support on Mac OS X and iOS
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   393
            SDL_snprintf(text, SDL_MAX_LOG_MESSAGE, "%s: %s", SDL_priority_prefixes[priority], message);
4f272256d172 Added an assert log category, and NSLog support on Mac OS X and iOS
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   394
            SDL_NSLog(text);
4f272256d172 Added an assert log category, and NSLog support on Mac OS X and iOS
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   395
            SDL_stack_free(text);
4f272256d172 Added an assert log category, and NSLog support on Mac OS X and iOS
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   396
            return;
4f272256d172 Added an assert log category, and NSLog support on Mac OS X and iOS
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   397
        }
4f272256d172 Added an assert log category, and NSLog support on Mac OS X and iOS
Sam Lantinga <slouken@libsdl.org>
parents: 6138
diff changeset
   398
    }
7009
161b7b6a5303 Add PSP support
Captain Lex <kimonline@126.com>
parents: 6885
diff changeset
   399
#elif defined(__PSP__)
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7009
diff changeset
   400
    {
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7009
diff changeset
   401
        FILE*        pFile;
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7009
diff changeset
   402
        pFile = fopen ("SDL_Log.txt", "a");
7350
302af2a46a66 No, there's no reason not to use fprintf
Sam Lantinga <slouken@libsdl.org>
parents: 7344
diff changeset
   403
        fprintf(pFile, "%s: %s\n", SDL_priority_prefixes[priority], message);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7009
diff changeset
   404
        fclose (pFile);
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7009
diff changeset
   405
    }
5221
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   406
#endif
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   407
#if HAVE_STDIO_H
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   408
    fprintf(stderr, "%s: %s\n", SDL_priority_prefixes[priority], message);
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   409
#endif
5235
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   410
}
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   411
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   412
void
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   413
SDL_LogGetOutputFunction(SDL_LogOutputFunction *callback, void **userdata)
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   414
{
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   415
    if (callback) {
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   416
        *callback = SDL_log_function;
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   417
    }
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   418
    if (userdata) {
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   419
        *userdata = SDL_log_userdata;
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   420
    }
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   421
}
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   422
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   423
void
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   424
SDL_LogSetOutputFunction(SDL_LogOutputFunction callback, void *userdata)
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   425
{
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   426
    SDL_log_function = callback;
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   427
    SDL_log_userdata = userdata;
5221
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   428
}
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   429
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   430
/* vi: set ts=4 sw=4 expandtab: */