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
c2b0e223
Commit
c2b0e223
authored
Mar 30, 2019
by
gabime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wip lite
parent
e32c856a
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
203 additions
and
136 deletions
+203
-136
create_logger.cpp
lite-example/create_logger.cpp
+5
-3
example.cpp
lite-example/example.cpp
+9
-8
CMakeLists.txt
lite/CMakeLists.txt
+1
-1
spdlite.cpp
lite/spdlite.cpp
+5
-58
spdlite.h
lite/spdlite.h
+0
-50
spdlite_global.cpp
lite/spdlite_global.cpp
+64
-0
spdlite_global.h
lite/spdlite_global.h
+95
-0
spdlite_macros.h
lite/spdlite_macros.h
+24
-16
No files found.
lite-example/create_logger.cpp
View file @
c2b0e223
// Copyright(c) 2015-present Gabi Melman.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
#include "spdlite.h"
#include "spdlog/spdlog.h"
#include "spdlog/sinks/basic_file_sink.h"
#include "spdlog/sinks/stdout_color_sinks.h"
#include "spdlog/sinks/stdout_sinks.h"
#define UNUSED(x) (void)(x)
...
...
@@ -10,5 +12,5 @@
spdlite
::
logger
create_logger
(
void
*
ctx
)
{
UNUSED
(
ctx
);
return
spdlite
::
default_logger
();
return
spdlite
::
logger
(
spdlog
::
basic_logger_mt
(
"logger-name"
,
"log.txt"
,
true
));
}
lite-example/example.cpp
View file @
c2b0e223
// Copyright(c) 2015-present Gabi Melman.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
#include "spdlite.h"
#include "spdlite_global.h"
#define SPDLITE_ACTIVE_LEVEL SPDLITE_LEVEL_TRACE
#include "spdlite_macros.h"
int
main
()
{
spdlite
::
default_logger
().
set_level
(
spdlite
::
level
::
trace
);
spdlite
::
trace_printf
(
"Hello %d"
,
123
);
spdlite
::
debug_printf
(
"Hello %d"
,
123
);
spdlite
::
info_printf
(
"Hello %d"
,
123
);
spdlite
::
warn_printf
(
"Hello %d"
,
123
);
spdlite
::
error_printf
(
"Hello %d"
,
123
);
spdlite
::
critical_printf
(
"Hello %d"
,
123
);
{
SPDLITE_TRACE
(
"SOME INFO {}"
,
123
);
}
\ No newline at end of file
lite/CMakeLists.txt
View file @
c2b0e223
cmake_minimum_required
(
VERSION 3.1
)
project
(
spdlog_lite
)
add_library
(
spdlog_lite spdlite.cpp spdlite.h
)
add_library
(
spdlog_lite spdlite.cpp spdlite.h
spdlite_global.cpp spdlite_global.h spdlite_macros.h
)
target_link_libraries
(
spdlog_lite spdlog::spdlog
)
lite/spdlite.cpp
View file @
c2b0e223
//
// Copyright(c) 2019-present spdlog
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
//
#include "spdlite.h"
#include "spdlog/spdlog.h"
...
...
@@ -147,62 +152,4 @@ spdlite::logger &spdlite::logger::default_logger()
return
default_inst_
;
}
spdlite
::
logger
&
spdlite
::
default_logger
()
{
return
spdlite
::
logger
::
default_logger
();
}
// printf
void
spdlite
::
log_printf
(
spdlite
::
level
lvl
,
const
char
*
format
,
va_list
args
)
{
default_logger
().
log_printf
(
lvl
,
format
,
args
);
}
void
spdlite
::
trace_printf
(
const
char
*
format
,
...)
{
va_list
args
;
va_start
(
args
,
format
);
log_printf
(
level
::
trace
,
format
,
args
);
va_end
(
args
);
}
void
spdlite
::
debug_printf
(
const
char
*
format
,
...)
{
va_list
args
;
va_start
(
args
,
format
);
log_printf
(
level
::
debug
,
format
,
args
);
va_end
(
args
);
}
void
spdlite
::
info_printf
(
const
char
*
format
,
...)
{
va_list
args
;
va_start
(
args
,
format
);
log_printf
(
level
::
info
,
format
,
args
);
va_end
(
args
);
}
void
spdlite
::
warn_printf
(
const
char
*
format
,
...)
{
va_list
args
;
va_start
(
args
,
format
);
log_printf
(
level
::
warn
,
format
,
args
);
va_end
(
args
);
}
void
spdlite
::
error_printf
(
const
char
*
format
,
...)
{
va_list
args
;
va_start
(
args
,
format
);
log_printf
(
level
::
err
,
format
,
args
);
va_end
(
args
);
}
void
spdlite
::
critical_printf
(
const
char
*
format
,
...)
{
va_list
args
;
va_start
(
args
,
format
);
log_printf
(
level
::
critical
,
format
,
args
);
va_end
(
args
);
}
lite/spdlite.h
View file @
c2b0e223
//
// Copyright(c) 2015-present Gabi Melman.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
...
...
@@ -211,55 +210,6 @@ protected:
void
log_formatted_
(
spdlite
::
level
lvl
,
const
fmt
::
memory_buffer
&
formatted
);
};
//
// spdlite namespace functions - forward the calls to the default_logger.
//
spdlite
::
logger
&
default_logger
();
template
<
typename
...
Args
>
inline
void
trace
(
const
char
*
fmt
,
const
Args
&
...
args
)
{
default_logger
().
trace
(
fmt
,
args
...);
}
template
<
typename
...
Args
>
inline
void
debug
(
const
char
*
fmt
,
const
Args
&
...
args
)
{
default_logger
().
debug
(
fmt
,
args
...);
}
template
<
typename
...
Args
>
inline
void
info
(
const
char
*
fmt
,
const
Args
&
...
args
)
{
default_logger
().
info
(
fmt
,
args
...);
}
template
<
typename
...
Args
>
inline
void
warn
(
const
char
*
fmt
,
const
Args
&
...
args
)
{
default_logger
().
warn
(
fmt
,
args
...);
}
template
<
typename
...
Args
>
inline
void
error
(
const
char
*
fmt
,
const
Args
&
...
args
)
{
default_logger
().
error
(
fmt
,
args
...);
}
template
<
typename
...
Args
>
inline
void
critical
(
const
char
*
fmt
,
const
Args
&
...
args
)
{
default_logger
().
critical
(
fmt
,
args
...);
}
void
log_printf
(
spdlite
::
level
lvl
,
const
char
*
format
,
va_list
args
);
void
trace_printf
(
const
char
*
format
,
...);
void
debug_printf
(
const
char
*
format
,
...);
void
info_printf
(
const
char
*
format
,
...);
void
warn_printf
(
const
char
*
format
,
...);
void
error_printf
(
const
char
*
format
,
...);
void
critical_printf
(
const
char
*
format
,
...);
}
// namespace spdlite
...
...
lite/spdlite_global.cpp
0 → 100644
View file @
c2b0e223
// Copyright(c) 2015-present Gabi Melman.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
#include "spdlite_global.h"
spdlite
::
logger
&
spdlite
::
default_logger
()
{
return
spdlite
::
logger
::
default_logger
();
}
// printf
void
spdlite
::
log_printf
(
spdlite
::
level
lvl
,
const
char
*
format
,
va_list
args
)
{
default_logger
().
log_printf
(
lvl
,
format
,
args
);
}
void
spdlite
::
trace_printf
(
const
char
*
format
,
...)
{
va_list
args
;
va_start
(
args
,
format
);
log_printf
(
level
::
trace
,
format
,
args
);
va_end
(
args
);
}
void
spdlite
::
debug_printf
(
const
char
*
format
,
...)
{
va_list
args
;
va_start
(
args
,
format
);
log_printf
(
level
::
debug
,
format
,
args
);
va_end
(
args
);
}
void
spdlite
::
info_printf
(
const
char
*
format
,
...)
{
va_list
args
;
va_start
(
args
,
format
);
log_printf
(
level
::
info
,
format
,
args
);
va_end
(
args
);
}
void
spdlite
::
warn_printf
(
const
char
*
format
,
...)
{
va_list
args
;
va_start
(
args
,
format
);
log_printf
(
level
::
warn
,
format
,
args
);
va_end
(
args
);
}
void
spdlite
::
error_printf
(
const
char
*
format
,
...)
{
va_list
args
;
va_start
(
args
,
format
);
log_printf
(
level
::
err
,
format
,
args
);
va_end
(
args
);
}
void
spdlite
::
critical_printf
(
const
char
*
format
,
...)
{
va_list
args
;
va_start
(
args
,
format
);
log_printf
(
level
::
critical
,
format
,
args
);
va_end
(
args
);
}
\ No newline at end of file
lite/spdlite_global.h
0 → 100644
View file @
c2b0e223
// Copyright(c) 2015-present Gabi Melman.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
#pragma once
#include "spdlite.h"
namespace
spdlite
{
//
// spdlite namespace functions - forward the calls to the default_logger.
//
spdlite
::
logger
&
default_logger
();
template
<
typename
...
Args
>
inline
void
trace
(
const
char
*
fmt
,
const
Args
&
...
args
)
{
default_logger
().
trace
(
fmt
,
args
...);
}
template
<
typename
...
Args
>
inline
void
debug
(
const
char
*
fmt
,
const
Args
&
...
args
)
{
default_logger
().
debug
(
fmt
,
args
...);
}
template
<
typename
...
Args
>
inline
void
info
(
const
char
*
fmt
,
const
Args
&
...
args
)
{
default_logger
().
info
(
fmt
,
args
...);
}
template
<
typename
...
Args
>
inline
void
warn
(
const
char
*
fmt
,
const
Args
&
...
args
)
{
default_logger
().
warn
(
fmt
,
args
...);
}
template
<
typename
...
Args
>
inline
void
error
(
const
char
*
fmt
,
const
Args
&
...
args
)
{
default_logger
().
error
(
fmt
,
args
...);
}
template
<
typename
...
Args
>
inline
void
critical
(
const
char
*
fmt
,
const
Args
&
...
args
)
{
default_logger
().
critical
(
fmt
,
args
...);
}
// string view convertable
template
<
typename
T
>
inline
void
trace
(
const
T
&
msg
)
{
default_logger
().
trace
(
msg
);
}
template
<
typename
T
>
inline
void
debug
(
const
T
&
msg
)
{
default_logger
().
debug
(
msg
);
}
template
<
typename
T
>
inline
void
info
(
const
T
&
msg
)
{
default_logger
().
info
(
msg
);
}
template
<
typename
T
>
inline
void
warn
(
const
T
&
msg
)
{
default_logger
().
warn
(
msg
);
}
template
<
typename
T
>
inline
void
error
(
const
T
&
msg
)
{
default_logger
().
error
(
msg
);
}
template
<
typename
T
>
inline
void
critical
(
const
T
&
msg
)
{
default_logger
().
critical
(
msg
);
}
void
log_printf
(
spdlite
::
level
lvl
,
const
char
*
format
,
va_list
args
);
void
trace_printf
(
const
char
*
format
,
...);
void
debug_printf
(
const
char
*
format
,
...);
void
info_printf
(
const
char
*
format
,
...);
void
warn_printf
(
const
char
*
format
,
...);
void
error_printf
(
const
char
*
format
,
...);
void
critical_printf
(
const
char
*
format
,
...);
}
lite/spdlite_macros.h
View file @
c2b0e223
//
// Created by gabi on 3/24/19.
//
// Copyright(c) 2015-present Gabi Melman.
// Distributed under the MIT License (http://opensource.org/licenses/MIT)
#pragma once
//
...
...
@@ -8,6 +7,7 @@
//
// define SPDLITE_ACTIVE_LEVEL to one of those (before including lite.h):
#define SPDLITE_LEVEL_TRACE 0
#define SPDLITE_LEVEL_DEBUG 1
#define SPDLITE_LEVEL_INFO 2
...
...
@@ -18,49 +18,57 @@
#define SPDLITE_LOGGER_CALL(logger, level, ...) logger.log(level, __VA_ARGS__)
#if SPDLITE_ACTIVE_LEVEL <= SPDLITE_LEVEL_TRACE
#define SPDLITE_LOGGER_TRACE(logger, ...) SPDLITE_LOGGER_CALL(logger, spdlog::lite::level::trace, __VA_ARGS__)
#define SPDLITE_TRACE(...) SPDLITE_LOGGER_TRACE(spdlog::lite::default_logger(), __VA_ARGS__)
// default level is info
#ifndef SPDLITE_ACTIVE_LEVEL
#define SPDLITE_ACTIVE_LEVEL SPDLITE_LEVEL_INFO
#endif
static_assert
(
SPDLITE_ACTIVE_LEVEL
>=
SPDLITE_LEVEL_TRACE
&&
SPDLITE_ACTIVE_LEVEL
<=
SPDLITE_LEVEL_OFF
,
"SPDLITE_ACTIVE_LEVEL"
);
#if SPDLITE_ACTIVE_LEVEL == SPDLITE_LEVEL_TRACE
#define SPDLITE_LOGGER_TRACE(logger, ...) SPDLITE_LOGGER_CALL(logger, spdlite::level::trace, __VA_ARGS__)
#define SPDLITE_TRACE(...) SPDLITE_LOGGER_TRACE(spdlite::default_logger(), __VA_ARGS__)
#else
#define SPDLITE_LOGGER_TRACE(logger, ...) (void)0
#define SPDLITE_TRACE(...) (void)0
#endif
#if SPDLITE_ACTIVE_LEVEL <= SPDLITE_LEVEL_DEBUG
#define SPDLITE_LOGGER_DEBUG(logger, ...) SPDLITE_LOGGER_CALL(logger, spdl
og::l
ite::level::debug, __VA_ARGS__)
#define SPDLITE_DEBUG(...) SPDLITE_LOGGER_DEBUG(spdl
og::l
ite::default_logger(), __VA_ARGS__)
#define SPDLITE_LOGGER_DEBUG(logger, ...) SPDLITE_LOGGER_CALL(logger, spdlite::level::debug, __VA_ARGS__)
#define SPDLITE_DEBUG(...) SPDLITE_LOGGER_DEBUG(spdlite::default_logger(), __VA_ARGS__)
#else
#define SPDLITE_LOGGER_DEBUG(logger, ...) (void)0
#define SPDLITE_DEBUG(...) (void)0
#endif
#if SPDLITE_ACTIVE_LEVEL <= SPDLITE_LEVEL_INFO
#define SPDLITE_LOGGER_INFO(logger, ...) SPDLITE_LOGGER_CALL(logger, spdl
og::l
ite::level::info, __VA_ARGS__)
#define SPDLITE_INFO(...) SPDLITE_LOGGER_INFO(spdl
og::l
ite::default_logger(), __VA_ARGS__)
#define SPDLITE_LOGGER_INFO(logger, ...) SPDLITE_LOGGER_CALL(logger, spdlite::level::info, __VA_ARGS__)
#define SPDLITE_INFO(...) SPDLITE_LOGGER_INFO(spdlite::default_logger(), __VA_ARGS__)
#else
#define SPDLITE_LOGGER_INFO(logger, ...) (void)0
#define SPDLITE_INFO(...) (void)0
#endif
#if SPDLITE_ACTIVE_LEVEL <= SPDLITE_LEVEL_WARN
#define SPDLITE_LOGGER_WARN(logger, ...) SPDLITE_LOGGER_CALL(logger, spdl
og::l
ite::level::warn, __VA_ARGS__)
#define SPDLITE_WARN(...) SPDLITE_LOGGER_WARN(spdl
og::l
ite::default_logger(), __VA_ARGS__)
#define SPDLITE_LOGGER_WARN(logger, ...) SPDLITE_LOGGER_CALL(logger, spdlite::level::warn, __VA_ARGS__)
#define SPDLITE_WARN(...) SPDLITE_LOGGER_WARN(spdlite::default_logger(), __VA_ARGS__)
#else
#define SPDLITE_LOGGER_WARN(logger, ...) (void)0
#define SPDLITE_WARN(...) (void)0
#endif
#if SPDLITE_ACTIVE_LEVEL <= SPDLITE_LEVEL_ERROR
#define SPDLITE_LOGGER_ERROR(logger, ...) SPDLITE_LOGGER_CALL(logger, spdl
og::l
ite::level::err, __VA_ARGS__)
#define SPDLITE_ERROR(...) SPDLITE_LOGGER_ERROR(spdl
og::l
ite::default_logger(), __VA_ARGS__)
#define SPDLITE_LOGGER_ERROR(logger, ...) SPDLITE_LOGGER_CALL(logger, spdlite::level::err, __VA_ARGS__)
#define SPDLITE_ERROR(...) SPDLITE_LOGGER_ERROR(spdlite::default_logger(), __VA_ARGS__)
#else
#define SPDLITE_LOGGER_ERROR(logger, ...) (void)0
#define SPDLITE_ERROR(...) (void)0
#endif
#if SPDLITE_ACTIVE_LEVEL <= SPDLITE_LEVEL_CRITICAL
#define SPDLITE_LOGGER_CRITICAL(logger, ...) SPDLITE_LOGGER_CALL(logger, spdl
og::l
ite::level::critical, __VA_ARGS__)
#define SPDLITE_CRITICAL(...) SPDLITE_LOGGER_CRITICAL(spdl
og::l
ite::default_logger(), __VA_ARGS__)
#define SPDLITE_LOGGER_CRITICAL(logger, ...) SPDLITE_LOGGER_CALL(logger, spdlite::level::critical, __VA_ARGS__)
#define SPDLITE_CRITICAL(...) SPDLITE_LOGGER_CRITICAL(spdlite::default_logger(), __VA_ARGS__)
#else
#define SPDLITE_LOGGER_CRITICAL(logger, ...) (void)0
#define SPDLITE_CRITICAL(...) (void)0
...
...
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