Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Libretro
Citra2018
Commits
b70dfc36
Commit
b70dfc36
authored
Jul 01, 2018
by
James
Browse files
Migrate logger to use a callable initialisation/destruction routine
Fixes #39
parent
a95f45b1
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/citra/citra.cpp
View file @
b70dfc36
...
...
@@ -129,6 +129,8 @@ static void InitializeLogging() {
/// Application entry point
int
main
(
int
argc
,
char
**
argv
)
{
Log
::
Init
();
Config
config
;
int
option_index
=
0
;
bool
use_gdbstub
=
Settings
::
values
.
use_gdbstub
;
...
...
src/citra_libretro/citra_libretro.cpp
View file @
b70dfc36
...
...
@@ -40,6 +40,7 @@ CitraLibRetro* emu_instance;
void
retro_init
()
{
emu_instance
=
new
CitraLibRetro
();
Log
::
Init
();
Log
::
SetGlobalFilter
(
emu_instance
->
log_filter
);
// Check to see if the frontend is providing us with logging functionality
...
...
@@ -64,6 +65,8 @@ void retro_deinit() {
LibRetro
::
Input
::
Shutdown
();
delete
emu_instance
;
Log
::
Destroy
();
}
unsigned
retro_api_version
()
{
...
...
src/citra_qt/main.cpp
View file @
b70dfc36
...
...
@@ -1680,6 +1680,15 @@ int main(int argc, char* argv[]) {
setlocale
(
LC_ALL
,
"C"
);
GMainWindow
main_window
;
Log
::
Init
();
// After settings have been loaded by GMainWindow, apply the filter
Log
::
Filter
log_filter
;
log_filter
.
ParseFilterString
(
Settings
::
values
.
log_filter
);
Log
::
SetGlobalFilter
(
log_filter
);
FileUtil
::
CreateFullPath
(
FileUtil
::
GetUserPath
(
D_LOGS_IDX
));
Log
::
AddBackend
(
std
::
make_unique
<
Log
::
FileBackend
>
(
FileUtil
::
GetUserPath
(
D_LOGS_IDX
)
+
LOG_FILE
));
// Register CameraFactory
Camera
::
RegisterFactory
(
"image"
,
std
::
make_unique
<
Camera
::
StillImageCameraFactory
>
());
...
...
src/common/logging/backend.cpp
View file @
b70dfc36
...
...
@@ -29,10 +29,6 @@ namespace Log {
*/
class
Impl
{
public:
static
Impl
&
Instance
()
{
static
Impl
backend
;
return
backend
;
}
Impl
(
Impl
const
&
)
=
delete
;
const
Impl
&
operator
=
(
Impl
const
&
)
=
delete
;
...
...
@@ -116,6 +112,16 @@ private:
Filter
filter
;
};
std
::
unique_ptr
<
Impl
>
g_logger
;
void
Init
()
{
g_logger
=
std
::
make_unique
<
Impl
>
();
}
void
Destroy
()
{
g_logger
=
nullptr
;
}
void
ConsoleBackend
::
Write
(
const
Entry
&
entry
)
{
PrintMessage
(
entry
);
}
...
...
@@ -263,32 +269,31 @@ Entry CreateEntry(Class log_class, Level log_level, const char* filename, unsign
}
void
SetGlobalFilter
(
const
Filter
&
filter
)
{
Impl
::
Instance
().
SetGlobalFilter
(
filter
);
g_logger
->
SetGlobalFilter
(
filter
);
}
void
AddBackend
(
std
::
unique_ptr
<
Backend
>
backend
)
{
Impl
::
Instance
().
AddBackend
(
std
::
move
(
backend
));
g_logger
->
AddBackend
(
std
::
move
(
backend
));
}
void
RemoveBackend
(
std
::
string_view
backend_name
)
{
Impl
::
Instance
().
RemoveBackend
(
backend_name
);
g_logger
->
RemoveBackend
(
backend_name
);
}
Backend
*
GetBackend
(
std
::
string_view
backend_name
)
{
return
Impl
::
Instance
().
GetBackend
(
backend_name
);
return
g_logger
->
GetBackend
(
backend_name
);
}
void
FmtLogMessageImpl
(
Class
log_class
,
Level
log_level
,
const
char
*
filename
,
unsigned
int
line_num
,
const
char
*
function
,
const
char
*
format
,
const
fmt
::
format_args
&
args
)
{
auto
&
instance
=
Impl
::
Instance
();
const
auto
&
filter
=
instance
.
GetGlobalFilter
();
auto
filter
=
g_logger
->
GetGlobalFilter
();
if
(
!
filter
.
CheckMessage
(
log_class
,
log_level
))
return
;
Entry
entry
=
CreateEntry
(
log_class
,
log_level
,
filename
,
line_num
,
function
,
fmt
::
vformat
(
format
,
args
));
instance
.
PushEntry
(
std
::
move
(
entry
));
g_logger
->
PushEntry
(
std
::
move
(
entry
));
}
}
// namespace Log
src/common/logging/backend.h
View file @
b70dfc36
...
...
@@ -104,6 +104,10 @@ private:
std
::
size_t
bytes_written
;
};
void
Init
();
void
Destroy
();
void
AddBackend
(
std
::
unique_ptr
<
Backend
>
backend
);
void
RemoveBackend
(
std
::
string_view
backend_name
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment