Merge branch 'master' into maxgolov/vs_toolset
This commit is contained in:
Коммит
96c23a1a19
|
@ -62,7 +62,7 @@ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/modules/exp/)
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(EXISTS "modules/dataviewer/")
|
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/modules/dataviewer/)
|
||||||
list(APPEND SRCS
|
list(APPEND SRCS
|
||||||
modules/dataviewer/DefaultDataViewer.cpp
|
modules/dataviewer/DefaultDataViewer.cpp
|
||||||
modules/dataviewer/OnDisableNotificationCollection.cpp
|
modules/dataviewer/OnDisableNotificationCollection.cpp
|
||||||
|
@ -128,6 +128,11 @@ if(PAL_IMPLEMENTATION STREQUAL "CPP11")
|
||||||
../wrappers/obj-c/ODWLogConfiguration.mm
|
../wrappers/obj-c/ODWLogConfiguration.mm
|
||||||
../wrappers/obj-c/ODWSemanticContext.mm
|
../wrappers/obj-c/ODWSemanticContext.mm
|
||||||
)
|
)
|
||||||
|
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/modules/dataviewer/)
|
||||||
|
list(APPEND SRCS
|
||||||
|
../wrappers/obj-c/ODWDiagnosticDataViewer.mm
|
||||||
|
)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
elseif(PAL_IMPLEMENTATION STREQUAL "WIN32")
|
elseif(PAL_IMPLEMENTATION STREQUAL "WIN32")
|
||||||
# Win32 Desktop for now.
|
# Win32 Desktop for now.
|
||||||
|
|
|
@ -0,0 +1,59 @@
|
||||||
|
#include "objc_begin.h"
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
/*!
|
||||||
|
The <b>ODWDiagnosticDataViewer</b> class represents Diagnostic Data Viewer Hook.
|
||||||
|
*/
|
||||||
|
@interface ODWDiagnosticDataViewer : NSObject
|
||||||
|
|
||||||
|
#pragma mark Initialization methods
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@brief Initializes Data Viewer with an specified machine identifier.
|
||||||
|
@param machineIdentifier A string that contains the machine identifier.
|
||||||
|
*/
|
||||||
|
+(void)initializeViewerWithMachineIdentifier:(NSString *)machineIdentifier;
|
||||||
|
|
||||||
|
#pragma mark Behavior methods
|
||||||
|
/*!
|
||||||
|
@brief Enables Data Viewer.
|
||||||
|
@param endpoint A string that contains endpoint to route events.
|
||||||
|
@param completionWithResult Code to execute when enable is completed. <b>Note:</b> This value can be null.
|
||||||
|
*/
|
||||||
|
+(void)enableRemoteViewer:(NSString *)endpoint
|
||||||
|
completionWithResult:(void(^)(bool result))completion;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@brief Enables Data Viewer.
|
||||||
|
@param endpoint A string that contains endpoint to route events.
|
||||||
|
*/
|
||||||
|
+(bool)enableRemoteViewer:(NSString *)endpoint;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@brief Disables Data Viewer.
|
||||||
|
@param completion Code to execute when disable is completed. <b>Note:</b> This value can be null.
|
||||||
|
*/
|
||||||
|
+(void)disableViewer:(void(^)(bool result))completion;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@brief Disables Data Viewer.
|
||||||
|
*/
|
||||||
|
+(bool)disableViewer;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@brief Returns if Data Viewer is enabled or not.
|
||||||
|
@return True if viewer is enabled
|
||||||
|
*/
|
||||||
|
+(bool)viewerEnabled;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@brief Sets callback for OnDisableNotification event.
|
||||||
|
@param callback Code to execute when OnDisableNotification event occurrs.
|
||||||
|
*/
|
||||||
|
+(void)registerOnDisableNotification:(void(^)())callback;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
||||||
|
#include "objc_end.h"
|
|
@ -0,0 +1,142 @@
|
||||||
|
#include <stdexcept>
|
||||||
|
#include "LogManager.hpp"
|
||||||
|
#include "DefaultDataViewer.hpp"
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import "ODWDiagnosticDataViewer.h"
|
||||||
|
#import "ODWLogConfiguration.h"
|
||||||
|
#import "ODWLogger_private.h"
|
||||||
|
|
||||||
|
using namespace MAT;
|
||||||
|
|
||||||
|
@implementation ODWDiagnosticDataViewer
|
||||||
|
|
||||||
|
std::shared_ptr<DefaultDataViewer> _viewer;
|
||||||
|
|
||||||
|
+(void)initializeViewerWithMachineIdentifier:(NSString *)machineIdentifier
|
||||||
|
{
|
||||||
|
const std::string identifier = { [machineIdentifier UTF8String] };
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_viewer = std::make_shared<DefaultDataViewer> (nullptr, identifier);
|
||||||
|
LogManager::GetDataViewerCollection().RegisterViewer(_viewer);
|
||||||
|
}
|
||||||
|
catch (const std::exception &e)
|
||||||
|
{
|
||||||
|
if ([ODWLogConfiguration surfaceCppExceptions])
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
[ODWLogger traceException: e.what()];
|
||||||
|
}
|
||||||
|
catch (const std::exception *e)
|
||||||
|
{
|
||||||
|
if ([ODWLogConfiguration surfaceCppExceptions])
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
[ODWLogger traceException: e->what()];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
+(void)enableRemoteViewer:(NSString *)endpoint completionWithResult:(void(^)(bool result))completion
|
||||||
|
{
|
||||||
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||||
|
bool result = [ODWDiagnosticDataViewer enableRemoteViewer: endpoint];
|
||||||
|
if (completion)
|
||||||
|
{
|
||||||
|
completion(result);
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
|
+(bool)enableRemoteViewer:(NSString *)endpoint
|
||||||
|
{
|
||||||
|
bool result = false;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
result = _viewer->EnableRemoteViewer(std::string([endpoint UTF8String]));
|
||||||
|
if ([ODWLogConfiguration enableTrace])
|
||||||
|
{
|
||||||
|
NSLog(@"RemoteDataViewer enabled on endpoint: %@ and result: %@", endpoint, result ? @"success" : @"failure");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (const std::exception &e)
|
||||||
|
{
|
||||||
|
if ([ODWLogConfiguration surfaceCppExceptions])
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
[ODWLogger traceException: e.what()];
|
||||||
|
}
|
||||||
|
catch (const std::exception *e)
|
||||||
|
{
|
||||||
|
if ([ODWLogConfiguration surfaceCppExceptions])
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
[ODWLogger traceException: e->what()];
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
+(void)disableViewer:(void(^)(bool result))completion
|
||||||
|
{
|
||||||
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||||
|
bool result = [ODWDiagnosticDataViewer disableViewer];
|
||||||
|
if (completion)
|
||||||
|
{
|
||||||
|
completion(result);
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
|
+(bool)disableViewer
|
||||||
|
{
|
||||||
|
bool result = _viewer->DisableViewer();
|
||||||
|
if ([ODWLogConfiguration enableTrace])
|
||||||
|
{
|
||||||
|
NSLog(@"RemoteDataViewer disabled with result: %@", result ? @"success" : @"failure");
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
+(bool)viewerEnabled
|
||||||
|
{
|
||||||
|
bool result = false;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
result = LogManager::GetDataViewerCollection().IsViewerEnabled();
|
||||||
|
}
|
||||||
|
catch (const std::exception &e)
|
||||||
|
{
|
||||||
|
if ([ODWLogConfiguration surfaceCppExceptions])
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
[ODWLogger traceException: e.what()];
|
||||||
|
}
|
||||||
|
catch (const std::exception *e)
|
||||||
|
{
|
||||||
|
if ([ODWLogConfiguration surfaceCppExceptions])
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
[ODWLogger traceException: e->what()];
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
+(void)registerOnDisableNotification:(void(^)())callback
|
||||||
|
{
|
||||||
|
std::function<void()> disableNotification = std::bind(callback);
|
||||||
|
_viewer->RegisterOnDisableNotification(disableNotification);
|
||||||
|
if ([ODWLogConfiguration enableTrace])
|
||||||
|
{
|
||||||
|
NSLog(@"Registered OnDisableNotification");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@end
|
|
@ -22,6 +22,17 @@
|
||||||
*/
|
*/
|
||||||
+(bool)enableTrace;
|
+(bool)enableTrace;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@brief Sets if inner C++ exceptions should be surfaced to Wrapper consumers.
|
||||||
|
@param surfaceCppExceptions True if C++ exceptions should be surfaced.
|
||||||
|
*/
|
||||||
|
+ (void)setSurfaceCppExceptions:(bool)surfaceCppExceptions;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@brief Returns true if inner C++ exceptions are surfaced to Wrapper consumers.
|
||||||
|
*/
|
||||||
|
+ (bool)surfaceCppExceptions;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#include "objc_end.h"
|
#include "objc_end.h"
|
||||||
|
|
|
@ -6,6 +6,7 @@ using namespace Microsoft::Applications::Events;
|
||||||
|
|
||||||
@implementation ODWLogConfiguration
|
@implementation ODWLogConfiguration
|
||||||
static bool _enableTrace;
|
static bool _enableTrace;
|
||||||
|
static bool _surfaceCppExceptions;
|
||||||
|
|
||||||
+(void)setMaxTeardownUploadTimeInSec:(int)maxTeardownUploadTimeInSec
|
+(void)setMaxTeardownUploadTimeInSec:(int)maxTeardownUploadTimeInSec
|
||||||
{
|
{
|
||||||
|
@ -25,4 +26,14 @@ using namespace Microsoft::Applications::Events;
|
||||||
return _enableTrace;
|
return _enableTrace;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+(void)setSurfaceCppExceptions:(bool)surfaceCppExceptions
|
||||||
|
{
|
||||||
|
_surfaceCppExceptions = surfaceCppExceptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
+(bool)surfaceCppExceptions
|
||||||
|
{
|
||||||
|
return _surfaceCppExceptions;
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -206,4 +206,11 @@ using namespace MAT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+(void)traceException:(const char *)message
|
||||||
|
{
|
||||||
|
if([ODWLogConfiguration enableTrace])
|
||||||
|
{
|
||||||
|
NSLog(EXCEPTION_TRACE_FORMAT, message);
|
||||||
|
}
|
||||||
|
}
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -7,6 +7,8 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
using namespace MAT;
|
using namespace MAT;
|
||||||
|
|
||||||
|
#define EXCEPTION_TRACE_FORMAT @"C++ Exception: %s"
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
The <b>ODWLogger</b> class represents an event's properties.
|
The <b>ODWLogger</b> class represents an event's properties.
|
||||||
*/
|
*/
|
||||||
|
@ -17,6 +19,11 @@ using namespace MAT;
|
||||||
*/
|
*/
|
||||||
-(instancetype)initWithILogger:(ILogger *)logger;
|
-(instancetype)initWithILogger:(ILogger *)logger;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
@brief Traces C++ exception message. This method might be only used internally by wrapper.
|
||||||
|
*/
|
||||||
|
+ (void)traceException:(const char*)message;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
NS_ASSUME_NONNULL_END
|
NS_ASSUME_NONNULL_END
|
||||||
|
|
Загрузка…
Ссылка в новой задаче