Adding hex logging interface

This commit is contained in:
Paul Sutton 2015-08-28 13:19:19 +01:00
parent 24b46906ba
commit 4c2d6e4461
1 changed files with 25 additions and 13 deletions

View File

@ -25,10 +25,6 @@
* *
*/ */
#include <stdint.h>
#include <string>
/****************************************************************************** /******************************************************************************
* File: log.h * File: log.h
* *
@ -40,6 +36,9 @@
#ifndef LOG_H #ifndef LOG_H
#define LOG_H #define LOG_H
#include <stdint.h>
#include <string>
namespace srslte { namespace srslte {
typedef enum { typedef enum {
@ -70,6 +69,9 @@ public:
void step(uint32_t tti_) { void step(uint32_t tti_) {
tti = tti_; tti = tti_;
} }
uint32_t get_tti() {
return tti;
}
void set_level(LOG_LEVEL_ENUM l) { void set_level(LOG_LEVEL_ENUM l) {
level = l; level = l;
@ -78,8 +80,11 @@ public:
return level; return level;
} }
uint32_t get_tti() { void set_hex_limit(int limit) {
return tti; hex_limit = limit;
}
int get_hex_limit() {
return hex_limit;
} }
// Pure virtual methods for logging // Pure virtual methods for logging
@ -87,19 +92,26 @@ public:
virtual void warning(std::string message, ...) = 0; virtual void warning(std::string message, ...) = 0;
virtual void info(std::string message, ...) = 0; virtual void info(std::string message, ...) = 0;
virtual void debug(std::string message, ...) = 0; virtual void debug(std::string message, ...) = 0;
// Same with hex dump
virtual void error_hex(uint8_t *hex, int size, std::string message, ...){error("error_hex not implemented.");}
virtual void warning_hex(uint8_t *hex, int size, std::string message, ...){error("warning_hex not implemented.");}
virtual void info_hex(uint8_t *hex, int size, std::string message, ...){error("info_hex not implemented.");}
virtual void debug_hex(uint8_t *hex, int size, std::string message, ...){error("debug_hex not implemented.");}
// Same with line and file info // Same with line and file info
virtual void error_line(std::string file, int line, std::string message, ...) = 0; virtual void error_line(std::string file, int line, std::string message, ...){error("error_line not implemented.");}
virtual void warning_line(std::string file, int line, std::string message, ...) = 0; virtual void warning_line(std::string file, int line, std::string message, ...){error("warning_line not implemented.");}
virtual void info_line(std::string file, int line, std::string message, ...) = 0; virtual void info_line(std::string file, int line, std::string message, ...){error("info_line not implemented.");}
virtual void debug_line(std::string file, int line, std::string message, ...) = 0; virtual void debug_line(std::string file, int line, std::string message, ...){error("debug_line not implemented.");}
protected: protected:
std::string get_service_name() { return service_name; } std::string get_service_name() { return service_name; }
uint32_t tti; uint32_t tti;
LOG_LEVEL_ENUM level; LOG_LEVEL_ENUM level;
int hex_limit;
private: private:
std::string service_name; std::string service_name;
}; };
} // namespace srslte } // namespace srslte