-
-
Notifications
You must be signed in to change notification settings - Fork 471
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
98 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,43 @@ | ||
namespace Mediapipe { | ||
public class Glog { | ||
public enum Severity : int { | ||
INFO = 0, | ||
WARNING = 1, | ||
ERROR = 2, | ||
FATAL = 3, | ||
} | ||
|
||
public static void Initialize(string name, string dir) { | ||
UnsafeNativeMethods.google_InitGoogleLogging__PKc(name, dir).Assert(); | ||
} | ||
|
||
public static void Shutdown() { | ||
UnsafeNativeMethods.google_ShutdownGoogleLogging().Assert(); | ||
} | ||
|
||
public static void Log(Severity severity, string str) { | ||
switch (severity) { | ||
case Severity.INFO: { | ||
UnsafeNativeMethods.glog_LOG_INFO__PKc(str); | ||
break; | ||
} | ||
case Severity.WARNING: { | ||
UnsafeNativeMethods.glog_LOG_WARNING__PKc(str); | ||
break; | ||
} | ||
case Severity.ERROR: { | ||
UnsafeNativeMethods.glog_LOG_ERROR__PKc(str); | ||
break; | ||
} | ||
case Severity.FATAL: { | ||
UnsafeNativeMethods.glog_LOG_FATAL__PKc(str); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
public static void FlushLogFiles(Severity severity = Severity.INFO) { | ||
UnsafeNativeMethods.google_FlushLogFiles(severity); | ||
} | ||
} | ||
} |
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
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,21 @@ | ||
#include "mediapipe_api/external/glog.h" | ||
|
||
void glog_LOG_INFO__PKc(const char* str) { | ||
LOG(INFO) << str; | ||
} | ||
|
||
void glog_LOG_WARNING__PKc(const char* str) { | ||
LOG(WARNING) << str; | ||
} | ||
|
||
void glog_LOG_ERROR__PKc(const char* str) { | ||
LOG(ERROR) << str; | ||
} | ||
|
||
void glog_LOG_FATAL__PKc(const char* str) { | ||
LOG(FATAL) << str; | ||
} | ||
|
||
void google_FlushLogFiles(google::LogSeverity severity) { | ||
google::FlushLogFiles(severity); | ||
} |
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,18 @@ | ||
#ifndef C_MEDIAPIPE_API_EXTERNAL_GLOG_H_ | ||
#define C_MEDIAPIPE_API_EXTERNAL_GLOG_H_ | ||
|
||
#include <string> | ||
#include "mediapipe_api/common.h" | ||
|
||
extern "C" { | ||
|
||
MP_CAPI(void) glog_LOG_INFO__PKc(const char* str); | ||
MP_CAPI(void) glog_LOG_WARNING__PKc(const char* str); | ||
MP_CAPI(void) glog_LOG_ERROR__PKc(const char* str); | ||
MP_CAPI(void) glog_LOG_FATAL__PKc(const char* str); | ||
|
||
MP_CAPI(void) google_FlushLogFiles(google::LogSeverity severity); | ||
|
||
} // extern "C" | ||
|
||
#endif // C_MEDIAPIPE_API_EXTERNAL_GLOG_H_ |