Skip to content

Commit

Permalink
Merge pull request #1571 from GrigoryanArtem/master
Browse files Browse the repository at this point in the history
Added logging facilities
  • Loading branch information
shimat authored Jun 5, 2023
2 parents 24b2568 + 35b9608 commit 117600e
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/OpenCvSharp/Cv2/Cv2_core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3590,6 +3590,35 @@ public static string Format(InputArray mtx, FormatType format = FormatType.Defau

#endregion

#region logger.hpp

/// <summary>
/// Set global logging level
/// </summary>
/// <param name="logLevel">logging level</param>
/// <returns>previous logging level</returns>
public static LogLevel SetLogLevel(LogLevel logLevel)
{
NativeMethods.HandleException(
NativeMethods.core_logger_setLogLevel(logLevel, out var previous));

return previous;
}

/// <summary>
/// Get global logging level
/// </summary>
/// <returns>logging level</returns>
public static LogLevel GetLogLevel()
{
NativeMethods.HandleException(
NativeMethods.core_logger_getLogLevel(out var logLevel));

return logLevel;
}

#endregion

/// <summary>
/// Computes absolute value of each matrix element
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,16 @@ static partial class NativeMethods

#endregion

#region logger.hpp

[Pure, DllImport(DllExtern, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern ExceptionStatus core_logger_setLogLevel(LogLevel logLevel, out LogLevel returnValue);

[Pure, DllImport(DllExtern, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern ExceptionStatus core_logger_getLogLevel(out LogLevel returnValue);

#endregion

[Pure, DllImport(DllExtern, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern ExceptionStatus core_borderInterpolate(
int p, int len, int borderType, out int returnValue);
Expand Down
42 changes: 42 additions & 0 deletions src/OpenCvSharp/Modules/core/Enum/LogLevel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
namespace OpenCvSharp;

/// <summary>
/// cv::utils::logging::LogLevel
/// </summary>
public enum LogLevel
{
/// <summary>
/// for using in setLogVevel() call
/// </summary>
SILENT = 0,

/// <summary>
/// Fatal (critical) error (unrecoverable internal error)
/// </summary>
FATAL = 1,

/// <summary>
/// Error message.
/// </summary>
ERROR = 2,

/// <summary>
/// Warning message.
/// </summary>
WARNING = 3,

/// <summary>
/// Info message.
/// </summary>
INFO = 4,

/// <summary>
/// Debug message. Disabled in the "Release" build.
/// </summary>
DEBUG = 5,

/// <summary>
/// Verbose (trace) messages. Requires verbosity level. Disabled in the "Release" build.
/// </summary>
VERBOSE = 6
}
18 changes: 18 additions & 0 deletions src/OpenCvSharpExtern/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -1058,6 +1058,24 @@ CVAPI(ExceptionStatus) core_format(cv::_InputArray *mtx, int fmt, std::string *b

#pragma endregion

#pragma region logger.hpp

CVAPI(ExceptionStatus) core_logger_setLogLevel(cv::utils::logging::LogLevel logLevel, cv::utils::logging::LogLevel* returnValue)
{
BEGIN_WRAP
*returnValue = cv::utils::logging::setLogLevel(logLevel);
END_WRAP
}

CVAPI(ExceptionStatus) core_logger_getLogLevel(cv::utils::logging::LogLevel *returnValue)
{
BEGIN_WRAP
*returnValue = cv::utils::logging::getLogLevel();
END_WRAP
}

#pragma endregion

#pragma region RNG

CVAPI(ExceptionStatus) core_RNG_fill(uint64 *state, cv::_InputOutputArray *mat, int distType, cv::_InputArray *a, cv::_InputArray *b, int saturateRange)
Expand Down
1 change: 1 addition & 0 deletions src/OpenCvSharpExtern/include_opencv.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#ifdef _WINRT_DLL
#include <opencv2/highgui/highgui_winrt.hpp>
#endif
#include <opencv2/core/utils/logger.hpp>
#include <opencv2/highgui/highgui_c.h>
#include <opencv2/imgproc/imgproc_c.h>
#include <opencv2/shape.hpp>
Expand Down

0 comments on commit 117600e

Please sign in to comment.