Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jlib
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
captainwong
jlib
Commits
8143e973
Commit
8143e973
authored
Dec 09, 2019
by
captainwong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
1b734fdf
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
27 deletions
+42
-27
date
jlib/3rdparty/date
+1
-0
config.h
jlib/base/config.h
+25
-8
log.h
jlib/log.h
+3
-5
log2.h
jlib/log2.h
+13
-14
No files found.
date
@
48433b98
Subproject commit 48433b9892ac5741f8d4d8753beb76e49c57f7c8
jlib/base/config.h
View file @
8143e973
#pragma once
#ifdef __GNUG__
#define JLIB_LINUX
#
define JLIB_LINUX
#elif defined(WIN32) || defined(_WIN32) || defined(__WIN32)
#define JLIB_WINDOWS
#
define JLIB_WINDOWS
#else
#error "jlib only support linux and windows"
#
error "jlib only support linux and windows"
#endif
#ifdef JLIB_WINDOWS
#define _CRT_SECURE_NO_WARNINGS
# ifndef NOMINMAX
# define NOMINMAX
# endif
# ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
# endif
# ifndef _CRT_SECURE_NO_WARNINGS
# define _CRT_SECURE_NO_WARNINGS
# endif
// https://blogs.msdn.microsoft.com/vcblog/2016/03/30/optimizing-the-layout-of-empty-base-classes-in-vs2015-update-2-3/
#define ENABLE_EBO __declspec(empty_bases)
#else
#define ENABLE_EBO
#endif
# define ENABLE_EBO __declspec(empty_bases)
#else // JLIB_WINDOWS
# define ENABLE_EBO
#endif // JLIB_WINDOWS
jlib/log.h
View file @
8143e973
#pragma once
#ifdef WIN32
#ifndef _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#endif
//#include <Windows.h>
#include "base/config.h"
#ifdef JLIB_WINDOWS
#include "win32.h"
#endif
...
...
jlib/log2.h
View file @
8143e973
#pragma once
#include "base/config.h"
#ifdef JLIB_DISABLE_LOG
namespace
jlib
{
...
...
@@ -31,21 +33,18 @@ public:
#define JLIB_LOG2_ENABLED
#ifdef
_WIN32
#ifdef
JLIB_WINDOWS
#define SPDLOG_WCHAR_FILENAMES
#ifndef _CRT_SECURE_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#endif // _CRT_SECURE_NO_WARNINGS
#include <Windows.h>
#endif //
_WIN32
#endif //
JLIB_WINDOWS
#include <stdio.h>
#include "3rdparty/spdlog/spdlog.h"
#ifdef
_WIN32
#ifdef
JLIB_WINDOWS
#include "3rdparty/spdlog/sinks/msvc_sink.h"
#include "utf8.h"
#endif //
_WIN32
#endif //
JLIB_WINDOWS
#include "utf8.h"
...
...
@@ -54,14 +53,14 @@ namespace jlib {
static
constexpr
char
g_logger_name
[]
=
"jlogger"
;
inline
void
init_logger
(
#ifdef
_WIN32
#ifdef
JLIB_WINDOWS
std
::
wstring
#else
std
::
string
#endif
file_name
)
{
#ifdef
_WIN32
#ifdef
JLIB_WINDOWS
file_name
+=
L".log"
;
#else
file_name
+=
".log"
;
...
...
@@ -69,7 +68,7 @@ file_name)
try
{
std
::
vector
<
spdlog
::
sink_ptr
>
sinks
;
#ifdef
_WIN32
#ifdef
JLIB_WINDOWS
sinks
.
push_back
(
std
::
make_shared
<
spdlog
::
sinks
::
msvc_sink_mt
>
());
#endif
sinks
.
push_back
(
std
::
make_shared
<
spdlog
::
sinks
::
stdout_sink_mt
>
());
...
...
@@ -81,7 +80,7 @@ file_name)
spdlog
::
register_logger
(
combined_logger
);
combined_logger
->
flush_on
(
spdlog
::
level
::
trace
);
}
catch
(
const
spdlog
::
spdlog_ex
&
ex
)
{
#ifdef
_WIN32
#ifdef
JLIB_WINDOWS
char
msg
[
1024
]
=
{
0
};
sprintf_s
(
msg
,
"Log initialization failed: %s
\n
"
,
ex
.
what
());
MessageBoxA
(
nullptr
,
msg
,
"Error"
,
MB_ICONERROR
);
...
...
@@ -100,11 +99,11 @@ file_name)
#define JLOG_ERRO spdlog::get(jlib::g_logger_name)->error
#define JLOG_CRTC spdlog::get(jlib::g_logger_name)->critical
#ifdef
_WIN32
#ifdef
JLIB_WINDOWS
#define JLOG_ALL(args, ...) spdlog::get(jlib::g_logger_name)->log(spdlog::level::off, args, __VA_ARGS__)
#else
#define JLOG_ALL(args...) spdlog::get(jlib::g_logger_name)->log(spdlog::level::off, args)
#endif
/*
_WIN32
*/
#endif
/*
JLIB_WINDOWS
*/
class
range_log
{
...
...
@@ -131,7 +130,7 @@ public:
}
};
#ifdef
_WIN32
#ifdef
JLIB_WINDOWS
#define __the_pretty_name_of_this_function__ __FUNCTION__
#else
#define __the_pretty_name_of_this_function__ __PRETTY_FUNCTION__
...
...
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