-
Notifications
You must be signed in to change notification settings - Fork 2k
Add logr v0.7.0 #21575
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
Merged
conan-center-bot
merged 21 commits into
conan-io:master
from
ngrodzitski:update-logr-v0.7.0
May 29, 2024
Merged
Add logr v0.7.0 #21575
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
58ca991
Add logr v0.7.0
ngrodzitski 2cecaea
Merge branch 'master' into update-logr-v0.7.0
ngrodzitski e5600e7
Merge branch 'master' into update-logr-v0.7.0
ngrodzitski b984277
Merge branch 'master' into update-logr-v0.7.0
ngrodzitski ea4a451
Merge branch 'master' into update-logr-v0.7.0
ngrodzitski 9910d93
Merge branch 'master' into update-logr-v0.7.0
ngrodzitski fdd2b49
Add header-only attribute to logr
ngrodzitski 95277ec
Merge branch 'master' into update-logr-v0.7.0
ngrodzitski 082eca5
Merge branch 'master' into update-logr-v0.7.0
ngrodzitski 60f834c
Make fmt version flexible
ngrodzitski 229f959
Update recipes/logr/v0.7/conanfile.py
ngrodzitski 5c237fe
Change backend options arrangement
ngrodzitski 9714560
Update recipes/logr/v0.7/conanfile.py
ngrodzitski c32db33
Update recipes/logr/v0.7/conanfile.py
ngrodzitski d166805
Update recipes/logr/v0.7/conanfile.py
ngrodzitski 2b60d0d
Update recipes/logr/v0.7/conanfile.py
ngrodzitski 21702e8
Update recipes/logr/v0.7/conanfile.py
AbrilRBS c1fc66e
Apply suggestions from code review
AbrilRBS 8ebb463
Switch to `with_xxx` dependency definition
ngrodzitski fa5d579
Fix test_package
AbrilRBS 289732e
Simplify test_package
AbrilRBS File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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": | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
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 | ||
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", "header-only") | ||
settings = "os", "arch", "compiler", "build_type" | ||
package_type = "header-library" | ||
options = { | ||
"with_spdlog": [True, False], | ||
"with_glog": [True, False], | ||
"with_log4cplus": [True, False], | ||
"with_boostlog": [True, False], | ||
} | ||
default_options = { | ||
"with_spdlog": True, | ||
"with_glog": False, | ||
"with_log4cplus": False, | ||
"with_boostlog": False, | ||
} | ||
|
||
@property | ||
def _min_cppstd(self): | ||
return 17 | ||
|
||
@property | ||
def _minimum_compilers_version(self): | ||
return { | ||
"gcc": "10", | ||
"clang": "11", | ||
"apple-clang": "12", | ||
} | ||
|
||
def layout(self): | ||
basic_layout(self, src_folder="src") | ||
|
||
def requirements(self): | ||
self.requires("fmt/10.2.1") | ||
|
||
if self.options.with_spdlog: | ||
self.requires("spdlog/1.12.0") | ||
|
||
if self.options.with_glog: | ||
self.requires("glog/0.6.0") | ||
|
||
if self.options.with_log4cplus: | ||
self.requires("log4cplus/2.1.0") | ||
|
||
if self.options.with_boostlog: | ||
self.requires("boost/1.83.0") | ||
|
||
def package_id(self): | ||
self.info.settings.clear() | ||
|
||
def validate(self): | ||
if self.settings.get_safe("compiler.cppstd"): | ||
check_min_cppstd(self, self._min_cppstd) | ||
|
||
check_min_vs(self, 192) | ||
|
||
minimum_version = self._minimum_compilers_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} version of {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")) | ||
|
||
include_folder = os.path.join(self.package_folder, "include", "logr") | ||
if not self.options.with_spdlog: | ||
rm(self, "spdlog_backend.hpp", include_folder) | ||
|
||
if not self.options.with_glog: | ||
rm(self, "glog_backend.hpp", include_folder) | ||
|
||
if not self.options.with_log4cplus: | ||
rm(self, "log4cplus_backend.hpp", include_folder) | ||
|
||
if not self.options.with_boostlog: | ||
rm(self, "boostlog_backend.hpp", include_folder) | ||
|
||
def package_info(self): | ||
self.cpp_info.bindirs = [] | ||
self.cpp_info.libdirs = [] | ||
|
||
self.cpp_info.components["logr_base"].includedirs = ["include"] | ||
self.cpp_info.components["logr_base"].requires = ["fmt::fmt"] | ||
|
||
if self.options.with_spdlog: | ||
self.cpp_info.components["logr_spdlog"].includedirs = [] | ||
self.cpp_info.components["logr_spdlog"].requires = [ | ||
"logr_base", | ||
"spdlog::spdlog", | ||
] | ||
|
||
if self.options.with_glog: | ||
self.cpp_info.components["logr_glog"].includedirs = [] | ||
self.cpp_info.components["logr_glog"].requires = [ | ||
"logr_base", | ||
"glog::glog", | ||
] | ||
|
||
if self.options.with_log4cplus: | ||
self.cpp_info.components["logr_log4cplus"].includedirs = [] | ||
self.cpp_info.components["logr_log4cplus"].requires = [ | ||
"logr_base", | ||
"log4cplus::log4cplus", | ||
] | ||
|
||
if self.options.with_boostlog: | ||
self.cpp_info.components["logr_boostlog"].includedirs = [] | ||
self.cpp_info.components["logr_boostlog"].requires = [ | ||
"logr_base", | ||
"boost::log", | ||
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Logger frontend library for C++. | ||
// | ||
// Copyright (c) 2020 - present, Nicolai Grodzitski | ||
// See LICENSE file in the root of the project. | ||
|
||
|
||
#include <iostream> | ||
|
||
#include <logr/logr.hpp> | ||
#include <logr/ostream_backend.hpp> | ||
|
||
|
||
int main() { | ||
auto logger = logr::basic_ostream_logger_t<1024u>(std::cout); | ||
|
||
logger.info( "Hello World! [raw message]" ); | ||
logger.info( LOGR_SRC_LOCATION, "Hello World! [raw message]" ); | ||
|
||
logger.info( []() { return "Hello World! [cb]"; } ); | ||
logger.info( LOGR_SRC_LOCATION, []() { return "Hello World! [cb]"; } ); | ||
|
||
logger.info( []( auto out ) { | ||
format_to( out, "Hello {}! [{}]", "World", "cb with explicit out" ); | ||
} ); | ||
|
||
logger.info( LOGR_SRC_LOCATION, []( auto out ) { | ||
format_to( out, "Hello {}! [{}]", "World", "cb with explicit out" ); | ||
} ); | ||
logger.info( LOGR_SRC_LOCATION, []( auto out ) { | ||
format_to( out, | ||
FMT_STRING( "Hello {}! [{}]" ), | ||
"World", | ||
"cb with explicit out and FMT_STRING" ); | ||
} ); | ||
|
||
logger.info( LOGR_SRC_LOCATION, []( auto out ) { | ||
format_to( out, | ||
fmt::runtime( "Hello {}! [{}]" ), | ||
"World", | ||
"cb with explicit out and runtime-string" ); | ||
} ); | ||
|
||
logger.flush(); | ||
|
||
return 0; | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.