DEPRECATED: operator<< API
This commit is contained in:
		
							
								
								
									
										13
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								README.md
									
									
									
									
									
								
							@@ -69,7 +69,6 @@ int main(int, char* [])
 | 
			
		||||
        auto console = spd::stdout_logger_mt("console", true);
 | 
			
		||||
        console->info("Welcome to spdlog!") ;
 | 
			
		||||
        console->info("An info message example {}..", 1);        
 | 
			
		||||
        console->info() << "Streams are supported too  " << 1;
 | 
			
		||||
 | 
			
		||||
        //Formatting examples
 | 
			
		||||
        console->info("Easy padding in numbers like {:08d}", 12);
 | 
			
		||||
@@ -129,7 +128,7 @@ int main(int, char* [])
 | 
			
		||||
        size_t q_size = 8192; //queue size must be power of 2
 | 
			
		||||
        spdlog::set_async_mode(q_size);
 | 
			
		||||
        auto async_file= spd::daily_logger_st("async_file_logger", "logs/async_log.txt");
 | 
			
		||||
        async_file->info() << "This is async log.." << "Should be very fast!";
 | 
			
		||||
        async_file->info("This is async log..Should be very fast!");
 | 
			
		||||
 | 
			
		||||
        //
 | 
			
		||||
        // syslog example. linux only..
 | 
			
		||||
@@ -148,16 +147,6 @@ int main(int, char* [])
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// Example of user defined class with operator<<
 | 
			
		||||
class some_class {};
 | 
			
		||||
std::ostream& operator<<(std::ostream& os, const some_class& c) { return os << "some_class"; }
 | 
			
		||||
 | 
			
		||||
void custom_class_example()
 | 
			
		||||
{
 | 
			
		||||
    some_class c;
 | 
			
		||||
    spdlog::get("console")->info("custom class with operator<<: {}..", c);
 | 
			
		||||
    spdlog::get("console")->info() << "custom class with operator<<: " << c << "..";
 | 
			
		||||
}
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
## Documentation
 | 
			
		||||
 
 | 
			
		||||
@@ -41,7 +41,7 @@ int main(int argc, char* argv[])
 | 
			
		||||
            {
 | 
			
		||||
                int counter = ++msg_counter;
 | 
			
		||||
                if (counter > howmany) break;
 | 
			
		||||
                logger->info() << "spdlog message #" << counter << ": This is some text for your pleasure";
 | 
			
		||||
                logger->info("spdlog message #{}: This is some text for your pleasure", counter);
 | 
			
		||||
            }
 | 
			
		||||
        }));
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -38,7 +38,7 @@ int main(int argc, char* argv[])
 | 
			
		||||
            {
 | 
			
		||||
                int counter = ++msg_counter;
 | 
			
		||||
                if (counter > howmany) break;
 | 
			
		||||
                logger->info() << "spdlog message #" << counter << ": This is some text for your pleasure";
 | 
			
		||||
                logger->info("spdlog message #{}: This is some text for your pleasure", counter);
 | 
			
		||||
            }
 | 
			
		||||
        }));
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -15,6 +15,6 @@ int main(int, char* [])
 | 
			
		||||
 | 
			
		||||
    logger->set_pattern("[%Y-%b-%d %T.%e]: %v");
 | 
			
		||||
    for(int i  = 0 ; i < howmany; ++i)
 | 
			
		||||
        logger->info() << "spdlog message #" << i << ": This is some text for your pleasure";
 | 
			
		||||
        logger->info("spdlog message #{} : This is some text for your pleasure", i);
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -23,7 +23,6 @@ int main(int, char*[])
 | 
			
		||||
        auto console = spd::stdout_logger_mt("console", true);
 | 
			
		||||
        console->info("Welcome to spdlog!");
 | 
			
		||||
        console->info("An info message example {}..", 1);
 | 
			
		||||
        console->info() << "Streams are supported too  " << 1;
 | 
			
		||||
 | 
			
		||||
        // Formatting examples
 | 
			
		||||
        console->info("Easy padding in numbers like {:08d}", 12);
 | 
			
		||||
@@ -55,6 +54,7 @@ int main(int, char*[])
 | 
			
		||||
 | 
			
		||||
        // Create a daily logger - a new file is created every day on 2:30am
 | 
			
		||||
        auto daily_logger = spd::daily_logger_mt("daily_logger", "logs/daily", 2, 30);
 | 
			
		||||
        daily_logger->info(123.44);
 | 
			
		||||
 | 
			
		||||
        // Customize msg format for all messages
 | 
			
		||||
        spd::set_pattern("*** [%H:%M:%S %z] [thread %t] %v ***");
 | 
			
		||||
@@ -107,17 +107,3 @@ void syslog_example()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// Example of user defined class with operator<<
 | 
			
		||||
class some_class {};
 | 
			
		||||
std::ostream& operator<<(std::ostream& os, const some_class&)
 | 
			
		||||
{
 | 
			
		||||
    return os << "some_class";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void custom_class_example()
 | 
			
		||||
{
 | 
			
		||||
    some_class c;
 | 
			
		||||
    spdlog::get("console")->info("custom class with operator<<: {}..", c);
 | 
			
		||||
    spdlog::get("console")->info() << "custom class with operator<<: " << c << "..";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -27,6 +27,14 @@
 | 
			
		||||
#define SPDLOG_CONSTEXPR constexpr
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if defined(__GNUC__)  || defined(__clang__)
 | 
			
		||||
#define DEPRECATED __attribute__((deprecated))
 | 
			
		||||
#elif defined(_MSC_VER)
 | 
			
		||||
#define DEPRECATED __declspec(deprecated)
 | 
			
		||||
#else
 | 
			
		||||
#pragma message("DEPRECATED")
 | 
			
		||||
#define DEPRECATED
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
namespace spdlog
 | 
			
		||||
{
 | 
			
		||||
 
 | 
			
		||||
@@ -49,21 +49,21 @@ public:
 | 
			
		||||
    //
 | 
			
		||||
    // Support for operator<<
 | 
			
		||||
    //
 | 
			
		||||
    line_logger& operator<<(const char* what);
 | 
			
		||||
    line_logger& operator<<(const std::string& what);
 | 
			
		||||
    line_logger& operator<<(int what);
 | 
			
		||||
    line_logger& operator<<(unsigned int what);
 | 
			
		||||
    line_logger& operator<<(long what);
 | 
			
		||||
    line_logger& operator<<(unsigned long what);
 | 
			
		||||
    line_logger& operator<<(long long what);
 | 
			
		||||
    line_logger& operator<<(unsigned long long what);
 | 
			
		||||
    line_logger& operator<<(double what);
 | 
			
		||||
    line_logger& operator<<(long double what);
 | 
			
		||||
    line_logger& operator<<(float what);
 | 
			
		||||
    line_logger& operator<<(char what);
 | 
			
		||||
    DEPRECATED line_logger& operator<<(const char* what);
 | 
			
		||||
    DEPRECATED line_logger& operator<<(const std::string& what);
 | 
			
		||||
    DEPRECATED line_logger& operator<<(int what);
 | 
			
		||||
    DEPRECATED line_logger& operator<<(unsigned int what);
 | 
			
		||||
    DEPRECATED line_logger& operator<<(long what);
 | 
			
		||||
    DEPRECATED line_logger& operator<<(unsigned long what);
 | 
			
		||||
    DEPRECATED line_logger& operator<<(long long what);
 | 
			
		||||
    DEPRECATED line_logger& operator<<(unsigned long long what);
 | 
			
		||||
    DEPRECATED line_logger& operator<<(double what);
 | 
			
		||||
    DEPRECATED line_logger& operator<<(long double what);
 | 
			
		||||
    DEPRECATED line_logger& operator<<(float what);
 | 
			
		||||
    DEPRECATED line_logger& operator<<(char what);
 | 
			
		||||
    //Support user types which implements operator<<
 | 
			
		||||
    template<typename T>
 | 
			
		||||
    line_logger& operator<<(const T& what);
 | 
			
		||||
    DEPRECATED line_logger& operator<<(const T& what);
 | 
			
		||||
 | 
			
		||||
    void disable();
 | 
			
		||||
    bool is_enabled() const;
 | 
			
		||||
 
 | 
			
		||||
@@ -74,7 +74,7 @@ inline spdlog::details::line_logger spdlog::logger::_log_if_enabled(level::level
 | 
			
		||||
{
 | 
			
		||||
    bool msg_enabled = should_log(lvl);
 | 
			
		||||
    details::line_logger l(this, lvl, msg_enabled);
 | 
			
		||||
    l << msg;
 | 
			
		||||
    l.write("{}", msg);
 | 
			
		||||
    return l;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -11,7 +11,7 @@ std::string log_info(const T& what, spdlog::level::level_enum logger_level = spd
 | 
			
		||||
    spdlog::logger oss_logger("oss", oss_sink);
 | 
			
		||||
    oss_logger.set_level(logger_level);
 | 
			
		||||
    oss_logger.set_pattern("%v");
 | 
			
		||||
    oss_logger.info() << what;
 | 
			
		||||
    oss_logger.info(what);
 | 
			
		||||
 | 
			
		||||
    return oss.str().substr(0, oss.str().length() - spdlog::details::os::eol_size);
 | 
			
		||||
}
 | 
			
		||||
@@ -21,19 +21,6 @@ std::string log_info(const T& what, spdlog::level::level_enum logger_level = spd
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
//User defined class with operator<<
 | 
			
		||||
struct some_logged_class
 | 
			
		||||
{
 | 
			
		||||
    some_logged_class(const std::string val) :value(val) {};
 | 
			
		||||
    std::string value;
 | 
			
		||||
};
 | 
			
		||||
std::ostream& operator<<(std::ostream& os, const some_logged_class& c)
 | 
			
		||||
{
 | 
			
		||||
    return os << c.value;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
TEST_CASE("basic_logging ", "[basic_logging]")
 | 
			
		||||
{
 | 
			
		||||
    //const char
 | 
			
		||||
@@ -49,7 +36,7 @@ TEST_CASE("basic_logging ", "[basic_logging]")
 | 
			
		||||
    REQUIRE(log_info(5.6) == "5.6");
 | 
			
		||||
 | 
			
		||||
    //User defined class
 | 
			
		||||
    REQUIRE(log_info(some_logged_class("some_val")) == "some_val");
 | 
			
		||||
    //REQUIRE(log_info(some_logged_class("some_val")) == "some_val");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -26,7 +26,7 @@
 | 
			
		||||
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
 | 
			
		||||
    <ConfigurationType>Application</ConfigurationType>
 | 
			
		||||
    <UseDebugLibraries>true</UseDebugLibraries>
 | 
			
		||||
    <PlatformToolset>v140</PlatformToolset>
 | 
			
		||||
    <PlatformToolset>v120</PlatformToolset>
 | 
			
		||||
    <CharacterSet>MultiByte</CharacterSet>
 | 
			
		||||
  </PropertyGroup>
 | 
			
		||||
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
 | 
			
		||||
@@ -38,7 +38,7 @@
 | 
			
		||||
  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
 | 
			
		||||
    <ConfigurationType>Application</ConfigurationType>
 | 
			
		||||
    <UseDebugLibraries>false</UseDebugLibraries>
 | 
			
		||||
    <PlatformToolset>v140</PlatformToolset>
 | 
			
		||||
    <PlatformToolset>v120</PlatformToolset>
 | 
			
		||||
    <WholeProgramOptimization>true</WholeProgramOptimization>
 | 
			
		||||
    <CharacterSet>MultiByte</CharacterSet>
 | 
			
		||||
  </PropertyGroup>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user