Fixed logging levels

This commit is contained in:
Bartek Kryza
2021-03-14 23:27:53 +01:00
parent c5beac2bd2
commit 5a5652a443
19 changed files with 57 additions and 76 deletions

View File

@@ -261,7 +261,7 @@ template <> struct convert<config> {
rhs.diagrams[name] = std::make_shared<class_diagram>(
d.second.as<class_diagram>());
}
if (diagram_type == "sequence") {
else if (diagram_type == "sequence") {
rhs.diagrams[name] = std::make_shared<sequence_diagram>(
d.second.as<sequence_diagram>());
}

View File

@@ -164,7 +164,7 @@ clanguml::model::sequence_diagram::diagram generate(
auto cursor = clang_getTranslationUnitCursor(tu);
if (clang_Cursor_isNull(cursor)) {
spdlog::debug("CURSOR IS NULL");
spdlog::debug("Cursor is NULL");
}
spdlog::debug("Cursor kind: {}",

View File

@@ -178,14 +178,14 @@ static enum CXChildVisitResult enum_visitor(
cx::cursor cursor{std::move(cx_cursor)};
cx::cursor parent{std::move(cx_parent)};
spdlog::info("Visiting enum {}: {} - {}:{}", ctx->element.name,
spdlog::debug("Visiting enum {}: {} - {}:{}", ctx->element.name,
cursor.spelling(), cursor.kind());
enum CXChildVisitResult ret = CXChildVisit_Break;
switch (cursor.kind()) {
case CXCursor_EnumConstantDecl:
visit_if_cursor_valid(cursor, [ctx](cx::cursor cursor) {
spdlog::info("Adding enum constant {}::{}", ctx->element.name,
spdlog::debug("Adding enum constant {}::{}", ctx->element.name,
cursor.spelling());
ctx->element.constants.emplace_back(cursor.spelling());
@@ -209,7 +209,7 @@ static enum CXChildVisitResult friend_class_visitor(
cx::cursor cursor{std::move(cx_cursor)};
cx::cursor parent{std::move(cx_parent)};
spdlog::info("Visiting friend class declaration {}: {} - {}:{}",
spdlog::debug("Visiting friend class declaration {}: {} - {}:{}",
ctx->element.name, cursor.spelling(), cursor.kind(),
cursor.referenced());
@@ -218,7 +218,7 @@ static enum CXChildVisitResult friend_class_visitor(
case CXCursor_TemplateRef:
case CXCursor_ClassTemplate:
case CXCursor_TypeRef: {
spdlog::info("Analyzing friend declaration: {}, {}", cursor,
spdlog::debug("Analyzing friend declaration: {}, {}", cursor,
cursor.specialized_cursor_template());
if (!ctx->ctx->config.should_include(
@@ -254,7 +254,7 @@ static enum CXChildVisitResult class_visitor(
std::string cursor_name_str = cursor.spelling();
spdlog::info("Visiting {}: {} - {}",
spdlog::debug("Visiting {}: {} - {}",
ctx->element.is_struct ? "struct" : "class", ctx->element.name, cursor);
auto &config = ctx->ctx->config;
@@ -280,7 +280,7 @@ static enum CXChildVisitResult class_visitor(
c.name = cursor.fully_qualified();
c.namespace_ = ctx->ctx->namespace_;
spdlog::info("Class {} has {} template arguments.", c.name,
spdlog::debug("Class {} has {} template arguments.", c.name,
cursor.template_argument_count());
auto class_ctx =
@@ -294,7 +294,7 @@ static enum CXChildVisitResult class_visitor(
containment.destination = c.name;
ctx->element.relationships.emplace_back(std::move(containment));
spdlog::info(
spdlog::debug(
"Added relationship {} +-- {}", ctx->element.name, c.name);
ctx->ctx->d.classes.emplace_back(std::move(c));
@@ -322,7 +322,7 @@ static enum CXChildVisitResult class_visitor(
containment.destination = e.name;
ctx->element.relationships.emplace_back(std::move(containment));
spdlog::info(
spdlog::debug(
"Added relationship {} +-- {}", ctx->element.name, e.name);
ctx->ctx->d.enums.emplace_back(std::move(e));
@@ -330,8 +330,9 @@ static enum CXChildVisitResult class_visitor(
ret = CXChildVisit_Continue;
break;
case CXCursor_TemplateTypeParameter: {
spdlog::info("Found template type parameter: {}: {}, isvariadic={}",
cursor, cursor.type(), cursor.is_template_parameter_variadic());
spdlog::debug(
"Found template type parameter: {}: {}, isvariadic={}", cursor,
cursor.type(), cursor.is_template_parameter_variadic());
class_template ct;
ct.type = "";
@@ -345,7 +346,7 @@ static enum CXChildVisitResult class_visitor(
ret = CXChildVisit_Continue;
} break;
case CXCursor_NonTypeTemplateParameter: {
spdlog::info(
spdlog::debug(
"Found template nontype parameter: {}: {}, isvariadic={}",
cursor.spelling(), cursor.type(),
cursor.is_template_parameter_variadic());
@@ -362,7 +363,7 @@ static enum CXChildVisitResult class_visitor(
ret = CXChildVisit_Continue;
} break;
case CXCursor_TemplateTemplateParameter: {
spdlog::info("Found template template parameter: {}: {}",
spdlog::debug("Found template template parameter: {}: {}",
cursor.spelling(), cursor.type());
class_template ct;
@@ -394,7 +395,7 @@ static enum CXChildVisitResult class_visitor(
m.scope =
cx_access_specifier_to_scope(cursor.cxxaccess_specifier());
spdlog::info("Adding method {} {}::{}()", m.type,
spdlog::debug("Adding method {} {}::{}()", m.type,
ctx->element.name, cursor.spelling());
ctx->element.methods.emplace_back(std::move(m));
@@ -422,7 +423,7 @@ static enum CXChildVisitResult class_visitor(
cursor.cxxaccess_specifier());
m.is_static = cursor.is_static();
spdlog::info("Adding member {} {}::{} {}, {}, {}", m.type,
spdlog::debug("Adding member {} {}::{} {}, {}, {}", m.type,
ctx->element.name, cursor.spelling(), t, tr,
tr.type_declaration());
@@ -443,7 +444,7 @@ static enum CXChildVisitResult class_visitor(
template_type = tr.type_declaration();
}
spdlog::info(
spdlog::debug(
"Found template instantiation: {} ..|> {}", tr,
template_type);
@@ -472,7 +473,7 @@ static enum CXChildVisitResult class_visitor(
ct.type = template_param;
tinst.templates.emplace_back(std::move(ct));
spdlog::info("Adding template argument '{}'",
spdlog::debug("Adding template argument '{}'",
template_param);
}
@@ -519,7 +520,7 @@ static enum CXChildVisitResult class_visitor(
// relationship type Skip:
// - POD
// - function variables
spdlog::info(
spdlog::debug(
"Analyzing possible relationship candidate: {}",
t.canonical().unqualified());
@@ -544,7 +545,7 @@ static enum CXChildVisitResult class_visitor(
ctx->element.relationships.emplace_back(
std::move(r));
spdlog::info("Added relationship to: {}",
spdlog::debug("Added relationship to: {}",
r.destination);
}
}
@@ -557,7 +558,7 @@ static enum CXChildVisitResult class_visitor(
break;
}
case CXCursor_ClassTemplatePartialSpecialization: {
spdlog::info("Found template specialization: {}", cursor);
spdlog::debug("Found template specialization: {}", cursor);
ret = CXChildVisit_Continue;
} break;
case CXCursor_CXXBaseSpecifier: {
@@ -571,7 +572,7 @@ static enum CXChildVisitResult class_visitor(
auto base_access = cursor.cxxaccess_specifier();
spdlog::info(
spdlog::debug(
"Found base specifier: {} - {}", cursor_name_str, display_name);
class_parent cp;
@@ -636,7 +637,7 @@ static enum CXChildVisitResult translation_unit_visitor(
case CXCursor_ClassTemplate:
[[fallthrough]];
case CXCursor_ClassDecl: {
spdlog::info(
spdlog::debug(
"Found class or class template declaration: {}", cursor);
if (!ctx->config.should_include(cursor.fully_qualified())) {
ret = CXChildVisit_Continue;

View File

@@ -53,21 +53,9 @@ struct diagram {
bool started{false};
std::string name;
// std::map<std::string, activity> sequences;
std::map<std::string, activity> sequences;
void sort()
{
/*
std::sort(sequence.begin(), sequence.end(),
[](const auto &a, const auto &b) -> bool {
if (a.from_usr == b.from_usr)
return a.line > b.line;
return a.from_usr > b.from_usr;
});
*/
}
void sort() {}
};
}
}

View File

@@ -16,10 +16,8 @@
* limitations under the License.
*/
TEST_CASE("Test t00002", "[unit-test]")
TEST_CASE("t00002", "[unit-test]")
{
spdlog::set_level(spdlog::level::debug);
auto [config, db] = load_config("t00002");
auto diagram = config.diagrams["t00002_class"];

View File

@@ -16,10 +16,8 @@
* limitations under the License.
*/
TEST_CASE("Test t00003", "[unit-test]")
TEST_CASE("t00003", "[unit-test]")
{
spdlog::set_level(spdlog::level::debug);
auto [config, db] = load_config("t00003");
auto diagram = config.diagrams["t00003_class"];

View File

@@ -16,10 +16,8 @@
* limitations under the License.
*/
TEST_CASE("Test t00004", "[unit-test]")
TEST_CASE("t00004", "[unit-test]")
{
spdlog::set_level(spdlog::level::debug);
auto [config, db] = load_config("t00004");
auto diagram = config.diagrams["t00004_class"];

View File

@@ -16,10 +16,8 @@
* limitations under the License.
*/
TEST_CASE("Test t00005", "[unit-test]")
TEST_CASE("t00005", "[unit-test]")
{
spdlog::set_level(spdlog::level::debug);
auto [config, db] = load_config("t00005");
auto diagram = config.diagrams["t00005_class"];

View File

@@ -16,10 +16,8 @@
* limitations under the License.
*/
TEST_CASE("Test t00006", "[unit-test]")
TEST_CASE("t00006", "[unit-test]")
{
spdlog::set_level(spdlog::level::debug);
auto [config, db] = load_config("t00006");
auto diagram = config.diagrams["t00006_class"];

View File

@@ -16,10 +16,8 @@
* limitations under the License.
*/
TEST_CASE("Test t00007", "[unit-test]")
TEST_CASE("t00007", "[unit-test]")
{
spdlog::set_level(spdlog::level::debug);
auto [config, db] = load_config("t00007");
auto diagram = config.diagrams["t00007_class"];

View File

@@ -16,10 +16,8 @@
* limitations under the License.
*/
TEST_CASE("Test t00008", "[unit-test]")
TEST_CASE("t00008", "[unit-test]")
{
spdlog::set_level(spdlog::level::debug);
auto [config, db] = load_config("t00008");
auto diagram = config.diagrams["t00008_class"];

View File

@@ -16,10 +16,8 @@
* limitations under the License.
*/
TEST_CASE("Test t00009", "[unit-test]")
TEST_CASE("t00009", "[unit-test]")
{
spdlog::set_level(spdlog::level::debug);
auto [config, db] = load_config("t00009");
auto diagram = config.diagrams["t00009_class"];

View File

@@ -16,10 +16,8 @@
* limitations under the License.
*/
TEST_CASE("Test t00010", "[unit-test]")
TEST_CASE("t00010", "[unit-test]")
{
spdlog::set_level(spdlog::level::debug);
auto [config, db] = load_config("t00010");
auto diagram = config.diagrams["t00010_class"];

View File

@@ -16,10 +16,8 @@
* limitations under the License.
*/
TEST_CASE("Test t00011", "[unit-test]")
TEST_CASE("t00011", "[unit-test]")
{
spdlog::set_level(spdlog::level::debug);
auto [config, db] = load_config("t00011");
auto diagram = config.diagrams["t00011_class"];

View File

@@ -16,10 +16,8 @@
* limitations under the License.
*/
TEST_CASE("Test t00012", "[unit-test]")
TEST_CASE("t00012", "[unit-test]")
{
spdlog::set_level(spdlog::level::debug);
auto [config, db] = load_config("t00012");
auto diagram = config.diagrams["t00012_class"];

View File

@@ -16,10 +16,8 @@
* limitations under the License.
*/
TEST_CASE("Test t20001", "[unit-test]")
TEST_CASE("t20001", "[unit-test]")
{
spdlog::set_level(spdlog::level::debug);
auto [config, db] = load_config("t20001");
auto diagram = config.diagrams["t20001_sequence"];

View File

@@ -16,10 +16,8 @@
* limitations under the License.
*/
TEST_CASE("Test t90000", "[unit-test]")
TEST_CASE("t90000", "[unit-test]")
{
spdlog::set_level(spdlog::level::debug);
auto [config, db] = load_config("t90000");
auto diagram = config.diagrams["t90000_class"];

View File

@@ -15,10 +15,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#define CATCH_CONFIG_MAIN
//#define CATCH_CONFIG_MAIN
#include "test_cases.h"
#include <spdlog/spdlog.h>
std::pair<clanguml::config::config, compilation_database> load_config(
const std::string &test_name)
{
@@ -137,3 +139,15 @@ using clanguml::test::matchers::Static;
// Other tests (e.g. configuration file)
//
#include "t90000/test_case.h"
//
// Main test function
//
int main(int argc, char *argv[])
{
spdlog::default_logger_raw()->set_level(spdlog::level::debug);
int result = Catch::Session().run(argc, argv);
return result;
}

View File

@@ -17,6 +17,8 @@
*/
#pragma once
#define SPDLOG_ACTIVE_LEVEL SPDLOG_LEVEL_DEBUG
#include "config/config.h"
#include "cx/compilation_database.h"
#include "puml/class_diagram_generator.h"
@@ -26,6 +28,8 @@
#include "uml/sequence_diagram_visitor.h"
#include "util/util.h"
#define CATCH_CONFIG_RUNNER
#include "catch.h"
#include <complex>