Austin Schuh | 812d0d1 | 2021-11-04 20:16:48 -0700 | [diff] [blame] | 1 | // Copyright (c) FIRST and other WPILib contributors. |
| 2 | // Open Source Software; you can modify and/or share it under the terms of |
| 3 | // the WPILib BSD license file in the root directory of this project. |
| 4 | |
| 5 | #include "wpi/Logger.h" |
| 6 | |
| 7 | using namespace wpi; |
| 8 | |
| 9 | void Logger::DoLog(unsigned int level, const char* file, unsigned int line, |
| 10 | const char* msg) { |
| 11 | if (!m_func || level < m_min_level) { |
| 12 | return; |
| 13 | } |
| 14 | m_func(level, file, line, msg); |
| 15 | } |
| 16 | |
| 17 | void Logger::LogV(unsigned int level, const char* file, unsigned int line, |
| 18 | fmt::string_view format, fmt::format_args args) { |
| 19 | if (!m_func || level < m_min_level) { |
| 20 | return; |
| 21 | } |
| 22 | fmt::memory_buffer out; |
| 23 | fmt::vformat_to(fmt::appender{out}, format, args); |
| 24 | out.push_back('\0'); |
| 25 | m_func(level, file, line, out.data()); |
| 26 | } |