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
6cc7e738
Commit
6cc7e738
authored
May 20, 2017
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
astyle
parent
40fc5bec
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
90 additions
and
87 deletions
+90
-87
async_log_helper.h
include/spdlog/details/async_log_helper.h
+8
-8
log_msg.h
include/spdlog/details/log_msg.h
+4
-4
logger_impl.h
include/spdlog/details/logger_impl.h
+4
-1
os.h
include/spdlog/details/os.h
+0
-0
spdlog_impl.h
include/spdlog/details/spdlog_impl.h
+2
-2
ansicolor_sink.h
include/spdlog/sinks/ansicolor_sink.h
+71
-71
tweakme.h
include/spdlog/tweakme.h
+1
-1
No files found.
include/spdlog/details/async_log_helper.h
View file @
6cc7e738
...
...
@@ -57,14 +57,14 @@ class async_log_helper
~
async_msg
()
=
default
;
async_msg
(
async_msg
&&
other
)
SPDLOG_NOEXCEPT
:
logger_name
(
std
::
move
(
other
.
logger_name
)),
level
(
std
::
move
(
other
.
level
)),
time
(
std
::
move
(
other
.
time
)),
thread_id
(
other
.
thread_id
),
txt
(
std
::
move
(
other
.
txt
)),
msg_type
(
std
::
move
(
other
.
msg_type
)),
msg_id
(
other
.
msg_id
)
async_msg
(
async_msg
&&
other
)
SPDLOG_NOEXCEPT
:
logger_name
(
std
::
move
(
other
.
logger_name
)),
level
(
std
::
move
(
other
.
level
)),
time
(
std
::
move
(
other
.
time
)),
thread_id
(
other
.
thread_id
),
txt
(
std
::
move
(
other
.
txt
)),
msg_type
(
std
::
move
(
other
.
msg_type
)),
msg_id
(
other
.
msg_id
)
{}
async_msg
(
async_msg_type
m_type
)
:
...
...
include/spdlog/details/log_msg.h
View file @
6cc7e738
...
...
@@ -19,10 +19,10 @@ namespace details
struct
log_msg
{
log_msg
()
=
default
;
log_msg
(
const
std
::
string
*
loggers_name
,
level
::
level_enum
lvl
)
:
logger_name
(
loggers_name
),
level
(
lvl
),
msg_id
(
0
)
log_msg
(
const
std
::
string
*
loggers_name
,
level
::
level_enum
lvl
)
:
logger_name
(
loggers_name
),
level
(
lvl
),
msg_id
(
0
)
{
#ifndef SPDLOG_NO_DATETIME
time
=
os
::
now
();
...
...
include/spdlog/details/logger_impl.h
View file @
6cc7e738
...
...
@@ -38,7 +38,10 @@ inline spdlog::logger::logger(const std::string& logger_name, sinks_init_list si
// ctor with single sink
inline
spdlog
::
logger
::
logger
(
const
std
::
string
&
logger_name
,
spdlog
::
sink_ptr
single_sink
)
:
logger
(
logger_name
,
{
single_sink
})
logger
(
logger_name
,
{
single_sink
})
{}
...
...
include/spdlog/details/os.h
View file @
6cc7e738
This diff is collapsed.
Click to expand it.
include/spdlog/details/spdlog_impl.h
View file @
6cc7e738
...
...
@@ -149,13 +149,13 @@ inline std::shared_ptr<spdlog::logger> spdlog::stdout_color_st(const std::string
inline
std
::
shared_ptr
<
spdlog
::
logger
>
spdlog
::
stderr_color_mt
(
const
std
::
string
&
logger_name
)
{
auto
sink
=
std
::
make_shared
<
spdlog
::
sinks
::
ansicolor_stderr_sink_mt
>
();
auto
sink
=
std
::
make_shared
<
spdlog
::
sinks
::
ansicolor_stderr_sink_mt
>
();
return
spdlog
::
details
::
registry
::
instance
().
create
(
logger_name
,
sink
);
}
inline
std
::
shared_ptr
<
spdlog
::
logger
>
spdlog
::
stderr_color_st
(
const
std
::
string
&
logger_name
)
{
auto
sink
=
std
::
make_shared
<
spdlog
::
sinks
::
ansicolor_stderr_sink_st
>
();
auto
sink
=
std
::
make_shared
<
spdlog
::
sinks
::
ansicolor_stderr_sink_st
>
();
return
spdlog
::
details
::
registry
::
instance
().
create
(
logger_name
,
sink
);
}
#endif
...
...
include/spdlog/sinks/ansicolor_sink.h
View file @
6cc7e738
...
...
@@ -14,85 +14,85 @@
namespace
spdlog
{
namespace
sinks
{
namespace
sinks
{
/**
* @brief The ansi_color_sink is a decorator around another sink and prefixes
* the output with an ANSI escape sequence color code depending on the severity
* of the message.
*/
template
<
class
Mutex
>
class
ansicolor_sink
SPDLOG_FINAL
:
public
base_sink
<
Mutex
>
{
public
:
ansicolor_sink
(
FILE
*
file
)
:
target_file_
(
file
)
{
should_do_colors_
=
details
::
os
::
in_terminal
(
file
)
&&
details
::
os
::
is_color_terminal
();
colors_
[
level
::
trace
]
=
"
\033
[36m"
;
// cyan;
colors_
[
level
::
debug
]
=
"
\033
[36m"
;
// cyan;
colors_
[
level
::
info
]
=
"
\033
[1m"
;
// bold;
colors_
[
level
::
warn
]
=
"
\033
[33m
\033
[1m"
;
// yellow_bold;
colors_
[
level
::
err
]
=
"
\033
[31m
\033
[1m"
;
// red_bold;
colors_
[
level
::
critical
]
=
"
\033
[1m
\033
[41m"
;
// bold_red_bg;
colors_
[
level
::
off
]
=
"
\033
[00m"
;
//reset;
}
virtual
~
ansicolor_sink
()
{
flush
();
}
/**
* @brief The ansi_color_sink is a decorator around another sink and prefixes
* the output with an ANSI escape sequence color code depending on the severity
* of the message.
*/
template
<
class
Mutex
>
class
ansicolor_sink
SPDLOG_FINAL
:
public
base_sink
<
Mutex
>
{
public
:
ansicolor_sink
(
FILE
*
file
)
:
target_file_
(
file
)
{
should_do_colors_
=
details
::
os
::
in_terminal
(
file
)
&&
details
::
os
::
is_color_terminal
();
colors_
[
level
::
trace
]
=
"
\033
[36m"
;
// cyan;
colors_
[
level
::
debug
]
=
"
\033
[36m"
;
// cyan;
colors_
[
level
::
info
]
=
"
\033
[1m"
;
// bold;
colors_
[
level
::
warn
]
=
"
\033
[33m
\033
[1m"
;
// yellow_bold;
colors_
[
level
::
err
]
=
"
\033
[31m
\033
[1m"
;
// red_bold;
colors_
[
level
::
critical
]
=
"
\033
[1m
\033
[41m"
;
// bold_red_bg;
colors_
[
level
::
off
]
=
"
\033
[00m"
;
//reset;
}
virtual
~
ansicolor_sink
()
{
flush
();
}
void
flush
()
override
{
fflush
(
target_file_
);
}
void
flush
()
override
{
fflush
(
target_file_
);
}
protected
:
virtual
void
_sink_it
(
const
details
::
log_msg
&
msg
)
override
{
// Wrap the originally formatted message in color codes.
// If color is not supported in the terminal, log as is instead.
if
(
should_do_colors_
)
{
const
std
::
string
&
prefix
=
colors_
[
msg
.
level
];
const
std
::
string
&
reset
=
colors_
[
level
::
off
];
fwrite
(
prefix
.
c_str
(),
sizeof
(
char
),
prefix
.
size
(),
target_file_
);
fwrite
(
msg
.
formatted
.
data
(),
sizeof
(
char
),
msg
.
formatted
.
size
(),
target_file_
);
fwrite
(
reset
.
c_str
(),
sizeof
(
char
),
reset
.
size
(),
target_file_
);
}
else
{
fwrite
(
msg
.
formatted
.
data
(),
sizeof
(
char
),
msg
.
formatted
.
size
(),
target_file_
);
}
}
FILE
*
target_file_
;
bool
should_do_colors_
;
std
::
map
<
level
::
level_enum
,
std
::
string
>
colors_
;
};
protected
:
virtual
void
_sink_it
(
const
details
::
log_msg
&
msg
)
override
{
// Wrap the originally formatted message in color codes.
// If color is not supported in the terminal, log as is instead.
if
(
should_do_colors_
)
{
const
std
::
string
&
prefix
=
colors_
[
msg
.
level
];
const
std
::
string
&
reset
=
colors_
[
level
::
off
];
fwrite
(
prefix
.
c_str
(),
sizeof
(
char
),
prefix
.
size
(),
target_file_
);
fwrite
(
msg
.
formatted
.
data
(),
sizeof
(
char
),
msg
.
formatted
.
size
(),
target_file_
);
fwrite
(
reset
.
c_str
(),
sizeof
(
char
),
reset
.
size
(),
target_file_
);
}
else
{
fwrite
(
msg
.
formatted
.
data
(),
sizeof
(
char
),
msg
.
formatted
.
size
(),
target_file_
);
}
}
FILE
*
target_file_
;
bool
should_do_colors_
;
std
::
map
<
level
::
level_enum
,
std
::
string
>
colors_
;
};
template
<
class
Mutex
>
class
ansicolor_stdout_sink
:
public
ansicolor_sink
<
Mutex
>
{
public
:
ansicolor_stdout_sink
()
:
ansicolor_sink
<
Mutex
>
(
stdout
)
{}
};
template
<
class
Mutex
>
class
ansicolor_stdout_sink
:
public
ansicolor_sink
<
Mutex
>
{
public
:
ansicolor_stdout_sink
()
:
ansicolor_sink
<
Mutex
>
(
stdout
)
{}
};
template
<
class
Mutex
>
class
ansicolor_stderr_sink
:
public
ansicolor_sink
<
Mutex
>
{
public
:
ansicolor_stderr_sink
()
:
ansicolor_sink
<
Mutex
>
(
stderr
)
{}
};
template
<
class
Mutex
>
class
ansicolor_stderr_sink
:
public
ansicolor_sink
<
Mutex
>
{
public
:
ansicolor_stderr_sink
()
:
ansicolor_sink
<
Mutex
>
(
stderr
)
{}
};
typedef
ansicolor_stdout_sink
<
std
::
mutex
>
ansicolor_stdout_sink_mt
;
typedef
ansicolor_stdout_sink
<
details
::
null_mutex
>
ansicolor_stdout_sink_st
;
typedef
ansicolor_stdout_sink
<
std
::
mutex
>
ansicolor_stdout_sink_mt
;
typedef
ansicolor_stdout_sink
<
details
::
null_mutex
>
ansicolor_stdout_sink_st
;
typedef
ansicolor_stderr_sink
<
std
::
mutex
>
ansicolor_stderr_sink_mt
;
typedef
ansicolor_stderr_sink
<
details
::
null_mutex
>
ansicolor_stderr_sink_st
;
typedef
ansicolor_stderr_sink
<
std
::
mutex
>
ansicolor_stderr_sink_mt
;
typedef
ansicolor_stderr_sink
<
details
::
null_mutex
>
ansicolor_stderr_sink_st
;
}
// namespace sinks
}
// namespace sinks
}
// namespace spdlog
include/spdlog/tweakme.h
View file @
6cc7e738
...
...
@@ -122,7 +122,7 @@
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
// Uncomment to enable message counting feature. Adds %i logger pattern that
// Uncomment to enable message counting feature. Adds %i logger pattern that
// prints log message sequence id.
//
// #define SPDLOG_ENABLE_MESSAGE_COUNTER
...
...
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