src/SDL_log.c
author Sam Lantinga <slouken@libsdl.org>
Sat, 31 Dec 2011 09:28:07 -0500
changeset 6138 4c64952a58fb
parent 6040 08aa9c1dfed6
child 6616 4f272256d172
child 8325 33cbbdd796ec
permissions -rwxr-xr-x
Happy New Year!
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
6138
4c64952a58fb Happy New Year!
Sam Lantinga <slouken@libsdl.org>
parents: 6040
diff changeset
     3
  Copyright (C) 1997-2012 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
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    38
#define DEFAULT_APPLICATION_PRIORITY    SDL_LOG_PRIORITY_INFO
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    39
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    40
typedef struct SDL_LogLevel
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    41
{
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    42
    int category;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    43
    SDL_LogPriority priority;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    44
    struct SDL_LogLevel *next;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    45
} SDL_LogLevel;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    46
5235
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
    47
/* The default log output function */
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
    48
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
    49
                          int category, SDL_LogPriority priority,
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
    50
                          const char *message);
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
    51
5221
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    52
static SDL_LogLevel *SDL_loglevels;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    53
static SDL_LogPriority SDL_application_priority = DEFAULT_APPLICATION_PRIORITY;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    54
static SDL_LogPriority SDL_default_priority = DEFAULT_PRIORITY;
5235
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
    55
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
    56
static void *SDL_log_userdata = NULL;
5221
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    57
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    58
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
    59
    NULL,
5221
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    60
    "VERBOSE",
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    61
    "DEBUG",
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    62
    "INFO",
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    63
    "WARN",
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    64
    "ERROR",
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    65
    "CRITICAL"
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    66
};
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    67
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    68
#ifdef __ANDROID__
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    69
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
    70
    "APP",
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
    "SYSTEM",
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    73
    "AUDIO",
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    74
    "VIDEO",
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    75
    "RENDER",
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    76
    "INPUT"
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    77
};
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    78
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    79
static int SDL_android_priority[SDL_NUM_LOG_PRIORITIES] = {
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    80
    ANDROID_LOG_VERBOSE,
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    81
    ANDROID_LOG_DEBUG,
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    82
    ANDROID_LOG_INFO,
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    83
    ANDROID_LOG_WARN,
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    84
    ANDROID_LOG_ERROR,
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    85
    ANDROID_LOG_FATAL
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    86
};
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    87
#endif /* __ANDROID__ */
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    88
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    89
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    90
void
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    91
SDL_LogSetAllPriority(SDL_LogPriority priority)
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    92
{
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    93
    SDL_LogLevel *entry;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    94
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    95
    for (entry = SDL_loglevels; entry; entry = entry->next) {
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    96
        entry->priority = priority;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    97
    }
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    98
    SDL_application_priority = SDL_default_priority = 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
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   101
void
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   102
SDL_LogSetPriority(int category, SDL_LogPriority priority)
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   103
{
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   104
    SDL_LogLevel *entry;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   105
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   106
    for (entry = SDL_loglevels; entry; entry = entry->next) {
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   107
        if (entry->category == category) {
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   108
            entry->priority = priority;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   109
            return;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   110
        }
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   111
    }
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
    /* Create a new entry */
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   114
    entry = (SDL_LogLevel *)SDL_malloc(sizeof(*entry));
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   115
    if (entry) {
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   116
        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
        entry->next = SDL_loglevels;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   119
        SDL_loglevels = entry;
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
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   123
SDL_LogPriority
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   124
SDL_LogGetPriority(int category)
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   125
{
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   126
    SDL_LogLevel *entry;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   127
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   128
    for (entry = SDL_loglevels; entry; entry = entry->next) {
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   129
        if (entry->category == category) {
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   130
            return entry->priority;
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
    }
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   133
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   134
    if (category == SDL_LOG_CATEGORY_APPLICATION) {
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   135
        return SDL_application_priority;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   136
    } else {
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   137
        return SDL_default_priority;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   138
    }
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   139
}
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
void
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   142
SDL_LogResetPriorities(void)
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   143
{
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   144
    SDL_LogLevel *entry;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   145
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   146
    while (SDL_loglevels) {
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   147
        entry = SDL_loglevels;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   148
        SDL_loglevels = entry->next;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   149
        SDL_free(entry);
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   150
    }
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
    SDL_application_priority = DEFAULT_APPLICATION_PRIORITY;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   153
    SDL_default_priority = DEFAULT_PRIORITY;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   154
}
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   155
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   156
void
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   157
SDL_Log(const char *fmt, ...)
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
    va_list ap;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   160
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   161
    va_start(ap, fmt);
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   162
    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
   163
    va_end(ap);
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   164
}
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   165
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   166
void
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   167
SDL_LogVerbose(int category, const char *fmt, ...)
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   168
{
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   169
    va_list ap;
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
    va_start(ap, fmt);
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   172
    SDL_LogMessageV(category, SDL_LOG_PRIORITY_VERBOSE, fmt, ap);
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   173
    va_end(ap);
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   174
}
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
void
5348
16202b090a63 Added missing log debug function
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   177
SDL_LogDebug(int category, const char *fmt, ...)
16202b090a63 Added missing log debug function
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   178
{
16202b090a63 Added missing log debug function
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   179
    va_list ap;
16202b090a63 Added missing log debug function
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   180
16202b090a63 Added missing log debug function
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   181
    va_start(ap, fmt);
16202b090a63 Added missing log debug function
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   182
    SDL_LogMessageV(category, SDL_LOG_PRIORITY_DEBUG, fmt, ap);
16202b090a63 Added missing log debug function
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   183
    va_end(ap);
16202b090a63 Added missing log debug function
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   184
}
16202b090a63 Added missing log debug function
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   185
16202b090a63 Added missing log debug function
Sam Lantinga <slouken@libsdl.org>
parents: 5262
diff changeset
   186
void
5221
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   187
SDL_LogInfo(int category, const char *fmt, ...)
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   188
{
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   189
    va_list ap;
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
    va_start(ap, fmt);
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   192
    SDL_LogMessageV(category, SDL_LOG_PRIORITY_INFO, fmt, ap);
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   193
    va_end(ap);
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   194
}
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   195
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   196
void
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   197
SDL_LogWarn(int category, const char *fmt, ...)
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   198
{
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   199
    va_list ap;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   200
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   201
    va_start(ap, fmt);
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   202
    SDL_LogMessageV(category, SDL_LOG_PRIORITY_WARN, fmt, ap);
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   203
    va_end(ap);
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   204
}
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
void
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   207
SDL_LogError(int category, const char *fmt, ...)
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   208
{
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   209
    va_list ap;
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
    va_start(ap, fmt);
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   212
    SDL_LogMessageV(category, SDL_LOG_PRIORITY_ERROR, fmt, ap);
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   213
    va_end(ap);
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   214
}
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
void
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   217
SDL_LogCritical(int category, const char *fmt, ...)
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   218
{
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   219
    va_list ap;
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
    va_start(ap, fmt);
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   222
    SDL_LogMessageV(category, SDL_LOG_PRIORITY_CRITICAL, fmt, ap);
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   223
    va_end(ap);
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   224
}
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
void
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   227
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
   228
{
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   229
    va_list ap;
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
    va_start(ap, fmt);
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   232
    SDL_LogMessageV(category, priority, fmt, ap);
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   233
    va_end(ap);
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   234
}
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
#ifdef __ANDROID__
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   237
static const char *
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   238
GetCategoryPrefix(int category)
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
    if (category < SDL_LOG_CATEGORY_RESERVED1) {
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   241
        return SDL_category_prefixes[category];
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   242
    }
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   243
    if (category < SDL_LOG_CATEGORY_CUSTOM) {
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   244
        return "RESERVED";
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
    return "CUSTOM";
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   247
}
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   248
#endif /* __ANDROID__ */
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
void
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   251
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
   252
{
5223
ab0d7cecc0f6 Fixed stack overflow on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 5221
diff changeset
   253
    char *message;
5221
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   254
5235
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   255
    /* 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
   256
    if (!SDL_log_function) {
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   257
        return;
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   258
    }
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   259
5221
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   260
    /* Make sure we don't exceed array bounds */
6040
08aa9c1dfed6 Fixed warnings on iOS
Sam Lantinga <slouken@libsdl.org>
parents: 5535
diff changeset
   261
    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
   262
        return;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   263
    }
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
    /* 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
   266
    if (priority < SDL_LogGetPriority(category)) {
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   267
        return;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   268
    }
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   269
5223
ab0d7cecc0f6 Fixed stack overflow on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 5221
diff changeset
   270
    message = SDL_stack_alloc(char, SDL_MAX_LOG_MESSAGE);
ab0d7cecc0f6 Fixed stack overflow on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 5221
diff changeset
   271
    if (!message) {
ab0d7cecc0f6 Fixed stack overflow on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 5221
diff changeset
   272
        return;
ab0d7cecc0f6 Fixed stack overflow on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 5221
diff changeset
   273
    }
ab0d7cecc0f6 Fixed stack overflow on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 5221
diff changeset
   274
    SDL_vsnprintf(message, SDL_MAX_LOG_MESSAGE, fmt, ap);
5235
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   275
    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
   276
    SDL_stack_free(message);
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   277
}
5221
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   278
5235
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   279
static void
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   280
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
   281
              const char *message)
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   282
{
5221
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   283
#if defined(__WIN32__)
5223
ab0d7cecc0f6 Fixed stack overflow on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 5221
diff changeset
   284
    /* Way too many allocations here, urgh */
5221
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
        char *output;
ab0d7cecc0f6 Fixed stack overflow on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 5221
diff changeset
   287
        size_t length;
5221
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   288
        LPTSTR tstr;
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   289
5223
ab0d7cecc0f6 Fixed stack overflow on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 5221
diff changeset
   290
        length = SDL_strlen(SDL_priority_prefixes[priority]) + 2 + SDL_strlen(message) + 1;
ab0d7cecc0f6 Fixed stack overflow on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 5221
diff changeset
   291
        output = SDL_stack_alloc(char, length);
ab0d7cecc0f6 Fixed stack overflow on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 5221
diff changeset
   292
        SDL_snprintf(output, length, "%s: %s", SDL_priority_prefixes[priority], message);
5221
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   293
        tstr = WIN_UTF8ToString(output);
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   294
        OutputDebugString(tstr);
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   295
        SDL_free(tstr);
5223
ab0d7cecc0f6 Fixed stack overflow on Windows
Sam Lantinga <slouken@libsdl.org>
parents: 5221
diff changeset
   296
        SDL_stack_free(output);
5221
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   297
    }
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   298
#elif defined(__ANDROID__)
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   299
    {
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   300
        char tag[32];
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   301
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   302
        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
   303
        __android_log_write(SDL_android_priority[priority], tag, message);
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   304
    }
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   305
#endif
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   306
#if HAVE_STDIO_H
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   307
    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
   308
#endif
5235
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   309
}
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   310
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   311
void
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   312
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
   313
{
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   314
    if (callback) {
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   315
        *callback = SDL_log_function;
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   316
    }
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   317
    if (userdata) {
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   318
        *userdata = SDL_log_userdata;
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   319
    }
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   320
}
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   321
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   322
void
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   323
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
   324
{
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   325
    SDL_log_function = callback;
1e28342cb15d Added a way to replace the default logging mechanism
Sam Lantinga <slouken@libsdl.org>
parents: 5223
diff changeset
   326
    SDL_log_userdata = userdata;
5221
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   327
}
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   328
2ee8112bfc6b Added a simple log message API
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   329
/* vi: set ts=4 sw=4 expandtab: */