Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: replace iguana::Logger with spdlog #322

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ fmt_dep = dependency(
method: 'pkg-config',
version: '>=' + run_command(prog_minver, 'fmt', check: true).stdout().strip(),
)
spdlog_dep = dependency(
'spdlog',
method: 'pkg-config',
version: '>=1.15',
default_options: {
'compile_library': 'true', ### FIXME: library libspdlog is not being installed, only the headers are
},
)
yamlcpp_dep = dependency(
'yaml-cpp',
method: 'pkg-config',
Expand Down Expand Up @@ -76,7 +84,7 @@ thread_dep = dependency(
# themselves are listed last (see FIXME in meson/this_iguana.sh.in)
# NOTE: omit ROOT (handled differently, and most ROOT users already have it in their environment)
dep_list = []
foreach dep : [ hipo_dep, fmt_dep, yamlcpp_dep, rcdb_dep ]
foreach dep : [ hipo_dep, fmt_dep, spdlog_dep, yamlcpp_dep, rcdb_dep ]
if dep.found()
dep_list += dep
endif
Expand All @@ -98,14 +106,16 @@ foreach dep : dep_list
libdirs += run_command('dirname', lib, check: true).stdout().strip()
endforeach
incdirs = ROOT_dep.get_variable(cmake: 'PACKAGE_INCLUDE_DIRS').split(';')
else
elif dep.type_name() == 'internal'
name = dep.get_variable(internal: 'name', default_value: dep.name())
if name == 'rcdb'
incdirs = [ dep.get_variable(internal: 'includedir') ]
else
warning(f'Unknown dependency "@name@"')
# warning(f'Unknown internal dependency "@name@"')
continue
endif
else
error('Dependency type "' + dep.type_name() + '" is unknown')
endif

# append to `dep_*_dirs` arrays, uniquely
Expand Down Expand Up @@ -241,7 +251,7 @@ pkg.generate(
name: meson.project_name(),
description: project_description,
libraries: project_libs,
requires: [ fmt_dep, yamlcpp_dep, hipo_dep ], # pkg-config dependencies only
requires: [ fmt_dep, yamlcpp_dep, hipo_dep ], # pkg-config dependencies only # FIXME # FIXME # FIXME
variables: project_pkg_vars_nonempty,
)

Expand Down
5 changes: 4 additions & 1 deletion src/iguana/services/Object.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ namespace iguana {
Object::Object(std::string_view name, Logger::Level lev)
: m_name(name)
, m_log(std::make_unique<Logger>(m_name, lev))
{}
, m_spdlog(spdlog::default_logger()->clone(m_name))
{
m_spdlog->set_level(spdlog::level::trace);
}

std::unique_ptr<Logger>& Object::Log()
{
Expand Down
2 changes: 2 additions & 0 deletions src/iguana/services/Object.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <string>

#include "Logger.h"
#include <spdlog/spdlog.h>

namespace iguana {

Expand Down Expand Up @@ -50,5 +51,6 @@ namespace iguana {

/// `Logger` instance for this object
std::unique_ptr<Logger> m_log;
std::shared_ptr<spdlog::logger> m_spdlog;
};
}
13 changes: 13 additions & 0 deletions subprojects/spdlog.wrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[wrap-file]
directory = spdlog-1.15.0
source_url = https://github.com/gabime/spdlog/archive/refs/tags/v1.15.0.tar.gz
source_filename = spdlog-1.15.0.tar.gz
source_hash = 9962648c9b4f1a7bbc76fd8d9172555bad1871fdb14ff4f842ef87949682caa5
patch_filename = spdlog_1.15.0-1_patch.zip
patch_url = https://wrapdb.mesonbuild.com/v2/spdlog_1.15.0-1/get_patch
patch_hash = 72bd578ff0eb4f5a84e5bd63ddc7b2ece84aad5abb516b54c8750306ae78df28
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/spdlog_1.15.0-1/spdlog-1.15.0.tar.gz
wrapdb_version = 1.15.0-1

[provide]
spdlog = spdlog_dep
Loading