blob: bba048265d92bbff579e51d7af42375fc4bbe586 [file] [log] [blame]
Austin Schuh86cd5722019-04-14 13:34:20 -07001#include "aos/seasocks/seasocks_logger.h"
2
Austin Schuh99f7c6a2024-06-25 22:07:44 -07003#include "absl/log/log.h"
Philipp Schrader790cb542023-07-05 21:06:52 -07004
Austin Schuh86cd5722019-04-14 13:34:20 -07005#include "seasocks/PrintfLogger.h"
6
Stephan Pleinesf63bde82024-01-13 15:59:33 -08007namespace aos::seasocks {
Austin Schuh86cd5722019-04-14 13:34:20 -07008
9void SeasocksLogger::log(::seasocks::Logger::Level level, const char *message) {
Brian Silverman5241b4e2021-11-04 19:19:14 -070010 // Convert Seasocks error codes to glog.
Austin Schuh99f7c6a2024-06-25 22:07:44 -070011 absl::LogSeverity log_level;
Austin Schuh86cd5722019-04-14 13:34:20 -070012 switch (level) {
13 case ::seasocks::Logger::Level::Info:
Austin Schuh99f7c6a2024-06-25 22:07:44 -070014 log_level = absl::LogSeverity::kInfo;
Austin Schuh86cd5722019-04-14 13:34:20 -070015 break;
16 case ::seasocks::Logger::Level::Warning:
Austin Schuh99f7c6a2024-06-25 22:07:44 -070017 log_level = absl::LogSeverity::kWarning;
Austin Schuh86cd5722019-04-14 13:34:20 -070018 break;
19 case ::seasocks::Logger::Level::Error:
20 case ::seasocks::Logger::Level::Severe:
Austin Schuh99f7c6a2024-06-25 22:07:44 -070021 log_level = absl::LogSeverity::kError;
Austin Schuh86cd5722019-04-14 13:34:20 -070022 break;
23 case ::seasocks::Logger::Level::Debug:
24 case ::seasocks::Logger::Level::Access:
25 default:
Brian Silverman5241b4e2021-11-04 19:19:14 -070026 if (!VLOG_IS_ON(1)) {
27 return;
28 }
Austin Schuh99f7c6a2024-06-25 22:07:44 -070029 log_level = absl::LogSeverity::kInfo;
Austin Schuh86cd5722019-04-14 13:34:20 -070030 break;
31 }
Austin Schuh99f7c6a2024-06-25 22:07:44 -070032 LOG(LEVEL(log_level)) << "Seasocks: " << message;
Austin Schuh86cd5722019-04-14 13:34:20 -070033}
34
Stephan Pleinesf63bde82024-01-13 15:59:33 -080035} // namespace aos::seasocks