Commit a047b58e authored by gabime's avatar gabime

Added "basic_logger_mt/basic_logger_st" to the API

parent cef7eb06
......@@ -88,6 +88,13 @@ int main(int, char* [])
console->debug("This message shold not be displayed!");
console->set_level(spd::level::debug); // Set specific logger's log level
console->debug("Now it should..");
//
// Create a basic file logger (multithreaded, use "file_logger_st" for single threaded logger)
//
auto simple_logger = spd::file_logger_mt("basic_logger", "logs/simple.txt");
simple_logger->info("Some log message");
//
// Create a file rotating logger with 5mb size max and 3 rotated files
......
......@@ -43,6 +43,11 @@ int main(int, char*[])
console->set_level(spd::level::debug); // Set specific logger's log level
console->debug("This message shold be displayed..");
// Create basic file logger (not rotated)
auto simple_logger = spd::basic_logger_mt("basic_logger", "logs/simple.txt");
simple_logger->info("Some log message");
// Create a file rotating logger with 5mb size max and 3 rotated files
auto file_logger = spd::rotating_logger_mt("file_logger", "logs/mylogfile", 1048576 * 5, 3);
for (int i = 0; i < 10; ++i)
......
......@@ -22,13 +22,13 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset>v120</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<PlatformToolset>v120</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
......
......@@ -35,6 +35,17 @@ inline void spdlog::drop(const std::string &name)
details::registry::instance().drop(name);
}
// Create multi/single threaded simple file logger
inline std::shared_ptr<spdlog::logger> spdlog::basic_logger_mt(const std::string& logger_name, const filename_t& filename, bool force_flush)
{
return create<spdlog::sinks::simple_file_sink_mt>(logger_name, filename, force_flush);
}
inline std::shared_ptr<spdlog::logger> spdlog::basic_logger_st(const std::string& logger_name, const filename_t& filename, bool force_flush)
{
return create<spdlog::sinks::simple_file_sink_st>(logger_name, filename, force_flush);
}
// Create multi/single threaded rotating file logger
inline std::shared_ptr<spdlog::logger> spdlog::rotating_logger_mt(const std::string& logger_name, const filename_t& filename, size_t max_file_size, size_t max_files, bool force_flush)
{
......
......@@ -62,6 +62,13 @@ void set_async_mode(size_t queue_size, const async_overflow_policy overflow_poli
// Turn off async mode
void set_sync_mode();
//
// Create and register multi/single basic file logger
//
std::shared_ptr<logger> basic_logger_mt(const std::string& logger_name, const filename_t& filename,bool force_flush = false);
std::shared_ptr<logger> basic_logger_st(const std::string& logger_name, const filename_t& filename, bool force_flush = false);
//
// Create and register multi/single threaded rotating file logger
//
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment