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
d5c9bac3
Commit
d5c9bac3
authored
May 12, 2019
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wip static-lib
parent
5220ac4a
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
124 additions
and
72 deletions
+124
-72
example.cpp
example/example.cpp
+0
-1
daily_file_sink.h
include/spdlog/sinks/daily_file_sink.h
+1
-0
stdout_sinks.h
include/spdlog/sinks/stdout_sinks.h
+1
-0
wincolor_sink-inl.h
include/spdlog/sinks/wincolor_sink-inl.h
+2
-1
wincolor_sink.h
include/spdlog/sinks/wincolor_sink.h
+0
-1
spdlog-inl.h
include/spdlog/spdlog-inl.h
+97
-0
spdlog.h
include/spdlog/spdlog.h
+21
-69
spdlog.cpp
src/spdlog.cpp
+2
-0
No files found.
example/example.cpp
View file @
d5c9bac3
...
...
@@ -2,7 +2,6 @@
// Copyright(c) 2015 Gabi Melman.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
// spdlog usage example
#include <cstdio>
...
...
include/spdlog/sinks/daily_file_sink.h
View file @
d5c9bac3
...
...
@@ -11,6 +11,7 @@
#include "spdlog/details/null_mutex.h"
#include "spdlog/fmt/fmt.h"
#include "spdlog/sinks/base_sink.h"
#include "spdlog/details/os.h"
#include <chrono>
#include <cstdio>
...
...
include/spdlog/sinks/stdout_sinks.h
View file @
d5c9bac3
...
...
@@ -9,6 +9,7 @@
#include "spdlog/details/console_globals.h"
#include "spdlog/details/null_mutex.h"
#include "spdlog/details/pattern_formatter.h"
#include <cstdio>
#include <memory>
...
...
include/spdlog/sinks/wincolor_sink-inl.h
View file @
d5c9bac3
...
...
@@ -100,5 +100,5 @@ void SPDLOG_INLINE wincolor_sink<TargetStream, ConsoleMutex>::print_range_(const
::
WriteConsoleA
(
out_handle_
,
formatted
.
data
()
+
start
,
size
,
nullptr
,
nullptr
);
}
}
}
// namespace sinks
}
// namespace spdlog
\ No newline at end of file
include/spdlog/sinks/wincolor_sink.h
View file @
d5c9bac3
...
...
@@ -48,7 +48,6 @@ public:
void
set_pattern
(
const
std
::
string
&
pattern
)
override
final
;
void
set_formatter
(
std
::
unique_ptr
<
spdlog
::
formatter
>
sink_formatter
)
override
final
;
private
:
using
mutex_t
=
typename
ConsoleMutex
::
mutex_t
;
HANDLE
out_handle_
;
...
...
include/spdlog/spdlog-inl.h
0 → 100644
View file @
d5c9bac3
// Copyright(c) 2015-present Gabi Melman & spdlog contributors.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
#pragma once
#include "spdlog/common.h"
#include "spdlog/details/pattern_formatter.h"
namespace
spdlog
{
SPDLOG_INLINE
void
initialize_logger
(
std
::
shared_ptr
<
logger
>
logger
)
{
details
::
registry
::
instance
().
initialize_logger
(
std
::
move
(
logger
));
}
SPDLOG_INLINE
std
::
shared_ptr
<
logger
>
get
(
const
std
::
string
&
name
)
{
return
details
::
registry
::
instance
().
get
(
name
);
}
SPDLOG_INLINE
void
set_formatter
(
std
::
unique_ptr
<
spdlog
::
formatter
>
formatter
)
{
details
::
registry
::
instance
().
set_formatter
(
std
::
move
(
formatter
));
}
SPDLOG_INLINE
void
set_pattern
(
std
::
string
pattern
,
pattern_time_type
time_type
)
{
set_formatter
(
std
::
unique_ptr
<
spdlog
::
formatter
>
(
new
pattern_formatter
(
std
::
move
(
pattern
),
time_type
)));
}
SPDLOG_INLINE
void
set_level
(
level
::
level_enum
log_level
)
{
details
::
registry
::
instance
().
set_level
(
log_level
);
}
SPDLOG_INLINE
void
flush_on
(
level
::
level_enum
log_level
)
{
details
::
registry
::
instance
().
flush_on
(
log_level
);
}
SPDLOG_INLINE
void
flush_every
(
std
::
chrono
::
seconds
interval
)
{
details
::
registry
::
instance
().
flush_every
(
interval
);
}
SPDLOG_INLINE
void
set_error_handler
(
void
(
*
handler
)(
const
std
::
string
&
msg
))
{
details
::
registry
::
instance
().
set_error_handler
(
handler
);
}
SPDLOG_INLINE
void
register_logger
(
std
::
shared_ptr
<
logger
>
logger
)
{
details
::
registry
::
instance
().
register_logger
(
std
::
move
(
logger
));
}
SPDLOG_INLINE
void
apply_all
(
const
std
::
function
<
void
(
std
::
shared_ptr
<
logger
>
)
>
&
fun
)
{
details
::
registry
::
instance
().
apply_all
(
fun
);
}
SPDLOG_INLINE
void
drop
(
const
std
::
string
&
name
)
{
details
::
registry
::
instance
().
drop
(
name
);
}
SPDLOG_INLINE
void
drop_all
()
{
details
::
registry
::
instance
().
drop_all
();
}
SPDLOG_INLINE
void
shutdown
()
{
details
::
registry
::
instance
().
shutdown
();
}
SPDLOG_INLINE
void
set_automatic_registration
(
bool
automatic_registation
)
{
details
::
registry
::
instance
().
set_automatic_registration
(
automatic_registation
);
}
SPDLOG_INLINE
std
::
shared_ptr
<
spdlog
::
logger
>
default_logger
()
{
return
details
::
registry
::
instance
().
default_logger
();
}
SPDLOG_INLINE
spdlog
::
logger
*
default_logger_raw
()
{
return
details
::
registry
::
instance
().
get_default_raw
();
}
SPDLOG_INLINE
void
set_default_logger
(
std
::
shared_ptr
<
spdlog
::
logger
>
default_logger
)
{
details
::
registry
::
instance
().
set_default_logger
(
std
::
move
(
default_logger
));
}
}
// namespace spdlog
\ No newline at end of file
include/spdlog/spdlog.h
View file @
d5c9bac3
...
...
@@ -11,7 +11,6 @@
#include "spdlog/common.h"
#include "spdlog/details/registry.h"
#include "spdlog/details/pattern_formatter.h"
#include "spdlog/logger.h"
#include "spdlog/version.h"
...
...
@@ -58,94 +57,52 @@ inline std::shared_ptr<spdlog::logger> create(std::string logger_name, SinkArgs
// auto console_sink = std::make_shared<spdlog::sinks::stdout_sink_mt>();
// auto console_logger = std::make_shared<spdlog::logger>("console_logger", console_sink);
// spdlog::initialize_logger(console_logger);
inline
void
initialize_logger
(
std
::
shared_ptr
<
logger
>
logger
)
{
details
::
registry
::
instance
().
initialize_logger
(
std
::
move
(
logger
));
}
void
initialize_logger
(
std
::
shared_ptr
<
logger
>
logger
);
// Return an existing logger or nullptr if a logger with such name doesn't
// exist.
// example: spdlog::get("my_logger")->info("hello {}", "world");
inline
std
::
shared_ptr
<
logger
>
get
(
const
std
::
string
&
name
)
{
return
details
::
registry
::
instance
().
get
(
name
);
}
std
::
shared_ptr
<
logger
>
get
(
const
std
::
string
&
name
);
// Set global formatter. Each sink in each logger will get a clone of this object
inline
void
set_formatter
(
std
::
unique_ptr
<
spdlog
::
formatter
>
formatter
)
{
details
::
registry
::
instance
().
set_formatter
(
std
::
move
(
formatter
));
}
void
set_formatter
(
std
::
unique_ptr
<
spdlog
::
formatter
>
formatter
);
// Set global format string.
// example: spdlog::set_pattern("%Y-%m-%d %H:%M:%S.%e %l : %v");
inline
void
set_pattern
(
std
::
string
pattern
,
pattern_time_type
time_type
=
pattern_time_type
::
local
)
{
set_formatter
(
std
::
unique_ptr
<
spdlog
::
formatter
>
(
new
pattern_formatter
(
std
::
move
(
pattern
),
time_type
)));
}
void
set_pattern
(
std
::
string
pattern
,
pattern_time_type
time_type
=
pattern_time_type
::
local
);
// Set global logging level
inline
void
set_level
(
level
::
level_enum
log_level
)
{
details
::
registry
::
instance
().
set_level
(
log_level
);
}
void
set_level
(
level
::
level_enum
log_level
);
// Set global flush level
inline
void
flush_on
(
level
::
level_enum
log_level
)
{
details
::
registry
::
instance
().
flush_on
(
log_level
);
}
void
flush_on
(
level
::
level_enum
log_level
);
// Start/Restart a periodic flusher thread
// Warning: Use only if all your loggers are thread safe!
inline
void
flush_every
(
std
::
chrono
::
seconds
interval
)
{
details
::
registry
::
instance
().
flush_every
(
interval
);
}
void
flush_every
(
std
::
chrono
::
seconds
interval
);
// Set global error handler
inline
void
set_error_handler
(
void
(
*
handler
)(
const
std
::
string
&
msg
))
{
details
::
registry
::
instance
().
set_error_handler
(
handler
);
}
void
set_error_handler
(
void
(
*
handler
)(
const
std
::
string
&
msg
));
// Register the given logger with the given name
inline
void
register_logger
(
std
::
shared_ptr
<
logger
>
logger
)
{
details
::
registry
::
instance
().
register_logger
(
std
::
move
(
logger
));
}
void
register_logger
(
std
::
shared_ptr
<
logger
>
logger
);
// Apply a user defined function on all registered loggers
// Example:
// spdlog::apply_all([&](std::shared_ptr<spdlog::logger> l) {l->flush();});
inline
void
apply_all
(
const
std
::
function
<
void
(
std
::
shared_ptr
<
logger
>
)
>
&
fun
)
{
details
::
registry
::
instance
().
apply_all
(
fun
);
}
void
apply_all
(
const
std
::
function
<
void
(
std
::
shared_ptr
<
logger
>
)
>
&
fun
);
// Drop the reference to the given logger
inline
void
drop
(
const
std
::
string
&
name
)
{
details
::
registry
::
instance
().
drop
(
name
);
}
void
drop
(
const
std
::
string
&
name
);
// Drop all references from the registry
inline
void
drop_all
()
{
details
::
registry
::
instance
().
drop_all
();
}
void
drop_all
();
// stop any running threads started by spdlog and clean registry loggers
inline
void
shutdown
()
{
details
::
registry
::
instance
().
shutdown
();
}
void
shutdown
();
// Automatic registration of loggers when using spdlog::create() or spdlog::create_async
inline
void
set_automatic_registration
(
bool
automatic_registation
)
{
details
::
registry
::
instance
().
set_automatic_registration
(
automatic_registation
);
}
void
set_automatic_registration
(
bool
automatic_registation
);
// API for using default logger (stdout_color_mt),
// e.g: spdlog::info("Message {}", 1);
...
...
@@ -162,20 +119,11 @@ inline void set_automatic_registration(bool automatic_registation)
// set_default_logger() *should not* be used concurrently with the default API.
// e.g do not call set_default_logger() from one thread while calling spdlog::info() from another.
inline
std
::
shared_ptr
<
spdlog
::
logger
>
default_logger
()
{
return
details
::
registry
::
instance
().
default_logger
();
}
std
::
shared_ptr
<
spdlog
::
logger
>
default_logger
();
inline
spdlog
::
logger
*
default_logger_raw
()
{
return
details
::
registry
::
instance
().
get_default_raw
();
}
spdlog
::
logger
*
default_logger_raw
();
inline
void
set_default_logger
(
std
::
shared_ptr
<
spdlog
::
logger
>
default_logger
)
{
details
::
registry
::
instance
().
set_default_logger
(
std
::
move
(
default_logger
));
}
void
set_default_logger
(
std
::
shared_ptr
<
spdlog
::
logger
>
default_logger
);
template
<
typename
...
Args
>
inline
void
log
(
source_loc
source
,
level
::
level_enum
lvl
,
const
char
*
fmt
,
const
Args
&
...
args
)
...
...
@@ -382,4 +330,8 @@ inline void critical(const wchar_t *fmt, const Args &... args)
#define SPDLOG_CRITICAL(...) (void)0
#endif
#ifdef SPDLOG_HEADER_ONLY
#include "spdlog-inl.h"
#endif
#endif // SPDLOG_H
src/spdlog.cpp
View file @
d5c9bac3
...
...
@@ -9,6 +9,8 @@
#include <chrono>
#include "spdlog/spdlog.h"
#include "spdlog/spdlog-inl.h"
#include "spdlog/async.h"
#include "spdlog/common.h"
...
...
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