UFO: Alien Invasion
Toggle main menu visibility
Loading...
Searching...
No Matches
sv_log.cpp
Go to the documentation of this file.
1
7
8
/*
9
All original material Copyright (C) 2002-2025 UFO: Alien Invasion.
10
11
This program is free software; you can redistribute it and/or
12
modify it under the terms of the GNU General Public License
13
as published by the Free Software Foundation; either version 2
14
of the License, or (at your option) any later version.
15
16
This program is distributed in the hope that it will be useful,
17
but WITHOUT ANY WARRANTY; without even the implied warranty of
18
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19
20
See the GNU General Public License for more details.
21
22
You should have received a copy of the GNU General Public License
23
along with this program; if not, write to the Free Software
24
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25
*/
26
27
#include "
server.h
"
28
#include "
sv_log.h
"
29
#include "
../shared/stringhunk.h
"
30
#include <SDL_thread.h>
31
32
static
SDL_mutex*
svLogMutex
;
33
static
stringHunk_t
*
svLogHunk
;
34
35
static
void
SV_LogPrintOutput
(
const
char
*
string
)
36
{
37
Com_Printf
(
"%s"
,
string
);
38
}
39
44
void
SV_LogHandleOutput
(
void
)
45
{
46
SDL_LockMutex(
svLogMutex
);
47
STRHUNK_Visit
(
svLogHunk
,
SV_LogPrintOutput
);
48
STRHUNK_Reset
(
svLogHunk
);
49
SDL_UnlockMutex(
svLogMutex
);
50
}
51
60
void
SV_LogAdd
(
const
char
*
format
, va_list ap)
61
{
62
char
msg[1024];
63
64
Q_vsnprintf
(msg,
sizeof
(msg),
format
, ap);
65
66
SDL_LockMutex(
svLogMutex
);
67
STRHUNK_Add
(
svLogHunk
, msg);
68
SDL_UnlockMutex(
svLogMutex
);
69
}
70
71
void
SV_LogInit
(
void
)
72
{
73
const
size_t
svHunkSize = 32768;
74
svLogMutex
= SDL_CreateMutex();
75
svLogHunk
=
STRHUNK_Create
(svHunkSize);
76
}
77
78
void
SV_LogShutdown
(
void
)
79
{
80
SDL_DestroyMutex(
svLogMutex
);
81
svLogMutex
=
nullptr
;
82
STRHUNK_Delete
(&
svLogHunk
);
83
}
Com_Printf
void Com_Printf(const char *const fmt,...)
Definition
common.cpp:428
format
void format(__printf__, 1, 2)))
server.h
Main server include file.
Q_vsnprintf
int Q_vsnprintf(char *str, size_t size, const char *format, va_list ap)
Safe (null terminating) vsnprintf implementation.
Definition
shared.cpp:535
STRHUNK_Add
bool STRHUNK_Add(stringHunk_t *hunk, const char *string)
Definition
stringhunk.cpp:32
STRHUNK_Create
stringHunk_t * STRHUNK_Create(size_t size)
Definition
stringhunk.cpp:88
STRHUNK_Delete
void STRHUNK_Delete(stringHunk_t **hunk)
Definition
stringhunk.cpp:97
STRHUNK_Visit
void STRHUNK_Visit(stringHunk_t *hunk, stringHunkVisitor_t visitor)
Definition
stringhunk.cpp:62
STRHUNK_Reset
void STRHUNK_Reset(stringHunk_t *hunk)
Definition
stringhunk.cpp:55
stringhunk.h
Header for string hunk management.
stringHunk_t
Definition
stringhunk.h:29
SV_LogInit
void SV_LogInit(void)
Definition
sv_log.cpp:71
SV_LogPrintOutput
static void SV_LogPrintOutput(const char *string)
Definition
sv_log.cpp:35
svLogMutex
static SDL_mutex * svLogMutex
Definition
sv_log.cpp:32
SV_LogAdd
void SV_LogAdd(const char *format, va_list ap)
Async version to add a log entry for the game lib.
Definition
sv_log.cpp:60
SV_LogShutdown
void SV_LogShutdown(void)
Definition
sv_log.cpp:78
SV_LogHandleOutput
void SV_LogHandleOutput(void)
Handle the log output from the main thread by reading the strings from the dbuffer the game lib threa...
Definition
sv_log.cpp:44
svLogHunk
static stringHunk_t * svLogHunk
Definition
sv_log.cpp:33
sv_log.h
game lib logging handling
src
server
sv_log.cpp
Generated on __DATE__ __TIME__ for UFO: Alien Invasion by
1.17.0