Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
f9879477
Commit
f9879477
authored
May 23, 2019
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Log: add Log() and LogFormat() overloads with std::exception_ptr
Make LogError()/FormatError() wrappers for those. Now we can log exceptions with a lower level.
parent
e0d5d881
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
68 additions
and
27 deletions
+68
-27
Log.cxx
src/Log.cxx
+13
-13
Log.hxx
src/Log.hxx
+55
-14
No files found.
src/Log.cxx
View file @
f9879477
...
...
@@ -91,19 +91,19 @@ FormatError(const Domain &domain, const char *fmt, ...) noexcept
}
void
Log
Error
(
const
std
::
exception
&
e
)
noexcept
Log
(
LogLevel
level
,
const
std
::
exception
&
e
)
noexcept
{
Log
Error
(
exception_domain
,
GetFullMessage
(
e
).
c_str
());
Log
(
level
,
exception_domain
,
GetFullMessage
(
e
).
c_str
());
}
void
Log
Error
(
const
std
::
exception
&
e
,
const
char
*
msg
)
noexcept
Log
(
LogLevel
level
,
const
std
::
exception
&
e
,
const
char
*
msg
)
noexcept
{
FormatError
(
exception_domain
,
"%s: %s"
,
msg
,
GetFullMessage
(
e
).
c_str
());
LogFormat
(
level
,
exception_domain
,
"%s: %s"
,
msg
,
GetFullMessage
(
e
).
c_str
());
}
void
FormatError
(
const
std
::
exception
&
e
,
const
char
*
fmt
,
...)
noexcept
LogFormat
(
LogLevel
level
,
const
std
::
exception
&
e
,
const
char
*
fmt
,
...)
noexcept
{
char
msg
[
1024
];
va_list
ap
;
...
...
@@ -111,24 +111,24 @@ FormatError(const std::exception &e, const char *fmt, ...) noexcept
vsnprintf
(
msg
,
sizeof
(
msg
),
fmt
,
ap
);
va_end
(
ap
);
Log
Error
(
e
,
msg
);
Log
(
level
,
e
,
msg
);
}
void
Log
Error
(
const
std
::
exception_ptr
&
ep
)
noexcept
Log
(
LogLevel
level
,
const
std
::
exception_ptr
&
ep
)
noexcept
{
Log
Error
(
exception_domain
,
GetFullMessage
(
ep
).
c_str
());
Log
(
level
,
exception_domain
,
GetFullMessage
(
ep
).
c_str
());
}
void
Log
Error
(
const
std
::
exception_ptr
&
ep
,
const
char
*
msg
)
noexcept
Log
(
LogLevel
level
,
const
std
::
exception_ptr
&
ep
,
const
char
*
msg
)
noexcept
{
FormatError
(
exception_domain
,
"%s: %s"
,
msg
,
GetFullMessage
(
ep
).
c_str
());
LogFormat
(
level
,
exception_domain
,
"%s: %s"
,
msg
,
GetFullMessage
(
ep
).
c_str
());
}
void
FormatError
(
const
std
::
exception_ptr
&
ep
,
const
char
*
fmt
,
...)
noexcept
LogFormat
(
LogLevel
level
,
const
std
::
exception_ptr
&
ep
,
const
char
*
fmt
,
...)
noexcept
{
char
msg
[
1024
];
va_list
ap
;
...
...
@@ -136,7 +136,7 @@ FormatError(const std::exception_ptr &ep, const char *fmt, ...) noexcept
vsnprintf
(
msg
,
sizeof
(
msg
),
fmt
,
ap
);
va_end
(
ap
);
Log
Error
(
ep
,
msg
);
Log
(
level
,
ep
,
msg
);
}
void
...
...
src/Log.hxx
View file @
f9879477
...
...
@@ -34,6 +34,28 @@ gcc_printf(3,4)
void
LogFormat
(
LogLevel
level
,
const
Domain
&
domain
,
const
char
*
fmt
,
...)
noexcept
;
void
Log
(
LogLevel
level
,
const
std
::
exception
&
e
)
noexcept
;
void
Log
(
LogLevel
level
,
const
std
::
exception
&
e
,
const
char
*
msg
)
noexcept
;
gcc_printf
(
3
,
4
)
void
LogFormat
(
LogLevel
level
,
const
std
::
exception
&
e
,
const
char
*
fmt
,
...)
noexcept
;
void
Log
(
LogLevel
level
,
const
std
::
exception_ptr
&
ep
)
noexcept
;
void
Log
(
LogLevel
level
,
const
std
::
exception_ptr
&
ep
,
const
char
*
msg
)
noexcept
;
gcc_printf
(
3
,
4
)
void
LogFormat
(
LogLevel
level
,
const
std
::
exception_ptr
&
ep
,
const
char
*
fmt
,
...)
noexcept
;
static
inline
void
LogDebug
(
const
Domain
&
domain
,
const
char
*
msg
)
noexcept
{
...
...
@@ -80,25 +102,44 @@ LogError(const Domain &domain, const char *msg) noexcept
Log
(
LogLevel
::
ERROR
,
domain
,
msg
);
}
void
LogError
(
const
std
::
exception
&
e
)
noexcept
;
inline
void
LogError
(
const
std
::
exception
&
e
)
noexcept
{
Log
(
LogLevel
::
ERROR
,
e
);
}
void
LogError
(
const
std
::
exception
&
e
,
const
char
*
msg
)
noexcept
;
inline
void
LogError
(
const
std
::
exception
&
e
,
const
char
*
msg
)
noexcept
{
Log
(
LogLevel
::
ERROR
,
e
,
msg
);
}
gcc_printf
(
2
,
3
)
void
FormatError
(
const
std
::
exception
&
e
,
const
char
*
fmt
,
...)
noexcept
;
template
<
typename
...
Args
>
inline
void
FormatError
(
const
std
::
exception
&
e
,
const
char
*
fmt
,
Args
&&
...
args
)
noexcept
{
LogFormat
(
LogLevel
::
ERROR
,
e
,
fmt
,
std
::
forward
<
Args
>
(
args
)...);
}
void
LogError
(
const
std
::
exception_ptr
&
ep
)
noexcept
;
inline
void
LogError
(
const
std
::
exception_ptr
&
ep
)
noexcept
{
Log
(
LogLevel
::
ERROR
,
ep
);
}
void
LogError
(
const
std
::
exception_ptr
&
ep
,
const
char
*
msg
)
noexcept
;
inline
void
LogError
(
const
std
::
exception_ptr
&
ep
,
const
char
*
msg
)
noexcept
{
Log
(
LogLevel
::
ERROR
,
ep
,
msg
);
}
gcc_printf
(
2
,
3
)
void
FormatError
(
const
std
::
exception_ptr
&
ep
,
const
char
*
fmt
,
...)
noexcept
;
template
<
typename
...
Args
>
inline
void
FormatError
(
const
std
::
exception_ptr
&
ep
,
const
char
*
fmt
,
Args
&&
...
args
)
noexcept
{
LogFormat
(
LogLevel
::
ERROR
,
ep
,
fmt
,
std
::
forward
<
Args
>
(
args
)...);
}
gcc_printf
(
2
,
3
)
void
...
...
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