-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathglobal.cpp
More file actions
150 lines (121 loc) · 5.22 KB
/
Copy pathglobal.cpp
File metadata and controls
150 lines (121 loc) · 5.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
//------------------------------------------------------------
// natus (c) Alexis Constantin Link
// Distributed under the MIT license
//------------------------------------------------------------
#include "global.h"
#include "system/system.h"
using namespace motor::log ;
std::mutex global::_mtx ;
global::this_ptr_t global::_ptr = nullptr ;
//*************************************************************************************
global::global( void_t ) noexcept
{
__default_log_system = motor::log::system_t::create() ;
}
//*************************************************************************************
global::global( this_rref_t rhv ) noexcept
{
motor_move_member_ptr( __default_log_system, rhv ) ;
}
//*************************************************************************************
global::~global( void_t ) noexcept
{
motor::log::system::destroy( __default_log_system ) ;
}
//*************************************************************************************
global::this_ptr_t global::init( void_t ) noexcept
{
if( global_t::_ptr != nullptr ) return this_t::_ptr ;
{
std::lock_guard<::std::mutex> lk( this_t::_mtx ) ;
if( global_t::_ptr != nullptr ) return this_t::_ptr ;
this_t::_ptr = new this_t() ;
this_t::status( "[online] : natus log" ) ;
}
return this_t::_ptr ;
}
//*************************************************************************************
void_t global::deinit( void_t ) noexcept
{
if( global_t::_ptr == nullptr ) return ;
delete global_t::_ptr ;
this_t::_ptr = nullptr ;
}
//*************************************************************************************
global::this_ptr_t global::get( void_t ) noexcept
{
return this_t::init() ;
}
//*************************************************************************************
void_t global::add_logger( motor::log::ilogger_ptr_t ptr ) noexcept
{
this_t::get()->__default_log_system->add_logger( ptr ) ;
}
//*************************************************************************************
motor::log::store_logger_cptr_t global::get_store( void_t ) noexcept
{
return this_t::get()->__default_log_system->get_store() ;
}
//*************************************************************************************
void_t global::message( log_level const level, motor::core::string_cref_t msg ) noexcept
{
this_t::get()->__default_log_system->log( level, msg ) ;
}
//*************************************************************************************
bool_t global::message( bool_t const condition, log_level const level, motor::core::string_cref_t msg ) noexcept
{
if( condition ) motor::log::global::message( level, msg ) ;
return condition ;
}
//*************************************************************************************
void_t global::status( motor::core::string_cref_t msg ) noexcept
{
motor::log::global::message( motor::log::log_level::status, msg ) ;
}
//*************************************************************************************
bool_t global::status( bool_t const condition, motor::core::string_cref_t msg ) noexcept
{
return motor::log::global::message( condition, motor::log::log_level::status, msg ) ;
}
//*************************************************************************************
void_t global::warning( motor::core::string_cref_t msg ) noexcept
{
motor::log::global::message( motor::log::log_level::warning, msg ) ;
}
//*************************************************************************************
bool_t global::warning( bool_t const condition, motor::core::string_cref_t msg ) noexcept
{
return motor::log::global::message( condition, motor::log::log_level::warning, msg ) ;
}
//*************************************************************************************
void_t global::error( motor::core::string_cref_t msg ) noexcept
{
motor::log::global::message( motor::log::log_level::error, msg ) ;
}
//*************************************************************************************
void_t global::error_and_exit( motor::core::string_cref_t msg ) noexcept
{
motor::log::global::message( motor::log::log_level::error, msg ) ;
std::exit( 1 ) ;
}
//*************************************************************************************
void_t global::error_and_exit( bool_t const condition, motor::core::string_cref_t msg ) noexcept
{
if( motor::log::global::message( condition, motor::log::log_level::error, msg ) )
std::exit( 1 ) ;
}
//*************************************************************************************
bool_t global::error( bool_t const condition, motor::core::string_cref_t msg ) noexcept
{
return motor::log::global::message( condition, motor::log::log_level::error, msg ) ;
}
//*************************************************************************************
void_t global::critical( motor::core::string_cref_t msg ) noexcept
{
motor::log::global::message( motor::log::log_level::critical, msg ) ;
}
//*************************************************************************************
bool_t global::critical( bool_t const condition, motor::core::string_cref_t msg ) noexcept
{
return motor::log::global::message( condition, motor::log::log_level::critical, msg ) ;
}