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

Add logr v0.7.0 #21575

Merged
merged 21 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
2 changes: 2 additions & 0 deletions recipes/logr/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
versions:
"0.7.0":
folder: v0.7
"0.6.0":
folder: all
"0.5.1":
Expand Down
4 changes: 4 additions & 0 deletions recipes/logr/v0.7/conandata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sources:
"0.7.0":
url: "https://github.com/ngrodzitski/logr/archive/v0.7.0.tar.gz"
sha256: "b43b6624a9223bcb0a11c83afb3df69ef4388d42abef9abb1b80fbc85b890287"
115 changes: 115 additions & 0 deletions recipes/logr/v0.7/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
from conan import ConanFile
from conan.tools.build import check_min_cppstd
from conan.tools.files import get, copy,rm
from conan.tools.layout import basic_layout
from conan.tools.scm import Version
from conan.errors import ConanInvalidConfiguration
from conan.tools.microsoft import check_min_vs, is_msvc
import os

required_conan_version = ">=1.50.0"

class LogrConan(ConanFile):
name = "logr"
description = (
"Logger frontend substitution for spdlog, glog, etc "
"for server/desktop applications"
)
license = "BSD-3-Clause"
url = "https://github.com/conan-io/conan-center-index"
homepage = "https://github.com/ngrodzitski/logr"
topics = ("logger", "development", "util", "utils")
AbrilRBS marked this conversation as resolved.
Show resolved Hide resolved
settings = "os", "arch", "compiler", "build_type"
uilianries marked this conversation as resolved.
Show resolved Hide resolved
options = {
"backend": ["spdlog", "glog", "log4cplus", "boostlog", None],
}
default_options = {
"backend": "spdlog",
}
ngrodzitski marked this conversation as resolved.
Show resolved Hide resolved

def layout(self):
basic_layout(self, src_folder="src")

def requirements(self):
self.requires("fmt/10.1.1")

if self.options.backend == "spdlog":
self.requires("spdlog/1.12.0")
elif self.options.backend == "glog":
self.requires("glog/0.6.0")
elif self.options.backend == "log4cplus":
self.requires("log4cplus/2.1.0")
elif self.options.backend == "boostlog":
self.requires("boost/1.83.0")

def package_id(self):
self.info.clear()
ngrodzitski marked this conversation as resolved.
Show resolved Hide resolved

def validate(self):
minimal_cpp_standard = "17"
if self.settings.get_safe("compiler.cppstd"):
check_min_cppstd(self, minimal_cpp_standard)
minimal_version = {
"gcc": "10",
"clang": "11",
"apple-clang": "12",
}
check_min_vs(self, 192)
if not is_msvc(self):
minimum_version = minimal_version.get(str(self.settings.compiler), False)
if minimum_version and Version(self.settings.compiler.version) < minimum_version:
raise ConanInvalidConfiguration(
f"{self.ref} requires minimum {self.settings.compiler}-{minimum_version}."
)

def build(self):
pass

def source(self):
get(self, **self.conan_data["sources"][self.version],
destination=self.source_folder, strip_root=True)

def package(self):
copy(self, "LICENSE", src=self.source_folder, dst=os.path.join(self.package_folder, "licenses"))
copy(self, "*.*pp", src=os.path.join(self.source_folder, "logr", "include"), dst=os.path.join(self.package_folder, "include"))

for back in ["spdlog", "glog", "log4cplus", "boostlog"]:
if self.options.backend != back:
rm(self, f"include/logr/{back}_backend.hpp", self.package_folder)

def package_info(self):
self.cpp_info.bindirs = []
self.cpp_info.frameworkdirs = []
self.cpp_info.libdirs = []
self.cpp_info.set_property("cmake_file_name", "logr")

self.cpp_info.names["cmake_find_package"] = "logr"
self.cpp_info.names["cmake_find_package_multi"] = "logr"
ngrodzitski marked this conversation as resolved.
Show resolved Hide resolved

self.cpp_info.components["logr_base"].includedirs = ["include"]
self.cpp_info.components["logr_base"].requires = ["fmt::fmt"]

if self.options.backend == "spdlog":
self.cpp_info.components["logr_spdlog"].includedirs = []
self.cpp_info.components["logr_spdlog"].requires = [
"logr_base",
"spdlog::spdlog",
]
elif self.options.backend == "glog":
self.cpp_info.components["logr_glog"].includedirs = []
self.cpp_info.components["logr_glog"].requires = [
"logr_base",
"glog::glog",
]
elif self.options.backend == "log4cplus":
self.cpp_info.components["logr_log4cplus"].includedirs = []
self.cpp_info.components["logr_log4cplus"].requires = [
"logr_base",
"log4cplus::log4cplus",
]
elif self.options.backend == "boostlog":
self.cpp_info.components["logr_boostlog"].includedirs = []
self.cpp_info.components["logr_boostlog"].requires = [
"logr_base",
"boost::log",
]
8 changes: 8 additions & 0 deletions recipes/logr/v0.7/test_package/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.8)
project(test_package LANGUAGES CXX)

find_package(logr REQUIRED)

add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE logr::logr)
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)
25 changes: 25 additions & 0 deletions recipes/logr/v0.7/test_package/conanfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from conan import ConanFile
from conan.tools.build import can_run
from conan.tools.cmake import cmake_layout, CMake
import os

class TestPackageConan(ConanFile):
settings = "os", "arch", "compiler", "build_type"
generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv"
test_type = "explicit"

def requirements(self):
self.requires(self.tested_reference_str)

def layout(self):
cmake_layout(self)

def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()

def test(self):
if can_run(self):
bin_path = os.path.join(self.cpp.build.bindir, "test_package")
self.run(bin_path, env="conanrun")
31 changes: 31 additions & 0 deletions recipes/logr/v0.7/test_package/test_package.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include <iostream>

#include <spdlog/sinks/stdout_sinks.h>

#include <logr/version.hpp>
#include <logr/spdlog_backend.hpp>

auto make_logger()
{
auto sink = std::make_shared< spdlog::sinks::stdout_sink_st >();
sink->set_pattern("[%Y-%m-%d %T][%n][%l] %v [%g]");

return logr::spdlog_logger_t<>{
"console",
std::move( sink ),
logr::log_message_level::trace
};
}

int main()
{
auto logger = make_logger();

logger.info( []( auto & out ){
format_to( out,
"Welcome to logr (v{}.{}.{}), package is provided by Conan!",
LOGR_VERSION_MAJOR,
LOGR_VERSION_MINOR,
LOGR_VERSION_PATCH );
} );
}