-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add logging * String publisher now behaves like Print(f) * Update example with eCAL logging * Fix enum type handling
- Loading branch information
1 parent
9e37530
commit 87c105e
Showing
8 changed files
with
158 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include "logging.h" | ||
|
||
#include <ecal/ecal_log.h> | ||
|
||
void Log(eCAL_Logging_eLogLevel level, const char *const msg, size_t len) { | ||
eCAL::Logging::Log(level, std::string(msg, len)); | ||
} | ||
|
||
void SetFileFilter(eCAL_Logging_Filter filter_bitset) { | ||
eCAL::Logging::SetFileLogFilter(filter_bitset); | ||
} | ||
|
||
void SetUDPFilter(eCAL_Logging_Filter filter_bitset) { | ||
eCAL::Logging::SetUDPLogFilter(filter_bitset); | ||
} | ||
|
||
void SetConsoleFilter(eCAL_Logging_Filter filter_bitset) { | ||
eCAL::Logging::SetConsoleLogFilter(filter_bitset); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package logging | ||
|
||
// #include <ecal/ecal_log_level.h> | ||
// #include "logging.h" | ||
// void GoLog(enum eCAL_Logging_eLogLevel level, _GoString_ msg) { | ||
// Log(level, _GoStringPtr(msg), _GoStringLen(msg)); | ||
// } | ||
import "C" | ||
import "fmt" | ||
|
||
type Level uint8 | ||
|
||
const ( | ||
LevelNone Level = C.log_level_none | ||
LevelAll Level = C.log_level_all | ||
LevelInfo Level = C.log_level_info | ||
LevelWarn Level = C.log_level_warning | ||
LevelError Level = C.log_level_error | ||
LevelFatal Level = C.log_level_fatal | ||
LevelDebug Level = C.log_level_debug1 | ||
LevelDebug1 Level = C.log_level_debug1 | ||
LevelDebug2 Level = C.log_level_debug2 | ||
LevelDebug3 Level = C.log_level_debug3 | ||
LevelDebug4 Level = C.log_level_debug4 | ||
) | ||
|
||
func Log(level Level, a ...any) { | ||
C.GoLog(uint32(level), fmt.Sprint(a...)) | ||
} | ||
|
||
func Logf(level Level, format string, a ...any) { | ||
C.GoLog(uint32(level), fmt.Sprintf(format, a...)) | ||
} | ||
|
||
func Error(a ...any) { | ||
Log(LevelError, a...) | ||
} | ||
|
||
func Errorf(format string, a ...any) { | ||
Logf(LevelError, format, a...) | ||
} | ||
|
||
func Warn(a ...any) { | ||
Log(LevelWarn, a...) | ||
} | ||
|
||
func Warnf(format string, a ...any) { | ||
Logf(LevelWarn, format, a...) | ||
} | ||
|
||
func Info(a ...any) { | ||
Log(LevelInfo, a...) | ||
} | ||
|
||
func Infof(format string, a ...any) { | ||
Logf(LevelInfo, format, a...) | ||
} | ||
|
||
func Debug(a ...any) { | ||
Log(LevelDebug, a...) | ||
} | ||
|
||
func Debugf(format string, a ...any) { | ||
Logf(LevelDebug, format, a...) | ||
} | ||
|
||
func SetConsoleFilter(levels Level) { | ||
C.SetConsoleFilter(C.eCAL_Logging_Filter(levels)) | ||
} | ||
|
||
func SetUdpFilter(levels Level) { | ||
C.SetUDPFilter(C.eCAL_Logging_Filter(levels)) | ||
} | ||
|
||
func SetFileFilter(levels Level) { | ||
C.SetFileFilter(C.eCAL_Logging_Filter(levels)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#ifndef ECAL_GO_LOGGING | ||
#define ECAL_GO_LOGGING | ||
|
||
#include <ecal/ecal_log_level.h> | ||
|
||
#include <stddef.h> | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
void Log(enum eCAL_Logging_eLogLevel level, const char *const msg, size_t len); | ||
|
||
void SetFileFilter(eCAL_Logging_Filter filter_bitset); | ||
void SetUDPFilter(eCAL_Logging_Filter filter_bitset); | ||
void SetConsoleFilter(eCAL_Logging_Filter filter_bitset); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,4 +25,3 @@ func TestProtobufPublisher(t *testing.T) { | |
t.Error("Failed to send message", err) | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters