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
d78ddcee
Unverified
Commit
d78ddcee
authored
Jun 01, 2018
by
Gabi Melman
Committed by
GitHub
Jun 01, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #719 from JamesReynolds/master
Closes #717
parents
d033ccc0
7bc598c9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
54 deletions
+9
-54
common.h
include/spdlog/common.h
+9
-6
os.h
include/spdlog/details/os.h
+0
-48
No files found.
include/spdlog/common.h
View file @
d78ddcee
...
...
@@ -143,11 +143,6 @@ enum class pattern_time_type
//
// Log exception
//
namespace
details
{
namespace
os
{
std
::
string
errno_str
(
int
err_num
);
}
}
// namespace details
class
spdlog_ex
:
public
std
::
exception
{
public
:
...
...
@@ -158,7 +153,15 @@ public:
spdlog_ex
(
const
std
::
string
&
msg
,
int
last_errno
)
{
_msg
=
msg
+
": "
+
details
::
os
::
errno_str
(
last_errno
);
char
buf
[
256
],
*
buf_ptr
=
buf
;
SPDLOG_CONSTEXPR
auto
buf_size
=
sizeof
(
buf
);
if
(
fmt
::
safe_strerror
(
last_errno
,
buf_ptr
,
buf_size
)
!=
0
)
{
buf_ptr
=
buf
;
char
unknown
[]
=
"Unknown error"
;
std
::
copy
(
unknown
,
unknown
+
sizeof
(
unknown
),
buf_ptr
);
}
_msg
=
msg
+
": "
+
std
::
string
(
buf_ptr
);
}
const
char
*
what
()
const
SPDLOG_NOEXCEPT
override
...
...
include/spdlog/details/os.h
View file @
d78ddcee
...
...
@@ -383,54 +383,6 @@ inline std::string filename_to_str(const filename_t &filename)
}
#endif
inline
std
::
string
errno_to_string
(
char
[
256
],
char
*
res
)
{
return
std
::
string
(
res
);
}
inline
std
::
string
errno_to_string
(
char
buf
[
256
],
int
res
)
{
if
(
res
==
0
)
{
return
std
::
string
(
buf
);
}
return
"Unknown error"
;
}
// Return errno string (thread safe)
inline
std
::
string
errno_str
(
int
err_num
)
{
char
buf
[
256
];
SPDLOG_CONSTEXPR
auto
buf_size
=
sizeof
(
buf
);
#ifdef _WIN32
if
(
strerror_s
(
buf
,
buf_size
,
err_num
)
==
0
)
{
return
std
::
string
(
buf
);
}
else
{
return
"Unknown error"
;
}
#elif defined(__FreeBSD__) || defined(__APPLE__) || defined(ANDROID) || defined(__SUNPRO_CC) || \
((_POSIX_C_SOURCE >= 200112L) && !defined(_GNU_SOURCE)) // posix version
if
(
strerror_r
(
err_num
,
buf
,
buf_size
)
==
0
)
{
return
std
::
string
(
buf
);
}
else
{
return
"Unknown error"
;
}
#else // gnu version (might not use the given buf, so its retval pointer must be used)
auto
err
=
strerror_r
(
err_num
,
buf
,
buf_size
);
// let compiler choose type
return
errno_to_string
(
buf
,
err
);
// use overloading to select correct stringify function
#endif
}
inline
int
pid
()
{
...
...
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