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
4ca69918
Commit
4ca69918
authored
Dec 22, 2017
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
astyle
parent
813dcbcf
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
60 additions
and
60 deletions
+60
-60
async_log_helper.h
include/spdlog/details/async_log_helper.h
+1
-1
file_helper.h
include/spdlog/details/file_helper.h
+20
-20
logger_impl.h
include/spdlog/details/logger_impl.h
+10
-10
file_helper.cpp
tests/file_helper.cpp
+29
-29
No files found.
include/spdlog/details/async_log_helper.h
View file @
4ca69918
...
...
@@ -282,7 +282,7 @@ inline void spdlog::details::async_log_helper::worker_loop()
}
catch
(...)
{
_err_handler
(
"Unknown exeption in async logger worker loop."
);
_err_handler
(
"Unknown exeption in async logger worker loop."
);
}
}
if
(
_worker_teardown_cb
)
_worker_teardown_cb
();
...
...
include/spdlog/details/file_helper.h
View file @
4ca69918
...
...
@@ -113,31 +113,31 @@ public:
//
// "mylog.txt" => ("mylog", ".txt")
// "mylog" => ("mylog", "")
// "mylog." => ("mylog.", "")
// "/dir1/dir2/mylog.txt" => ("/dir1/dir2/mylog", ".txt")
// "mylog." => ("mylog.", "")
// "/dir1/dir2/mylog.txt" => ("/dir1/dir2/mylog", ".txt")
//
// the starting dot in filenames is ignored (hidden files):
//
// ".mylog" => (".mylog". "")
// ".mylog" => (".mylog". "")
// "my_folder/.mylog" => ("my_folder/.mylog", "")
// "my_folder/.mylog.txt" => ("my_folder/.mylog", ".txt")
static
std
::
tuple
<
filename_t
,
filename_t
>
split_by_extenstion
(
const
spdlog
::
filename_t
&
fname
)
{
auto
ext_index
=
fname
.
rfind
(
'.'
);
// no valid extension found - return whole path and empty string as extension
if
(
ext_index
==
filename_t
::
npos
||
ext_index
==
0
||
ext_index
==
fname
.
size
()
-
1
)
return
std
::
make_tuple
(
fname
,
spdlog
::
filename_t
());
// treat casese like "/etc/rc.d/somelogfile or "/abc/.hiddenfile"
//auto folder_index = fname.find('\\', ext_index);
auto
folder_index
=
fname
.
rfind
(
details
::
os
::
folder_sep
);
if
(
folder_index
!=
fname
.
npos
&&
folder_index
>=
ext_index
-
1
)
return
std
::
make_tuple
(
fname
,
spdlog
::
filename_t
());
// finally - return a valid base and extnetion tuple
return
std
::
make_tuple
(
fname
.
substr
(
0
,
ext_index
),
fname
.
substr
(
ext_index
));
}
static
std
::
tuple
<
filename_t
,
filename_t
>
split_by_extenstion
(
const
spdlog
::
filename_t
&
fname
)
{
auto
ext_index
=
fname
.
rfind
(
'.'
);
// no valid extension found - return whole path and empty string as extension
if
(
ext_index
==
filename_t
::
npos
||
ext_index
==
0
||
ext_index
==
fname
.
size
()
-
1
)
return
std
::
make_tuple
(
fname
,
spdlog
::
filename_t
());
// treat casese like "/etc/rc.d/somelogfile or "/abc/.hiddenfile"
//auto folder_index = fname.find('\\', ext_index);
auto
folder_index
=
fname
.
rfind
(
details
::
os
::
folder_sep
);
if
(
folder_index
!=
fname
.
npos
&&
folder_index
>=
ext_index
-
1
)
return
std
::
make_tuple
(
fname
,
spdlog
::
filename_t
());
// finally - return a valid base and extnetion tuple
return
std
::
make_tuple
(
fname
.
substr
(
0
,
ext_index
),
fname
.
substr
(
ext_index
));
}
private
:
FILE
*
_fd
;
filename_t
_filename
;
...
...
include/spdlog/details/logger_impl.h
View file @
4ca69918
...
...
@@ -98,11 +98,11 @@ inline void spdlog::logger::log(level::level_enum lvl, const char* msg)
{
_err_handler
(
ex
.
what
());
}
catch
(...)
{
_err_handler
(
"Unknown exception in logger "
+
_name
);
throw
;
}
catch
(...)
{
_err_handler
(
"Unknown exception in logger "
+
_name
);
throw
;
}
}
template
<
typename
T
>
...
...
@@ -119,11 +119,11 @@ inline void spdlog::logger::log(level::level_enum lvl, const T& msg)
{
_err_handler
(
ex
.
what
());
}
catch
(...)
{
_err_handler
(
"Unknown exception in logger "
+
_name
);
throw
;
}
catch
(...)
{
_err_handler
(
"Unknown exception in logger "
+
_name
);
throw
;
}
}
...
...
tests/file_helper.cpp
View file @
4ca69918
...
...
@@ -76,42 +76,42 @@ TEST_CASE("file_helper_reopen2", "[file_helper::reopen(false)]]")
static
void
test_split_ext
(
const
char
*
fname
,
const
char
*
expect_base
,
const
char
*
expect_ext
)
{
spdlog
::
filename_t
filename
(
fname
);
spdlog
::
filename_t
expected_base
(
expect_base
);
spdlog
::
filename_t
expected_ext
(
expect_ext
);
{
spdlog
::
filename_t
filename
(
fname
);
spdlog
::
filename_t
expected_base
(
expect_base
);
spdlog
::
filename_t
expected_ext
(
expect_ext
);
#ifdef _WIN32 // replace folder sep
std
::
replace
(
filename
.
begin
(),
filename
.
end
(),
'/'
,
'\\'
);
std
::
replace
(
expected_base
.
begin
(),
expected_base
.
end
(),
'/'
,
'\\'
);
std
::
replace
(
filename
.
begin
(),
filename
.
end
(),
'/'
,
'\\'
);
std
::
replace
(
expected_base
.
begin
(),
expected_base
.
end
(),
'/'
,
'\\'
);
#endif
spdlog
::
filename_t
basename
,
ext
;
std
::
tie
(
basename
,
ext
)
=
file_helper
::
split_by_extenstion
(
filename
);
REQUIRE
(
basename
==
expected_base
);
REQUIRE
(
ext
==
expected_ext
);
spdlog
::
filename_t
basename
,
ext
;
std
::
tie
(
basename
,
ext
)
=
file_helper
::
split_by_extenstion
(
filename
);
REQUIRE
(
basename
==
expected_base
);
REQUIRE
(
ext
==
expected_ext
);
}
TEST_CASE
(
"file_helper_split_by_extenstion"
,
"[file_helper::split_by_extenstion()]]"
)
{
test_split_ext
(
"mylog.txt"
,
"mylog"
,
".txt"
);
test_split_ext
(
".mylog.txt"
,
".mylog"
,
".txt"
);
test_split_ext
(
".mylog"
,
".mylog"
,
""
);
test_split_ext
(
"/aaa/bb.d/mylog"
,
"/aaa/bb.d/mylog"
,
""
);
test_split_ext
(
"/aaa/bb.d/mylog.txt"
,
"/aaa/bb.d/mylog"
,
".txt"
);
test_split_ext
(
"aaa/bbb/ccc/mylog.txt"
,
"aaa/bbb/ccc/mylog"
,
".txt"
);
test_split_ext
(
"aaa/bbb/ccc/mylog."
,
"aaa/bbb/ccc/mylog."
,
""
);
test_split_ext
(
"aaa/bbb/ccc/.mylog.txt"
,
"aaa/bbb/ccc/.mylog"
,
".txt"
);
test_split_ext
(
"/aaa/bbb/ccc/mylog.txt"
,
"/aaa/bbb/ccc/mylog"
,
".txt"
);
test_split_ext
(
"/aaa/bbb/ccc/.mylog"
,
"/aaa/bbb/ccc/.mylog"
,
""
);
test_split_ext
(
"../mylog.txt"
,
"../mylog"
,
".txt"
);
test_split_ext
(
".././mylog.txt"
,
".././mylog"
,
".txt"
);
test_split_ext
(
".././mylog.txt/xxx"
,
".././mylog.txt/xxx"
,
""
);
test_split_ext
(
"/mylog.txt"
,
"/mylog"
,
".txt"
);
test_split_ext
(
"//mylog.txt"
,
"//mylog"
,
".txt"
);
test_split_ext
(
""
,
""
,
""
);
test_split_ext
(
"."
,
"."
,
""
);
test_split_ext
(
"..txt"
,
"."
,
".txt"
);
{
test_split_ext
(
"mylog.txt"
,
"mylog"
,
".txt"
);
test_split_ext
(
".mylog.txt"
,
".mylog"
,
".txt"
);
test_split_ext
(
".mylog"
,
".mylog"
,
""
);
test_split_ext
(
"/aaa/bb.d/mylog"
,
"/aaa/bb.d/mylog"
,
""
);
test_split_ext
(
"/aaa/bb.d/mylog.txt"
,
"/aaa/bb.d/mylog"
,
".txt"
);
test_split_ext
(
"aaa/bbb/ccc/mylog.txt"
,
"aaa/bbb/ccc/mylog"
,
".txt"
);
test_split_ext
(
"aaa/bbb/ccc/mylog."
,
"aaa/bbb/ccc/mylog."
,
""
);
test_split_ext
(
"aaa/bbb/ccc/.mylog.txt"
,
"aaa/bbb/ccc/.mylog"
,
".txt"
);
test_split_ext
(
"/aaa/bbb/ccc/mylog.txt"
,
"/aaa/bbb/ccc/mylog"
,
".txt"
);
test_split_ext
(
"/aaa/bbb/ccc/.mylog"
,
"/aaa/bbb/ccc/.mylog"
,
""
);
test_split_ext
(
"../mylog.txt"
,
"../mylog"
,
".txt"
);
test_split_ext
(
".././mylog.txt"
,
".././mylog"
,
".txt"
);
test_split_ext
(
".././mylog.txt/xxx"
,
".././mylog.txt/xxx"
,
""
);
test_split_ext
(
"/mylog.txt"
,
"/mylog"
,
".txt"
);
test_split_ext
(
"//mylog.txt"
,
"//mylog"
,
".txt"
);
test_split_ext
(
""
,
""
,
""
);
test_split_ext
(
"."
,
"."
,
""
);
test_split_ext
(
"..txt"
,
"."
,
".txt"
);
}
...
...
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