zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SDL_test_log.c
Go to the documentation of this file.
1 /*
2  Simple DirectMedia Layer
3  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
4 
5  This software is provided 'as-is', without any express or implied
6  warranty. In no event will the authors be held liable for any damages
7  arising from the use of this software.
8 
9  Permission is granted to anyone to use this software for any purpose,
10  including commercial applications, and to alter it and redistribute it
11  freely, subject to the following restrictions:
12 
13  1. The origin of this software must not be misrepresented; you must not
14  claim that you wrote the original software. If you use this software
15  in a product, an acknowledgment in the product documentation would be
16  appreciated but is not required.
17  2. Altered source versions must be plainly marked as such, and must not be
18  misrepresented as being the original software.
19  3. This notice may not be removed or altered from any source distribution.
20 */
21 
22 /*
23 
24  Used by the test framework and test cases.
25 
26 */
27 
28 /* quiet windows compiler warnings */
29 #define _CRT_SECURE_NO_WARNINGS
30 
31 #include "SDL_config.h"
32 
33 #include <stdarg.h> /* va_list */
34 #include <stdio.h>
35 #include <string.h>
36 #include <time.h>
37 
38 #include "SDL.h"
39 
40 #include "SDL_test.h"
41 
42 /* !
43  * Converts unix timestamp to its ascii representation in localtime
44  *
45  * Note: Uses a static buffer internally, so the return value
46  * isn't valid after the next call of this function. If you
47  * want to retain the return value, make a copy of it.
48  *
49  * \param timestamp A Timestamp, i.e. time(0)
50  *
51  * \return Ascii representation of the timestamp in localtime in the format '08/23/01 14:55:02'
52  */
53 char *SDLTest_TimestampToString(const time_t timestamp)
54 {
55  time_t copy;
56  static char buffer[64];
57  struct tm *local;
58  const char *fmt = "%x %X";
59 
60  SDL_memset(buffer, 0, sizeof(buffer));
61  copy = timestamp;
62  local = localtime(&copy);
63  strftime(buffer, sizeof(buffer), fmt, local);
64 
65  return buffer;
66 }
67 
68 /*
69  * Prints given message with a timestamp in the TEST category and INFO priority.
70  */
71 void SDLTest_Log(const char *fmt, ...)
72 {
73  va_list list;
74  char logMessage[SDLTEST_MAX_LOGMESSAGE_LENGTH];
75 
76  /* Print log message into a buffer */
78  va_start(list, fmt);
79  SDL_vsnprintf(logMessage, SDLTEST_MAX_LOGMESSAGE_LENGTH - 1, fmt, list);
80  va_end(list);
81 
82  /* Log with timestamp and newline */
84 }
85 
86 /*
87  * Prints given message with a timestamp in the TEST category and the ERROR priority.
88  */
89 void SDLTest_LogError(const char *fmt, ...)
90 {
91  va_list list;
92  char logMessage[SDLTEST_MAX_LOGMESSAGE_LENGTH];
93 
94  /* Print log message into a buffer */
96  va_start(list, fmt);
97  SDL_vsnprintf(logMessage, SDLTEST_MAX_LOGMESSAGE_LENGTH - 1, fmt, list);
98  va_end(list);
99 
100  /* Log with timestamp and newline */
102 }
char * SDLTest_TimestampToString(const time_t timestamp)
Definition: SDL_test_log.c:53
#define local
Definition: zutil.h:30
#define SDLTEST_MAX_LOGMESSAGE_LENGTH
Definition: SDL_test.h:58
EGLContext EGLenum EGLClientBuffer buffer
Definition: eglext.h:87
DECLSPEC void *SDLCALL SDL_memset(void *dst, int c, size_t len)
Definition: SDL_string.c:261
void SDLTest_Log(const char *fmt,...)
Prints given message with a timestamp in the TEST category and INFO priority.
Definition: SDL_test_log.c:71
DECLSPEC void SDLCALL SDL_LogMessage(int category, SDL_LogPriority priority, const char *fmt,...)
Log a message with the specified category and priority.
Definition: SDL_log.c:243
DECLSPEC int SDLCALL SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap)
Definition: SDL_string.c:1479
void SDLTest_LogError(const char *fmt,...)
Prints given message with a timestamp in the TEST category and the ERROR priority.
Definition: SDL_test_log.c:89