|
| 1 | +/* |
| 2 | + * Copyright (c) 2019 - 2022 Geode-solutions |
| 3 | + * |
| 4 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 5 | + * of this software and associated documentation files (the "Software"), to deal |
| 6 | + * in the Software without restriction, including without limitation the rights |
| 7 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 8 | + * copies of the Software, and to permit persons to whom the Software is |
| 9 | + * furnished to do so, subject to the following conditions: |
| 10 | + * |
| 11 | + * The above copyright notice and this permission notice shall be included in |
| 12 | + * all copies or substantial portions of the Software. |
| 13 | + * |
| 14 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 15 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 16 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 17 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 18 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 19 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 20 | + * SOFTWARE. |
| 21 | + * |
| 22 | + */ |
| 23 | + |
| 24 | +#include <geode/basic/console_logger_client.h> |
| 25 | + |
| 26 | +// clang-format off |
| 27 | +#include <spdlog/spdlog.h> |
| 28 | +#include <spdlog/sinks/stdout_color_sinks.h> |
| 29 | +// clang-format on |
| 30 | + |
| 31 | +#include <geode/basic/logger.h> |
| 32 | +#include <geode/basic/pimpl_impl.h> |
| 33 | + |
| 34 | +namespace geode |
| 35 | +{ |
| 36 | + class ConsoleLoggerClient::Impl |
| 37 | + { |
| 38 | + public: |
| 39 | + Impl() : logger_impl_( spdlog::stdout_color_mt( "console" ) ) |
| 40 | + { |
| 41 | + spdlog::set_level( spdlog::level::level_enum::trace ); |
| 42 | + } |
| 43 | + |
| 44 | + void trace( const std::string &message ) |
| 45 | + { |
| 46 | + logger_impl_->trace( message ); |
| 47 | + } |
| 48 | + |
| 49 | + void debug( const std::string &message ) |
| 50 | + { |
| 51 | + logger_impl_->debug( message ); |
| 52 | + } |
| 53 | + |
| 54 | + void info( const std::string &message ) |
| 55 | + { |
| 56 | + logger_impl_->info( message ); |
| 57 | + } |
| 58 | + |
| 59 | + void warn( const std::string &message ) |
| 60 | + { |
| 61 | + logger_impl_->warn( message ); |
| 62 | + } |
| 63 | + |
| 64 | + void error( const std::string &message ) |
| 65 | + { |
| 66 | + logger_impl_->error( message ); |
| 67 | + } |
| 68 | + |
| 69 | + void critical( const std::string &message ) |
| 70 | + { |
| 71 | + logger_impl_->critical( message ); |
| 72 | + } |
| 73 | + |
| 74 | + private: |
| 75 | + std::shared_ptr< spdlog::logger > logger_impl_; |
| 76 | + }; |
| 77 | + |
| 78 | + ConsoleLoggerClient::ConsoleLoggerClient() {} |
| 79 | + |
| 80 | + ConsoleLoggerClient::~ConsoleLoggerClient() {} |
| 81 | + |
| 82 | + void ConsoleLoggerClient::trace( const std::string &message ) |
| 83 | + { |
| 84 | + impl_->trace( message ); |
| 85 | + } |
| 86 | + |
| 87 | + void ConsoleLoggerClient::debug( const std::string &message ) |
| 88 | + { |
| 89 | + impl_->debug( message ); |
| 90 | + } |
| 91 | + |
| 92 | + void ConsoleLoggerClient::info( const std::string &message ) |
| 93 | + { |
| 94 | + impl_->info( message ); |
| 95 | + } |
| 96 | + |
| 97 | + void ConsoleLoggerClient::warn( const std::string &message ) |
| 98 | + { |
| 99 | + impl_->warn( message ); |
| 100 | + } |
| 101 | + |
| 102 | + void ConsoleLoggerClient::error( const std::string &message ) |
| 103 | + { |
| 104 | + impl_->error( message ); |
| 105 | + } |
| 106 | + |
| 107 | + void ConsoleLoggerClient::critical( const std::string &message ) |
| 108 | + { |
| 109 | + impl_->critical( message ); |
| 110 | + } |
| 111 | +} // namespace geode |
0 commit comments