Commit a0db86aa authored by Ghislain MARY's avatar Ghislain MARY

Use the new API to set the linphone core log handler and log level.

parent 8b1be4a9
......@@ -116,7 +116,8 @@ namespace Linphone
Debug = 0,
Message = 1,
Warning = 2,
Error = 3
Error = 3,
None = 255
};
/// <summary>
......
......@@ -85,6 +85,24 @@ Platform::String^ Linphone::Core::Transports::ToString()
}
void Linphone::Core::LinphoneCore::SetLogLevel(OutputTraceLevel logLevel)
{
int coreLogLevel = 0;
if (logLevel == OutputTraceLevel::Error) {
coreLogLevel = ORTP_ERROR | ORTP_FATAL;
}
else if (logLevel == OutputTraceLevel::Warning) {
coreLogLevel = ORTP_WARNING | ORTP_ERROR | ORTP_FATAL;
}
else if (logLevel == OutputTraceLevel::Message) {
coreLogLevel = ORTP_MESSAGE | ORTP_WARNING | ORTP_ERROR | ORTP_FATAL;
}
else if (logLevel == OutputTraceLevel::Debug) {
coreLogLevel = ORTP_DEBUG | ORTP_MESSAGE | ORTP_WARNING | ORTP_ERROR | ORTP_FATAL;
}
Utils::LinphoneCoreSetLogLevel(coreLogLevel);
}
void Linphone::Core::LinphoneCore::SetContext(Platform::Object^ object)
{
......
......@@ -59,6 +59,8 @@ namespace Linphone
public ref class LinphoneCore sealed
{
public:
static void SetLogLevel(OutputTraceLevel logLevel);
void SetContext(Platform::Object^ object);
void ClearProxyConfigs();
......
......@@ -47,7 +47,7 @@ void LinphoneCoreFactory::CreateLinphoneCore(Linphone::Core::LinphoneCoreListene
void LinphoneCoreFactory::CreateLinphoneCore(Linphone::Core::LinphoneCoreListener^ listener, Platform::String^ configPath, Platform::String^ factoryConfigPath)
{
std::lock_guard<std::recursive_mutex> lock(g_apiLock);
linphone_core_enable_logs_with_cb(LinphoneNativeOutputTraceHandler);
Utils::LinphoneCoreSetLogHandler(LinphoneNativeOutputTraceHandler);
this->linphoneCore = ref new Linphone::Core::LinphoneCore(listener, configPath, factoryConfigPath);
this->linphoneCore->Init();
}
......
#pragma once
#include <windows.h>
#include "Globals.h"
#include "LinphoneCore.h"
namespace Linphone
{
......@@ -56,6 +57,11 @@ namespace Linphone
return Windows::ApplicationModel::Package::Current->InstalledLocation->Path;
};
}
void SetLogLevel(OutputTraceLevel logLevel)
{
Linphone::Core::LinphoneCore::SetLogLevel(logLevel);
}
};
}
}
......
......@@ -41,6 +41,18 @@ Platform::String^ Linphone::Core::Utils::cctops(const char* cc)
return ref new Platform::String(w_char);
}
void Linphone::Core::Utils::LinphoneCoreSetLogHandler(void *logfunc)
{
std::lock_guard<std::recursive_mutex> lock(g_apiLock);
linphone_core_set_log_handler(static_cast<OrtpLogFunc>(logfunc));
}
void Linphone::Core::Utils::LinphoneCoreSetLogLevel(int loglevel)
{
std::lock_guard<std::recursive_mutex> lock(g_apiLock);
linphone_core_set_log_level(static_cast<OrtpLogLevel>(loglevel));
}
Platform::Object^ Linphone::Core::Utils::CreateLpConfig(void *config)
{
return ref new Linphone::Core::LpConfig((::LpConfig *)config);
......
......@@ -14,6 +14,20 @@ namespace Linphone
static Platform::String^ Linphone::Core::Utils::cctops(const char*);
/// <summary>
/// Define a log handler.
/// <param name="logfunc">The function pointer of the log handler.</param>
/// </summary>
static void LinphoneCoreSetLogHandler(void *logfunc);
/// <summary>
/// Define the log level.
/// The loglevel parameter is a bitmask parameter. Therefore to enable only warning and error
/// messages, use ORTP_WARNING | ORTP_ERROR. To disable logs, simply set loglevel to 0.
/// <param name="loglevel">A bitmask of the log levels to set.</param>
/// </summary>
static void LinphoneCoreSetLogLevel(int loglevel);
static Platform::Object^ CreateLpConfig(void *config);
static Platform::Object^ CreatePayloadType(void *pt);
......
......@@ -265,6 +265,11 @@ namespace Linphone.Model
Logger.Instance.TraceListener = server.BackgroundModeLogger;
}
public void SetLogLevel(OutputTraceLevel logLevel)
{
server.SetLogLevel(logLevel);
}
#region CallLogs
private List<CallLogs> _history;
......
......@@ -129,6 +129,12 @@ namespace Linphone.Model
{
LinphoneCore lc = LinphoneManager.Instance.LinphoneCore;
bool debugEnabled = Convert.ToBoolean(GetNew(DebugSettingKeyName));
OutputTraceLevel logLevel = OutputTraceLevel.None;
if (debugEnabled)
{
logLevel = OutputTraceLevel.Message;
}
LinphoneManager.Instance.SetLogLevel(logLevel);
lc.GetConfig().SetBool(ApplicationSection, DebugSettingKeyName, debugEnabled);
LinphoneManager.Instance.ConfigureLogger();
}
......
......@@ -80,6 +80,7 @@
<Interface Name="Linphone.Core.__ITransportsPublicNonVirtuals" InterfaceId="{9CF934BB-9476-3105-B0DF-49E2F4B2A580}" />
<Interface Name="Linphone.Core.__ITransportsFactory" InterfaceId="{3376B207-4618-313D-B564-D5500B8EFB64}" />
<Interface Name="Linphone.Core.__ILinphoneCorePublicNonVirtuals" InterfaceId="{5D15EB8C-4443-3BC3-BC3D-A319DDE8A2BE}" />
<Interface Name="Linphone.Core.__ILinphoneCoreStatics" InterfaceId="{27C5C871-79CD-3BEB-ACED-BF201D8ACC7B}" />
<Interface Name="Linphone.Core.__IGlobalsPublicNonVirtuals" InterfaceId="{01600449-19D0-3E52-80E3-382A2C93CBB1}" />
<Interface Name="Linphone.Core.__IGlobalsStatics" InterfaceId="{828E0FFB-4077-39EF-A334-6F19365E4FFE}" />
<Interface Name="Linphone.Core.OutOfProcess.__IServerPublicNonVirtuals" InterfaceId="{46DDE636-87D1-3A06-9D4A-D0753804368A}" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment