Skip to content

Commit

Permalink
Merge pull request #170 from etienneschmitt/develop-schmitte
Browse files Browse the repository at this point in the history
Logger
  • Loading branch information
pierrekraemer committed Mar 30, 2016
2 parents 7211440 + 5373664 commit aa94e56
Show file tree
Hide file tree
Showing 71 changed files with 74,132 additions and 247 deletions.
9 changes: 5 additions & 4 deletions benchmarks/multithreading/bench_multithreading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <chrono>
#include <vector>

#include <core/utils/logger.h>
#include <core/cmap/cmap2.h>
#include <io/map_import.h>
#include <geometry/algos/normal.h>
Expand Down Expand Up @@ -128,7 +129,7 @@ static void BENCH_faces_normals_multi_threaded(benchmark::State& state)
Vec3 error = face_normal[f] - face_normal_mt[f];
if (!cgogn::almost_equal_absolute(error.squaredNorm(), 0., 1e-9 ))
{
std::cerr << __FILE__ << ":" << __LINE__ << " : there was an error during computation of normals" << std::endl;
cgogn_log_warning("bench_multithreading") << "There was an error during computation of normals.";
// std::cerr << "face_normal " << face_normal[f] << std::endl;
// std::cerr << "face_normal_mt " << face_normal_mt[f] << std::endl;
}
Expand Down Expand Up @@ -186,7 +187,7 @@ static void BENCH_vertices_normals_multi_threaded(benchmark::State& state)
Vec3 error = vertices_normal[v] - vertices_normal_mt[v];
if (!cgogn::almost_equal_absolute(error.squaredNorm(), 0., 1e-9 ))
{
std::cerr << __FILE__ << ":" << __LINE__ << " : there was an error during computation of vertices normals" << std::endl;
cgogn_log_warning("bench_multithreading") << "There was an error during computation of vertices normals.";
// std::cerr << "vertices_normal " << vertices_normal[v] << std::endl;
// std::cerr << "vertices_normal_mt " << vertices_normal_mt[v] << std::endl;
}
Expand Down Expand Up @@ -222,9 +223,9 @@ int main(int argc, char** argv)

if (argc < 2)
{
std::cout << "USAGE: " << argv[0] << " [filename]" << std::endl;
cgogn_log_info("bench_multithreading") << "USAGE: " << argv[0] << " [filename]";
surfaceMesh = std::string(DEFAULT_MESH_PATH) + std::string("off/aneurysm_3D.off");
std::cout << "Using default mesh : " << surfaceMesh << std::endl;
cgogn_log_info("bench_multithreading") << "Using default mesh : \"" << surfaceMesh << "\".";
}
else
surfaceMesh = std::string(argv[1]);
Expand Down
9 changes: 9 additions & 0 deletions cgogn/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ set(HEADER_FILES
utils/thread_barrier.h
utils/string.h
utils/precision.h
utils/logger.h
utils/log_entry.h
utils/logger_output.h
utils/log_stream.h
)

set(SOURCE_FILES
Expand All @@ -64,6 +68,10 @@ set(SOURCE_FILES
utils/thread.cpp
utils/thread_pool.cpp
utils/serialization.cpp
utils/logger.cpp
utils/log_entry.cpp
utils/logger_output.cpp
utils/log_stream.cpp
)

add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${SOURCE_FILES})
Expand All @@ -80,6 +88,7 @@ set_target_properties(${PROJECT_NAME} PROPERTIES DEBUG_POSTFIX "_d")

target_include_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CGOGN_SOURCE_DIR}>
$<BUILD_INTERFACE:${CGOGN_THIRDPARTY_TERMCOLOR_INCLUDE_DIR}>
$<INSTALL_INTERFACE:include/cgogn/core>
)

Expand Down
2 changes: 1 addition & 1 deletion cgogn/core/cmap/cmap1.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ class CMap1_T : public CMap0_T<MAP_TRAITS, MAP_TYPE>
cgogn_message_assert(size > 0u, "Cannot create an empty face");

if (size == 0)
std::cerr << "Warning: attempt to create an empty face results in a single dart" << std::endl;
cgogn_log_warning("add_face_topo") << "Attempt to create an empty face results in a single dart.";

Dart d = this->add_dart();
for (uint32 i = 1u; i < size; ++i)
Expand Down
15 changes: 8 additions & 7 deletions cgogn/core/cmap/map_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include <core/basic/dart_marker.h>
#include <core/basic/cell_marker.h>

#include <core/utils/logger.h>
#include <core/utils/thread_barrier.h>
#include <core/utils/unique_ptr.h>

Expand Down Expand Up @@ -376,7 +377,7 @@ class MapBase : public MapBaseData<MAP_TRAITS>
{
const uint32 old_emb = this->get_embedding(c);
const uint32 new_emb = this->new_orbit_embedding(c);
std::cerr << "Warning: enforce_unique_orbit_embedding: duplicating orbit #" << old_emb << " in orbit " << orbit_name(ORBIT) << std::endl;
cgogn_log_warning("enforce_unique_orbit_embedding")<< "Warning: enforce_unique_orbit_embedding: duplicating orbit #" << old_emb << " in orbit " << orbit_name(ORBIT);
this->template get_attribute_container<ORBIT>().copy_line(new_emb, old_emb,false,false);
}

Expand Down Expand Up @@ -415,7 +416,7 @@ class MapBase : public MapBaseData<MAP_TRAITS>
if (idx == EMBNULL)
{
result = false;
std::cerr << "EMBNULL found for dart "<< c << " in orbit " << orbit_name(ORBIT) << std::endl;
cgogn_log_error("is_well_embedded")<< "EMBNULL found for dart "<< c << " in orbit " << orbit_name(ORBIT);
return;
}
counter[idx].push_back(c);
Expand All @@ -424,7 +425,7 @@ class MapBase : public MapBaseData<MAP_TRAITS>
{
const uint32 emb_d = this->get_embedding(CellType(d));
if (emb_d != idx)
std::cerr << "Different indices (" << idx << " and " << emb_d << ") in orbit " << orbit_name(ORBIT) << std::endl;
cgogn_log_error("is_well_embedded") << "Different indices (" << idx << " and " << emb_d << ") in orbit " << orbit_name(ORBIT);
});
});
// check that all cells present in the attribute handler are used
Expand All @@ -433,14 +434,14 @@ class MapBase : public MapBaseData<MAP_TRAITS>
if (counter[i].empty())
{
result =false;
std::cerr << "Cell #" << i << " is not used in orbit " << orbit_name(ORBIT) << std::endl;
cgogn_log_error("is_well_embedded") << "Cell #" << i << " is not used in orbit " << orbit_name(ORBIT);
} else
{
const std::size_t size = counter[i].size();
if (size >= 2ul)
{
result =false;
std::cerr << size << " cells with same index \"" << i << "\" in orbit " << orbit_name(ORBIT) << std::endl;
cgogn_log_error("is_well_embedded") << size << " cells with same index \"" << i << "\" in orbit " << orbit_name(ORBIT);
}
}
}
Expand All @@ -462,15 +463,15 @@ class MapBase : public MapBaseData<MAP_TRAITS>
});
if (!result)
{
std::cerr << "Integrity of the topology is broken" << std::endl;
cgogn_log_error("check_map_integrity") << "Integrity of the topology is broken";
return false;
}

// check the embedding indexation for the concrete map
result = cmap->check_embedding_integrity();
if (!result)
{
std::cerr << "Integrity of the embeddings is broken" << std::endl;
cgogn_log_error("check_map_integrity") << "Integrity of the embeddings is broken";
return false;
}
return true;
Expand Down
3 changes: 1 addition & 2 deletions cgogn/core/cmap/map_base_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,7 @@ class MapBaseData : public MapGen
{
static uint32 index = 0u;
const std::thread::id& th_id = std::this_thread::get_id();
std::cerr << "WARNING: registration of an unknown thread (id :" << th_id << ") in the map." << std::endl;
std::cerr << "Data can be lost. Please use add_thread and remove_thread interface." << std::endl;
cgogn_log_warning("add_unknown_thread") << "Registration of an unknown thread (id :" << th_id << ") in the map. Data can be lost. Please use add_thread and remove_thread interface.";
thread_ids_[index] = th_id;
const unsigned old_index = index;
index = (index+1u) % NB_UNKNOWN_THREADS;
Expand Down
15 changes: 8 additions & 7 deletions cgogn/core/container/chunk_array_container.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <memory>
#include <climits>

#include <core/utils/logger.h>
#include <core/dll.h>
#include <core/utils/definitions.h>
#include <core/utils/assert.h>
Expand Down Expand Up @@ -195,7 +196,7 @@ class ChunkArrayContainer
uint32 index = get_array_index(attribute_name);
if (index == UNKNOWN)
{
std::cerr << "attribute " << attribute_name << " not found." << std::endl;
cgogn_log_warning("get_attribute") << "Attribute \"" << attribute_name << "\" not found.";
return nullptr;
}

Expand All @@ -217,7 +218,7 @@ class ChunkArrayContainer
uint32 index = get_array_index(attribute_name);
if (index != UNKNOWN)
{
std::cerr << "attribute " << attribute_name << " already exists.." << std::endl;
cgogn_log_warning("add_attribute") << "Attribute \"" << attribute_name << "\" already exists.";
return nullptr;
}

Expand Down Expand Up @@ -248,7 +249,7 @@ class ChunkArrayContainer

if (index == UNKNOWN)
{
std::cerr << "removeAttribute by name: attribute not found (" << attribute_name << ")" << std::endl;
cgogn_log_warning("remove_attribute_by_name") << "Attribute \""<< attribute_name << "\" not found.";
return false;
}

Expand All @@ -268,7 +269,7 @@ class ChunkArrayContainer

if (index == UNKNOWN)
{
std::cerr << "remove_attribute by ptr: attribute not found" << std::endl;
cgogn_log_warning("remove_attribute_by_ptr") << "Attribute not found.";
return false;
}

Expand Down Expand Up @@ -300,7 +301,7 @@ class ChunkArrayContainer
while (index < table_marker_arrays_.size() && table_marker_arrays_[index] != ptr)
++index;

cgogn_message_assert(index != table_marker_arrays_.size(), "remove_marker_attribute by ptr: attribute not found");
cgogn_message_assert(index != table_marker_arrays_.size(), "remove_marker_attribute by ptr: attribute not found.");

if (index != table_marker_arrays_.size() - std::size_t(1u))
table_marker_arrays_[index] = table_marker_arrays_.back();
Expand Down Expand Up @@ -332,7 +333,7 @@ class ChunkArrayContainer

ChunkArray<T>* atm = dynamic_cast<ChunkArray<T>*>(table_arrays_[index]);

cgogn_message_assert(atm != nullptr, "get_data_array : wrong type");
cgogn_message_assert(atm != nullptr, "get_data_array : wrong type.");

return atm;
}
Expand Down Expand Up @@ -818,7 +819,7 @@ class ChunkArrayContainer
}
else
{
std::cerr << "ChunkArrayContainer: could not load attribute" << names_[i] << " of type "<< type_names_[i] << std::endl;
cgogn_log_warning("ChunkArrayContainer::load") << "Could not load attribute \"" << names_[i] << "\" of type \""<< type_names_[i] << "\".";
type_names_.erase(type_names_.begin()+i);
names_.erase(names_.begin()+i);
ChunkArrayGen::skip(fs);
Expand Down
3 changes: 2 additions & 1 deletion cgogn/core/container/chunk_array_factory.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#ifndef CORE_CONTAINER_CHUNK_ARRAY_FACTORY_H_
#define CORE_CONTAINER_CHUNK_ARRAY_FACTORY_H_

#include <core/utils/logger.h>
#include <core/utils/unique_ptr.h>
#include <core/utils/name_types.h>
#include <core/container/chunk_array.h>
Expand Down Expand Up @@ -110,7 +111,7 @@ class ChunkArrayFactory
tmp = (it->second)->clone();
}
else
std::cerr << "type " << keyType << " not registred in ChunkArrayFactory" << std::endl;
cgogn_log_warning("ChunkArrayFactory::create") << "Type \"" << keyType << "\" is not registred in ChunkArrayFactory.";

return tmp;
}
Expand Down
22 changes: 11 additions & 11 deletions cgogn/core/examples/chunk_array/bench_chunk_array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const uint32 NB_LINES = 20000000;

int test1()
{
std::cout << "= TEST 1 = ref unsigned char" << std::endl;
cgogn_log_info("bench_chunk_array") << "= TEST 1 = ref unsigned char" ;

ChunkArrayContainer<BLK_SZ, unsigned char> container;
ChunkArray<BLK_SZ,int32>* att1 = container.add_attribute<int32>("entier");
Expand Down Expand Up @@ -70,13 +70,13 @@ int test1()
container.insert_lines<1>();
}

std::cout << "---> OK" << std::endl;
cgogn_log_info("bench_chunk_array") << "---> OK" ;
return 0;
}

int test2()
{
std::cout << "= TEST 2 = ref bool" << std::endl;
cgogn_log_info("bench_chunk_array") << "= TEST 2 = ref bool" ;

ChunkArrayContainer<BLK_SZ, bool> container;
ChunkArray<BLK_SZ,int32>* att1 = container.add_attribute<int32>("entier");
Expand Down Expand Up @@ -106,13 +106,13 @@ int test2()
container.insert_lines<1>();
}

std::cout << "---> OK" << std::endl;
cgogn_log_info("bench_chunk_array") << "---> OK" ;
return 0;
}

int test3()
{
std::cout << "= TEST 3 = random bool cleaning" << std::endl;
cgogn_log_info("bench_chunk_array") << "= TEST 3 = random bool cleaning" ;

ChunkArrayContainer<BLK_SZ, bool> container;
ChunkArray<BLK_SZ,bool>* att1 = container.add_attribute<bool>("bools");
Expand All @@ -134,13 +134,13 @@ int test3()
}
}

std::cout << "---> OK" << std::endl;
cgogn_log_info("bench_chunk_array") << "---> OK" ;
return 0;
}

int test4()
{
std::cout << "= TEST 4 = random bool cleaning with set_false_byte" << std::endl;
cgogn_log_info("bench_chunk_array") << "= TEST 4 = random bool cleaning with set_false_byte" ;

ChunkArrayContainer<BLK_SZ, bool> container;
ChunkArray<BLK_SZ,bool>* att1 = container.add_attribute<bool>("bools");
Expand All @@ -162,13 +162,13 @@ int test4()
}
}

std::cout << "---> OK" << std::endl;
cgogn_log_info("bench_chunk_array") << "---> OK" ;
return 0;
}

int test5()
{
std::cout << "= TEST 5 = Traversal" << std::endl;
cgogn_log_info("bench_chunk_array") << "= TEST 5 = Traversal" ;

ChunkArrayContainer<BLK_SZ, uint32> container;
ChunkArray<BLK_SZ,uint32>* att1 = container.add_attribute<uint32>("uints");
Expand All @@ -193,15 +193,15 @@ int test5()
total = - total;
}

std::cout << "---> OK " << total << std::endl;
cgogn_log_info("bench_chunk_array") << "---> OK " << total ;
return 0;
}

int main(int argc, char **argv)
{
if (argc == 1)
{
std::cout << " PARAMETER: 1/2 for uint/bool refs; 3/4 for random clear bool; 5 for traversal";
cgogn_log_info("bench_chunk_array") << " PARAMETER: 1/2 for uint/bool refs; 3/4 for random clear bool; 5 for traversal";
return 1;
}

Expand Down
Loading

0 comments on commit aa94e56

Please sign in to comment.