Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
S
spdlog
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
spdlog
Commits
faea32c9
Commit
faea32c9
authored
Jun 01, 2018
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simplfiy a little the use of fmt:safe_strerror
parent
d78ddcee
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
8 deletions
+18
-8
common.h
include/spdlog/common.h
+18
-8
No files found.
include/spdlog/common.h
View file @
faea32c9
...
@@ -153,15 +153,18 @@ public:
...
@@ -153,15 +153,18 @@ public:
spdlog_ex
(
const
std
::
string
&
msg
,
int
last_errno
)
spdlog_ex
(
const
std
::
string
&
msg
,
int
last_errno
)
{
{
std
::
string
errno_string
;
char
buf
[
256
],
*
buf_ptr
=
buf
;
char
buf
[
256
],
*
buf_ptr
=
buf
;
SPDLOG_CONSTEXPR
auto
buf_size
=
sizeof
(
buf
);
if
(
fmt
::
safe_strerror
(
last_errno
,
buf_ptr
,
buf_size
)
!=
0
)
if
(
fmt
::
safe_strerror
(
last_errno
,
buf_ptr
,
sizeof
(
buf
))
==
0
)
{
errno_string
=
buf_ptr
;
}
else
{
{
buf_ptr
=
buf
;
errno_string
=
"Unknown error"
;
char
unknown
[]
=
"Unknown error"
;
std
::
copy
(
unknown
,
unknown
+
sizeof
(
unknown
),
buf_ptr
);
}
}
_msg
=
msg
+
": "
+
std
::
string
(
buf_ptr
)
;
_msg
=
msg
+
": "
+
errno_string
;
}
}
const
char
*
what
()
const
SPDLOG_NOEXCEPT
override
const
char
*
what
()
const
SPDLOG_NOEXCEPT
override
...
@@ -182,6 +185,13 @@ using filename_t = std::wstring;
...
@@ -182,6 +185,13 @@ using filename_t = std::wstring;
using
filename_t
=
std
::
string
;
using
filename_t
=
std
::
string
;
#endif
#endif
#define SPDLOG_CATCH_AND_HANDLE catch (const std::exception &ex) {_err_handler(ex.what());}\
#define SPDLOG_CATCH_AND_HANDLE \
catch (...) {_err_handler("Unknown exeption in logger");}
catch (const std::exception &ex) \
{ \
_err_handler(ex.what()); \
} \
catch (...) \
{ \
_err_handler("Unknown exeption in logger"); \
}
}
// namespace spdlog
}
// namespace spdlog
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