Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-cpplib
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-cpplib
Commits
ff427e9e
Verified
Commit
ff427e9e
authored
Oct 15, 2021
by
Timm Fitschen
Browse files
Options
Downloads
Patches
Plain Diff
Fix tests
parent
cf4f7094
No related branches found
No related tags found
2 merge requests
!33
Release 0.1
,
!30
Debug build
Pipeline
#14901
failed
Oct 15, 2021
Stage: info
Stage: setup
Stage: test
Stage: deploy
Changes
3
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
include/caosdb/logging.h
+8
-10
8 additions, 10 deletions
include/caosdb/logging.h
src/caosdb/logging.cpp
+9
-14
9 additions, 14 deletions
src/caosdb/logging.cpp
test/test_entity.cpp
+22
-20
22 additions, 20 deletions
test/test_entity.cpp
with
39 additions
and
44 deletions
include/caosdb/logging.h
+
8
−
10
View file @
ff427e9e
...
@@ -41,11 +41,11 @@ typedef boost::log::sources::severity_channel_logger_mt<int, std::string> boost_
...
@@ -41,11 +41,11 @@ typedef boost::log::sources::severity_channel_logger_mt<int, std::string> boost_
class
logger
{
class
logger
{
public:
public:
static
boost_logger_class
&
get
()
{
return
*
logger
::
GetInstance
().
_logger_instance
;
}
static
auto
destroy
()
->
void
{
static
void
destroy
()
{
auto
&
instance
=
logger
::
GetInstance
();
auto
&
instance
=
logger
::
GetInstance
();
delete
instance
.
_logger_instance
;
delete
instance
.
_logger_instance
;
}
}
static
auto
get
()
->
boost_logger_class
&
{
return
*
logger
::
GetInstance
().
_logger_instance
;
}
private
:
private
:
logger
()
{
this
->
_logger_instance
=
new
boost_logger_class
();
};
logger
()
{
this
->
_logger_instance
=
new
boost_logger_class
();
};
...
@@ -56,8 +56,6 @@ private:
...
@@ -56,8 +56,6 @@ private:
boost_logger_class
*
_logger_instance
;
boost_logger_class
*
_logger_instance
;
};
};
auto
inline
get_logger
()
->
boost_logger_class
&
{
return
logger
::
get
();
}
/**
/**
* This class stores the integer log level.
* This class stores the integer log level.
*/
*/
...
@@ -203,17 +201,17 @@ void caosdb_log_trace(const char *channel, const char *msg);
...
@@ -203,17 +201,17 @@ void caosdb_log_trace(const char *channel, const char *msg);
}
// namespace caosdb::logging
}
// namespace caosdb::logging
#define CAOSDB_LOG_FATAL(Channel) \
#define CAOSDB_LOG_FATAL(Channel) \
BOOST_LOG_CHANNEL_SEV(caosdb::logging::
get_
logger(), Channel, CAOSDB_LOG_LEVEL_FATAL)
BOOST_LOG_CHANNEL_SEV(caosdb::logging::logger
::get
(), Channel, CAOSDB_LOG_LEVEL_FATAL)
#define CAOSDB_LOG_ERROR(Channel) \
#define CAOSDB_LOG_ERROR(Channel) \
BOOST_LOG_CHANNEL_SEV(caosdb::logging::
get_
logger(), Channel, CAOSDB_LOG_LEVEL_ERROR)
BOOST_LOG_CHANNEL_SEV(caosdb::logging::logger
::get
(), Channel, CAOSDB_LOG_LEVEL_ERROR)
#define CAOSDB_LOG_WARN(Channel) \
#define CAOSDB_LOG_WARN(Channel) \
BOOST_LOG_CHANNEL_SEV(caosdb::logging::
get_
logger(), Channel, CAOSDB_LOG_LEVEL_WARN)
BOOST_LOG_CHANNEL_SEV(caosdb::logging::logger
::get
(), Channel, CAOSDB_LOG_LEVEL_WARN)
#define CAOSDB_LOG_INFO(Channel) \
#define CAOSDB_LOG_INFO(Channel) \
BOOST_LOG_CHANNEL_SEV(caosdb::logging::
get_
logger(), Channel, CAOSDB_LOG_LEVEL_INFO)
BOOST_LOG_CHANNEL_SEV(caosdb::logging::logger
::get
(), Channel, CAOSDB_LOG_LEVEL_INFO)
#define CAOSDB_LOG_DEBUG(Channel) \
#define CAOSDB_LOG_DEBUG(Channel) \
BOOST_LOG_CHANNEL_SEV(caosdb::logging::
get_
logger(), Channel, CAOSDB_LOG_LEVEL_DEBUG)
BOOST_LOG_CHANNEL_SEV(caosdb::logging::logger
::get
(), Channel, CAOSDB_LOG_LEVEL_DEBUG)
#define CAOSDB_LOG_TRACE(Channel) \
#define CAOSDB_LOG_TRACE(Channel) \
BOOST_LOG_CHANNEL_SEV(caosdb::logging::
get_
logger(), Channel, CAOSDB_LOG_LEVEL_TRACE)
BOOST_LOG_CHANNEL_SEV(caosdb::logging::logger
::get
(), Channel, CAOSDB_LOG_LEVEL_TRACE)
#define CAOSDB_LOG_ERROR_AND_RETURN_STATUS(Channel, StatusCode, Message) \
#define CAOSDB_LOG_ERROR_AND_RETURN_STATUS(Channel, StatusCode, Message) \
CAOSDB_LOG_ERROR(Channel) << "StatusCode (" << StatusCode << ") " \
CAOSDB_LOG_ERROR(Channel) << "StatusCode (" << StatusCode << ") " \
...
...
This diff is collapsed.
Click to expand it.
src/caosdb/logging.cpp
+
9
−
14
View file @
ff427e9e
...
@@ -44,13 +44,8 @@
...
@@ -44,13 +44,8 @@
#include
<utility>
// for move
#include
<utility>
// for move
#include
<vector>
#include
<vector>
void
__attribute__
((
constructor
))
startup
()
{
void
__attribute__
((
constructor
))
startup
()
{}
std
::
cout
<<
"LOADING CAOSDB"
<<
std
::
endl
;
void
__attribute__
((
destructor
))
shutdown
()
{
caosdb
::
logging
::
logger
::
destroy
();
}
}
void
__attribute__
((
destructor
))
shutdown
()
{
std
::
cout
<<
"UNLOADING CAOSDB"
<<
std
::
endl
;
caosdb
::
logging
::
logger
::
destroy
();
}
namespace
caosdb
::
logging
{
namespace
caosdb
::
logging
{
...
@@ -140,7 +135,7 @@ auto initialize_logging_defaults() -> int {
...
@@ -140,7 +135,7 @@ auto initialize_logging_defaults() -> int {
}
}
boost
::
log
::
init_from_settings
(
default_settings
);
boost
::
log
::
init_from_settings
(
default_settings
);
//
core->add_global_attribute("TimeStamp", boost::log::attributes::local_clock());
core
->
add_global_attribute
(
"TimeStamp"
,
boost
::
log
::
attributes
::
local_clock
());
CAOSDB_LOG_DEBUG
(
logger_name
)
<<
"Initialized default settings."
;
CAOSDB_LOG_DEBUG
(
logger_name
)
<<
"Initialized default settings."
;
...
@@ -176,27 +171,27 @@ auto initialize_logging(const LoggingConfiguration &configuration) -> void {
...
@@ -176,27 +171,27 @@ auto initialize_logging(const LoggingConfiguration &configuration) -> void {
}
}
void
caosdb_log_fatal
(
const
char
*
channel
,
const
char
*
msg
)
{
void
caosdb_log_fatal
(
const
char
*
channel
,
const
char
*
msg
)
{
BOOST_LOG_CHANNEL_SEV
(
caosdb
::
logging
::
get_
logger
(),
channel
,
CAOSDB_LOG_LEVEL_FATAL
)
<<
msg
;
BOOST_LOG_CHANNEL_SEV
(
caosdb
::
logging
::
logger
::
get
(),
channel
,
CAOSDB_LOG_LEVEL_FATAL
)
<<
msg
;
}
}
void
caosdb_log_error
(
const
char
*
channel
,
const
char
*
msg
)
{
void
caosdb_log_error
(
const
char
*
channel
,
const
char
*
msg
)
{
BOOST_LOG_CHANNEL_SEV
(
caosdb
::
logging
::
get_
logger
(),
channel
,
CAOSDB_LOG_LEVEL_ERROR
)
<<
msg
;
BOOST_LOG_CHANNEL_SEV
(
caosdb
::
logging
::
logger
::
get
(),
channel
,
CAOSDB_LOG_LEVEL_ERROR
)
<<
msg
;
}
}
void
caosdb_log_warn
(
const
char
*
channel
,
const
char
*
msg
)
{
void
caosdb_log_warn
(
const
char
*
channel
,
const
char
*
msg
)
{
BOOST_LOG_CHANNEL_SEV
(
caosdb
::
logging
::
get_
logger
(),
channel
,
CAOSDB_LOG_LEVEL_WARN
)
<<
msg
;
BOOST_LOG_CHANNEL_SEV
(
caosdb
::
logging
::
logger
::
get
(),
channel
,
CAOSDB_LOG_LEVEL_WARN
)
<<
msg
;
}
}
void
caosdb_log_info
(
const
char
*
channel
,
const
char
*
msg
)
{
void
caosdb_log_info
(
const
char
*
channel
,
const
char
*
msg
)
{
BOOST_LOG_CHANNEL_SEV
(
caosdb
::
logging
::
get_
logger
(),
channel
,
CAOSDB_LOG_LEVEL_INFO
)
<<
msg
;
BOOST_LOG_CHANNEL_SEV
(
caosdb
::
logging
::
logger
::
get
(),
channel
,
CAOSDB_LOG_LEVEL_INFO
)
<<
msg
;
}
}
void
caosdb_log_debug
(
const
char
*
channel
,
const
char
*
msg
)
{
void
caosdb_log_debug
(
const
char
*
channel
,
const
char
*
msg
)
{
BOOST_LOG_CHANNEL_SEV
(
caosdb
::
logging
::
get_
logger
(),
channel
,
CAOSDB_LOG_LEVEL_DEBUG
)
<<
msg
;
BOOST_LOG_CHANNEL_SEV
(
caosdb
::
logging
::
logger
::
get
(),
channel
,
CAOSDB_LOG_LEVEL_DEBUG
)
<<
msg
;
}
}
void
caosdb_log_trace
(
const
char
*
channel
,
const
char
*
msg
)
{
void
caosdb_log_trace
(
const
char
*
channel
,
const
char
*
msg
)
{
BOOST_LOG_CHANNEL_SEV
(
caosdb
::
logging
::
get_
logger
(),
channel
,
CAOSDB_LOG_LEVEL_TRACE
)
<<
msg
;
BOOST_LOG_CHANNEL_SEV
(
caosdb
::
logging
::
logger
::
get
(),
channel
,
CAOSDB_LOG_LEVEL_TRACE
)
<<
msg
;
}
}
}
// namespace caosdb::logging
}
// namespace caosdb::logging
This diff is collapsed.
Click to expand it.
test/test_entity.cpp
+
22
−
20
View file @
ff427e9e
...
@@ -143,16 +143,17 @@ TEST(test_entity, test_append_property) {
...
@@ -143,16 +143,17 @@ TEST(test_entity, test_append_property) {
}
}
TEST
(
test_entity
,
entity_copy_constructor
)
{
TEST
(
test_entity
,
entity_copy_constructor
)
{
ProtoParent
parent
;
Arena
arena
;
parent
.
set_description
(
"the parent desc"
);
auto
*
parent
=
Arena
::
CreateMessage
<
ProtoParent
>
(
&
arena
);
parent
.
set_id
(
"the parent id"
);
parent
->
set_description
(
"the parent desc"
);
parent
.
set_name
(
"the parent name"
);
parent
->
set_id
(
"the parent id"
);
ProtoProperty
property
;
parent
->
set_name
(
"the parent name"
);
property
.
set_id
(
"the-prop-id"
);
auto
*
property
=
Arena
::
CreateMessage
<
ProtoProperty
>
(
&
arena
);
property
.
set_description
(
"the prop-desc"
);
property
->
set_id
(
"the-prop-id"
);
property
.
set_name
(
"the-prop-name"
);
property
->
set_description
(
"the prop-desc"
);
property
.
mutable_value
()
->
mutable_list_values
()
->
mutable_values
()
->
Add
()
->
set_double_value
(
25.5
);
property
->
set_name
(
"the-prop-name"
);
property
.
mutable_data_type
()
->
mutable_list_data_type
()
->
set_atomic_data_type
(
property
->
mutable_value
()
->
mutable_list_values
()
->
mutable_values
()
->
Add
()
->
set_double_value
(
25.5
);
property
->
mutable_data_type
()
->
mutable_list_data_type
()
->
set_atomic_data_type
(
ProtoAtomicDataType
::
ATOMIC_DATA_TYPE_DOUBLE
);
ProtoAtomicDataType
::
ATOMIC_DATA_TYPE_DOUBLE
);
auto
*
entity_response
=
Arena
::
CreateMessage
<
EntityResponse
>
(
&
arena
);
auto
*
entity_response
=
Arena
::
CreateMessage
<
EntityResponse
>
(
&
arena
);
entity_response
->
mutable_entity
()
->
set_id
(
"the-id"
);
entity_response
->
mutable_entity
()
->
set_id
(
"the-id"
);
...
@@ -198,16 +199,17 @@ TEST(test_entity, entity_copy_constructor) {
...
@@ -198,16 +199,17 @@ TEST(test_entity, entity_copy_constructor) {
}
}
TEST
(
test_entity
,
entity_move_constructor
)
{
TEST
(
test_entity
,
entity_move_constructor
)
{
ProtoParent
parent
;
Arena
arena
;
parent
.
set_description
(
"the parent desc"
);
auto
*
parent
=
Arena
::
CreateMessage
<
ProtoParent
>
(
&
arena
);
parent
.
set_id
(
"the parent id"
);
parent
->
set_description
(
"the parent desc"
);
parent
.
set_name
(
"the parent name"
);
parent
->
set_id
(
"the parent id"
);
ProtoProperty
property
;
parent
->
set_name
(
"the parent name"
);
property
.
set_id
(
"the-prop-id"
);
auto
*
property
=
Arena
::
CreateMessage
<
ProtoProperty
>
(
&
arena
);
property
.
set_description
(
"the prop-desc"
);
property
->
set_id
(
"the-prop-id"
);
property
.
set_name
(
"the-prop-name"
);
property
->
set_description
(
"the prop-desc"
);
property
.
mutable_value
()
->
mutable_list_values
()
->
mutable_values
()
->
Add
()
->
set_double_value
(
25.5
);
property
->
set_name
(
"the-prop-name"
);
property
.
mutable_data_type
()
->
mutable_list_data_type
()
->
set_atomic_data_type
(
property
->
mutable_value
()
->
mutable_list_values
()
->
mutable_values
()
->
Add
()
->
set_double_value
(
25.5
);
property
->
mutable_data_type
()
->
mutable_list_data_type
()
->
set_atomic_data_type
(
ProtoAtomicDataType
::
ATOMIC_DATA_TYPE_DOUBLE
);
ProtoAtomicDataType
::
ATOMIC_DATA_TYPE_DOUBLE
);
auto
*
entity_response
=
Arena
::
CreateMessage
<
EntityResponse
>
(
&
arena
);
auto
*
entity_response
=
Arena
::
CreateMessage
<
EntityResponse
>
(
&
arena
);
entity_response
->
mutable_errors
()
->
Add
()
->
set_code
(
25
);
entity_response
->
mutable_errors
()
->
Add
()
->
set_code
(
25
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment