Java API LogManager completion along with DDV changes
This commit is contained in:
Родитель
c099307cf6
Коммит
fa12761aed
|
@ -80,6 +80,12 @@ set(SRCS
|
|||
${SDK_ROOT}/sqlite/sqlite3.c
|
||||
)
|
||||
|
||||
if(EXISTS ${SDK_ROOT}/lib/modules/dataviewer/)
|
||||
list(APPEND SRCS
|
||||
${SDK_ROOT}/lib/modules/dataviewer/DefaultDataViewer.cpp
|
||||
${SDK_ROOT}/lib/modules/dataviewer/OnDisableNotificationCollection.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
if (USE_CURL)
|
||||
list(APPEND SRCS ${SDK_ROOT}/lib/http/HttpClient_Curl.cpp)
|
||||
|
|
|
@ -140,6 +140,13 @@ public interface ISemanticContext {
|
|||
*/
|
||||
public void setOsBuild(final String osBuild);
|
||||
|
||||
/**
|
||||
* Set the userId context information of telemetry event and default to PiiKind_Identity.
|
||||
*
|
||||
* @param userId Identifier that uniquely identifies a user in the application-specific user namespace
|
||||
*/
|
||||
public void setUserId(final String userId);
|
||||
|
||||
/**
|
||||
* Set the userId context information of telemetry event.
|
||||
* @param userId Identifier that uniquely identifies a user in the application-specific user namespace
|
||||
|
@ -189,6 +196,14 @@ public interface ISemanticContext {
|
|||
*/
|
||||
public void setCommercialId(final String commercialId);
|
||||
|
||||
/**
|
||||
* Sets the common Part A/B field.
|
||||
*
|
||||
* @param name Field name
|
||||
* @param value Field value in string
|
||||
*/
|
||||
public void setCommonField(final String name, final String value);
|
||||
|
||||
/**
|
||||
* Sets the common Part A/B field.
|
||||
* @param name Field name
|
||||
|
@ -196,6 +211,14 @@ public interface ISemanticContext {
|
|||
*/
|
||||
public void setCommonField(final String name, final EventProperty value);
|
||||
|
||||
/**
|
||||
* Sets the custom Part C field.
|
||||
*
|
||||
* @param name Field name
|
||||
* @param value Field value
|
||||
*/
|
||||
public void setCustomField(final String name, final String value);
|
||||
|
||||
/**
|
||||
* Sets the custom Part C field.
|
||||
* @param name Field name
|
||||
|
|
|
@ -6,7 +6,7 @@ import java.util.UUID;
|
|||
public class LogManager {
|
||||
private LogManager() {};
|
||||
|
||||
private static native long initializeWithoutTenantToken();
|
||||
private static native long nativeInitializeWithoutTenantToken();
|
||||
|
||||
/**
|
||||
* Initializes the telemetry logging system with default configuration and HTTPClient.
|
||||
|
@ -14,10 +14,14 @@ public class LogManager {
|
|||
* @return A logger instance instantiated with the default tenantToken.
|
||||
*/
|
||||
public static ILogger initialize(){
|
||||
return new Logger(initializeWithoutTenantToken());
|
||||
long logger = nativeInitializeWithoutTenantToken();
|
||||
if (logger == 0)
|
||||
return null;
|
||||
else
|
||||
return new Logger(logger);
|
||||
}
|
||||
|
||||
private static native long initializeWithTenantToken(String tenantToken);
|
||||
private static native long nativeInitializeWithTenantToken(String tenantToken);
|
||||
|
||||
/**
|
||||
* Initializes the telemetry logging system with the specified tenantToken.
|
||||
|
@ -29,22 +33,26 @@ public class LogManager {
|
|||
if (tenantToken == null || tenantToken.trim().isEmpty())
|
||||
throw new IllegalArgumentException("tenantToken is null or empty");
|
||||
|
||||
return new Logger(initializeWithTenantToken(tenantToken));
|
||||
long logger = nativeInitializeWithTenantToken(tenantToken);
|
||||
if (logger == 0)
|
||||
return null;
|
||||
else
|
||||
return new Logger(logger);
|
||||
}
|
||||
|
||||
|
||||
private static native int nativeFlushAndTeardown();
|
||||
|
||||
/**
|
||||
* Flush any pending telemetry events in memory to disk and tear down the telemetry logging system.
|
||||
*
|
||||
* @return native value of status_t
|
||||
* @return Status enum corresponding to the native API execution status_t.
|
||||
*/
|
||||
public static native int flushAndTeardown();
|
||||
public static Status flushAndTeardown() {
|
||||
return Status.getEnum(nativeFlushAndTeardown());
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to send any pending telemetry events in memory or on disk.
|
||||
*
|
||||
* @return native value of status_t
|
||||
*/
|
||||
public static native int uploadNow();
|
||||
private static native int nativeFlush();
|
||||
|
||||
/**
|
||||
* Flush any pending telemetry events in memory to disk to reduce possible data loss as seen necessary.
|
||||
|
@ -52,26 +60,48 @@ public class LogManager {
|
|||
* and might flush the global file buffers, i.e. all buffered filesystem data, to disk, which could be
|
||||
* time consuming.
|
||||
*
|
||||
* @return native value of status_t
|
||||
* @return Status enum corresponding to the native API execution status_t.
|
||||
*/
|
||||
public static native int flush();
|
||||
public static Status flush() {
|
||||
return Status.getEnum(nativeFlush());
|
||||
}
|
||||
|
||||
private static native int nativeUploadNow();
|
||||
|
||||
/**
|
||||
* Try to send any pending telemetry events in memory or on disk.
|
||||
*
|
||||
* @return Status enum corresponding to the native API execution status_t.
|
||||
*/
|
||||
public static Status uploadNow() {
|
||||
return Status.getEnum(nativeUploadNow());
|
||||
}
|
||||
|
||||
|
||||
private static native int nativePauseTransmission();
|
||||
|
||||
/**
|
||||
* Pauses the transmission of events to data collector.
|
||||
* While paused events will continue to be queued up on client side in cache (either in memory or on disk file).
|
||||
*
|
||||
* @return native value of status_t
|
||||
* @return Status enum corresponding to the native API execution status_t.
|
||||
*/
|
||||
public static native int pauseTransmission();
|
||||
public static Status pauseTransmission() {
|
||||
return Status.getEnum(nativePauseTransmission());
|
||||
}
|
||||
|
||||
private static native int nativeResumeTransmission();
|
||||
|
||||
/**
|
||||
* Resumes the transmission of events to data collector.
|
||||
*
|
||||
* @return native value of status_t
|
||||
* @return Status enum corresponding to the native API execution status_t.
|
||||
*/
|
||||
public static native int resumeTransmission();
|
||||
public static Status resumeTransmission() {
|
||||
return Status.getEnum(nativeResumeTransmission());
|
||||
}
|
||||
|
||||
private static native int setIntTransmitProfile(int profile);
|
||||
private static native int nativeSetIntTransmitProfile(int profile);
|
||||
|
||||
/**
|
||||
* Sets transmit profile for event transmission to one of the built-in profiles.
|
||||
|
@ -79,17 +109,17 @@ public class LogManager {
|
|||
* based on which to determine how events are to be transmitted.
|
||||
*
|
||||
* @param profile Transmit profile
|
||||
* @return native value of status_t
|
||||
* @return Status enum corresponding to the native API execution status_t.
|
||||
*/
|
||||
public static int setTransmitProfile(TransmitProfile profile) {
|
||||
public static Status setTransmitProfile(TransmitProfile profile) {
|
||||
if (profile == null)
|
||||
throw new IllegalArgumentException("profile is null");
|
||||
|
||||
return setIntTransmitProfile(profile.getValue());
|
||||
return Status.getEnum(nativeSetIntTransmitProfile(profile.getValue()));
|
||||
}
|
||||
|
||||
|
||||
public static native int setTransmitProfileString(String profile);
|
||||
private static native int nativeSetTransmitProfileString(String profile);
|
||||
|
||||
/**
|
||||
* Sets transmit profile for event transmission.
|
||||
|
@ -97,37 +127,41 @@ public class LogManager {
|
|||
* based on which to determine how events are to be transmitted.
|
||||
*
|
||||
* @param profile Transmit profile
|
||||
* @return native value of status_t
|
||||
* @return Status enum corresponding to the native API execution status_t.
|
||||
*/
|
||||
|
||||
public static int setTransmitProfile(String profile) {
|
||||
public static Status setTransmitProfile(String profile) {
|
||||
if (profile == null || profile.trim().isEmpty())
|
||||
throw new IllegalArgumentException("profile is null or empty");
|
||||
|
||||
return setTransmitProfileString(profile);
|
||||
return Status.getEnum(nativeSetTransmitProfileString(profile));
|
||||
}
|
||||
|
||||
private static native int loadTransmitProfilesString(String profilesJson);
|
||||
private static native int nativeLoadTransmitProfilesString(String profilesJson);
|
||||
|
||||
/**
|
||||
* Load transmit profiles from JSON config
|
||||
*
|
||||
* @param profilesJson JSON config
|
||||
* @return native value of status_t
|
||||
* @return Status enum corresponding to the native API execution status_t.
|
||||
*/
|
||||
public static int loadTransmitProfiles(String profilesJson) {
|
||||
public static Status loadTransmitProfiles(String profilesJson) {
|
||||
if (profilesJson == null || profilesJson.trim().isEmpty())
|
||||
throw new IllegalArgumentException("profilesJson is null or empty");
|
||||
|
||||
return loadTransmitProfilesString(profilesJson);
|
||||
return Status.getEnum(nativeLoadTransmitProfilesString(profilesJson));
|
||||
}
|
||||
|
||||
private static native int nativeResetTransmitProfiles();
|
||||
|
||||
/**
|
||||
* Reset transmission profiles to default settings
|
||||
*
|
||||
* @return native value of status_t
|
||||
* @return Status enum corresponding to the native API execution status_t.
|
||||
*/
|
||||
public static native int resetTransmitProfiles();
|
||||
public static Status resetTransmitProfiles() {
|
||||
return Status.getEnum(nativeResetTransmitProfiles());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Transmit profile name based on built-in profile enum
|
||||
|
@ -141,10 +175,16 @@ public class LogManager {
|
|||
* such as device, system, hardware and user information.
|
||||
* Context information set via this API will apply to all logger instance unless they
|
||||
* are overwritten by individual logger instance.
|
||||
*
|
||||
* @return ISemanticContext interface pointer
|
||||
*/
|
||||
public static ISemanticContext getSemanticContext() {
|
||||
return new SemanticContext(nativeGetSemanticContext());
|
||||
|
||||
long semanticContext = nativeGetSemanticContext();
|
||||
if (semanticContext == 0)
|
||||
return null;
|
||||
else
|
||||
return new SemanticContext(semanticContext);
|
||||
}
|
||||
|
||||
private static native int nativeSetContextStringValue(String name, String value, int piiKind);
|
||||
|
@ -157,9 +197,9 @@ public class LogManager {
|
|||
*
|
||||
* @param name Name of the context property
|
||||
* @param value Value of the context property
|
||||
* @return native value of status_t
|
||||
* @return Status enum corresponding to the native API execution status_t.
|
||||
*/
|
||||
public static int setContext(final String name, final String value) {
|
||||
public static Status setContext(final String name, final String value) {
|
||||
return setContext(name, value, PiiKind.None);
|
||||
}
|
||||
|
||||
|
@ -171,17 +211,17 @@ public class LogManager {
|
|||
* @param name Name of the context property
|
||||
* @param value String value of the context property
|
||||
* @param piiKind PIIKind of the context
|
||||
* @return native value of status_t
|
||||
* @return Status enum corresponding to the native API execution status_t.
|
||||
*/
|
||||
public static int setContext(final String name, final String value, PiiKind piiKind) {
|
||||
public static Status setContext(final String name, final String value, final PiiKind piiKind) {
|
||||
if (name == null || name.trim().isEmpty())
|
||||
throw new IllegalArgumentException("name is null or empty");
|
||||
if (value == null || value.trim().isEmpty())
|
||||
throw new IllegalArgumentException("value is null or empty");
|
||||
if (value == null)
|
||||
throw new IllegalArgumentException("value is null");
|
||||
if (piiKind == null)
|
||||
throw new IllegalArgumentException("piiKind is null");
|
||||
|
||||
return nativeSetContextStringValue(name, value, piiKind.getValue());
|
||||
return Status.getEnum(nativeSetContextStringValue(name, value, piiKind.getValue()));
|
||||
}
|
||||
|
||||
private static native int nativeSetContextIntValue(String name, int value, int piiKind);
|
||||
|
@ -194,9 +234,9 @@ public class LogManager {
|
|||
*
|
||||
* @param name Name of the context property
|
||||
* @param value Int value of the context property
|
||||
* @return native value of status_t
|
||||
* @return Status enum corresponding to the native API execution status_t.
|
||||
*/
|
||||
public static int setContext(final String name, final int value) {
|
||||
public static Status setContext(final String name, final int value) {
|
||||
return setContext(name, value, PiiKind.None);
|
||||
}
|
||||
|
||||
|
@ -208,15 +248,15 @@ public class LogManager {
|
|||
* @param name Name of the context property
|
||||
* @param value Int value of the context property
|
||||
* @param piiKind PIIKind of the context
|
||||
* @return native value of status_t
|
||||
* @return Status enum corresponding to the native API execution status_t.
|
||||
*/
|
||||
public static int setContext(final String name, final int value, PiiKind piiKind) {
|
||||
public static Status setContext(final String name, final int value, final PiiKind piiKind) {
|
||||
if (name == null || name.trim().isEmpty())
|
||||
throw new IllegalArgumentException("name is null or empty");
|
||||
if (piiKind == null)
|
||||
throw new IllegalArgumentException("piiKind is null");
|
||||
|
||||
return nativeSetContextIntValue(name, value, piiKind.getValue());
|
||||
return Status.getEnum(nativeSetContextIntValue(name, value, piiKind.getValue()));
|
||||
}
|
||||
|
||||
private static native int nativeSetContextLongValue(String name, long value, int piiKind);
|
||||
|
@ -229,9 +269,9 @@ public class LogManager {
|
|||
*
|
||||
* @param name Name of the context property
|
||||
* @param value Long value of the context property
|
||||
* @return native value of status_t
|
||||
* @return Status enum corresponding to the native API execution status_t.
|
||||
*/
|
||||
public static int setContext(final String name, final long value) {
|
||||
public static Status setContext(final String name, final long value) {
|
||||
return setContext(name, value, PiiKind.None);
|
||||
}
|
||||
|
||||
|
@ -243,15 +283,15 @@ public class LogManager {
|
|||
* @param name Name of the context property
|
||||
* @param value Long value of the context property
|
||||
* @param piiKind PIIKind of the context
|
||||
* @return native value of status_t
|
||||
* @return Status enum corresponding to the native API execution status_t.
|
||||
*/
|
||||
public static int setContext(final String name, final long value, PiiKind piiKind) {
|
||||
public static Status setContext(final String name, final long value, final PiiKind piiKind) {
|
||||
if (name == null || name.trim().isEmpty())
|
||||
throw new IllegalArgumentException("name is null or empty");
|
||||
if (piiKind == null)
|
||||
throw new IllegalArgumentException("piiKind is null");
|
||||
|
||||
return nativeSetContextLongValue(name, value, piiKind.getValue());
|
||||
return Status.getEnum(nativeSetContextLongValue(name, value, piiKind.getValue()));
|
||||
}
|
||||
|
||||
private static native int nativeSetContextDoubleValue(String name, double value, int piiKind);
|
||||
|
@ -264,9 +304,9 @@ public class LogManager {
|
|||
*
|
||||
* @param name Name of the context property
|
||||
* @param value Double value of the context property
|
||||
* @return native value of status_t
|
||||
* @return Status enum corresponding to the native API execution status_t.
|
||||
*/
|
||||
public static int setContext(final String name, final double value) {
|
||||
public static Status setContext(final String name, final double value) {
|
||||
return setContext(name, value, PiiKind.None);
|
||||
}
|
||||
|
||||
|
@ -278,15 +318,15 @@ public class LogManager {
|
|||
* @param name Name of the context property
|
||||
* @param value Double value of the context property
|
||||
* @param piiKind PIIKind of the context
|
||||
* @return native value of status_t
|
||||
* @return Status enum corresponding to the native API execution status_t.
|
||||
*/
|
||||
public static int setContext(final String name, final double value, PiiKind piiKind) {
|
||||
public static Status setContext(final String name, final double value, final PiiKind piiKind) {
|
||||
if (name == null || name.trim().isEmpty())
|
||||
throw new IllegalArgumentException("name is null or empty");
|
||||
if (piiKind == null)
|
||||
throw new IllegalArgumentException("piiKind is null");
|
||||
|
||||
return nativeSetContextDoubleValue(name, value, piiKind.getValue());
|
||||
return Status.getEnum(nativeSetContextDoubleValue(name, value, piiKind.getValue()));
|
||||
}
|
||||
|
||||
private static native int nativeSetContextBoolValue(String name, boolean value, int piiKind);
|
||||
|
@ -299,9 +339,9 @@ public class LogManager {
|
|||
*
|
||||
* @param name Name of the context property
|
||||
* @param value Boolean value of the context property
|
||||
* @return native value of status_t
|
||||
* @return Status enum corresponding to the native API execution status_t.
|
||||
*/
|
||||
public static int setContext(final String name, final boolean value) {
|
||||
public static Status setContext(final String name, final boolean value) {
|
||||
return setContext(name, value, PiiKind.None);
|
||||
}
|
||||
|
||||
|
@ -313,15 +353,15 @@ public class LogManager {
|
|||
* @param name Name of the context property
|
||||
* @param value boolean value of the context property
|
||||
* @param piiKind PIIKind of the context
|
||||
* @return native value of status_t
|
||||
* @return Status enum corresponding to the native API execution status_t.
|
||||
*/
|
||||
public static int setContext(final String name, final boolean value, PiiKind piiKind) {
|
||||
public static Status setContext(final String name, final boolean value, final PiiKind piiKind) {
|
||||
if (name == null || name.trim().isEmpty())
|
||||
throw new IllegalArgumentException("name is null or empty");
|
||||
if (piiKind == null)
|
||||
throw new IllegalArgumentException("piiKind is null");
|
||||
|
||||
return nativeSetContextBoolValue(name, value, piiKind.getValue());
|
||||
return Status.getEnum(nativeSetContextBoolValue(name, value, piiKind.getValue()));
|
||||
}
|
||||
|
||||
private static native int nativeSetContextTimeTicksValue(String name, long value, int piiKind);
|
||||
|
@ -334,9 +374,9 @@ public class LogManager {
|
|||
* @param name Name of the context property
|
||||
* @param value TimeTicks value of the context property
|
||||
* @param piiKind PIIKind of the context
|
||||
* @return native value of status_t
|
||||
* @return Status enum corresponding to the native API execution status_t.
|
||||
*/
|
||||
private static int setContext(final String name, final TimeTicks value, PiiKind piiKind) {
|
||||
private static Status setContext(final String name, final TimeTicks value, final PiiKind piiKind) {
|
||||
if (name == null || name.trim().isEmpty())
|
||||
throw new IllegalArgumentException("name is null or empty");
|
||||
if (value == null)
|
||||
|
@ -344,7 +384,7 @@ public class LogManager {
|
|||
if (piiKind == null)
|
||||
throw new IllegalArgumentException("piiKind is null");
|
||||
|
||||
return nativeSetContextTimeTicksValue(name, value.getTicks(), piiKind.getValue());
|
||||
return Status.getEnum(nativeSetContextTimeTicksValue(name, value.getTicks(), piiKind.getValue()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -355,9 +395,9 @@ public class LogManager {
|
|||
*
|
||||
* @param name Name of the context property
|
||||
* @param value Date value of the context property
|
||||
* @return native value of status_t
|
||||
* @return Status enum corresponding to the native API execution status_t.
|
||||
*/
|
||||
public static int setContext(final String name, final Date value) {
|
||||
public static Status setContext(final String name, final Date value) {
|
||||
return setContext(name, value, PiiKind.None);
|
||||
}
|
||||
|
||||
|
@ -369,16 +409,9 @@ public class LogManager {
|
|||
* @param name Name of the context property
|
||||
* @param value Date value of the context property
|
||||
* @param piiKind PIIKind of the context
|
||||
* @return native value of status_t
|
||||
* @return Status enum corresponding to the native API execution status_t.
|
||||
*/
|
||||
public static int setContext(final String name, final Date value, PiiKind piiKind) {
|
||||
if (name == null || name.trim().isEmpty())
|
||||
throw new IllegalArgumentException("name is null or empty");
|
||||
if (value == null)
|
||||
throw new IllegalArgumentException("value is null");
|
||||
if (piiKind == null)
|
||||
throw new IllegalArgumentException("piiKind is null");
|
||||
|
||||
public static Status setContext(final String name, final Date value, final PiiKind piiKind) {
|
||||
return setContext(name, new TimeTicks(value), piiKind);
|
||||
}
|
||||
|
||||
|
@ -392,9 +425,9 @@ public class LogManager {
|
|||
*
|
||||
* @param name Name of the context property
|
||||
* @param value UUID/GUID value of the context property
|
||||
* @return native value of status_t
|
||||
* @return Status enum corresponding to the native API execution status_t.
|
||||
*/
|
||||
public static int setContext(final String name, final UUID value) {
|
||||
public static Status setContext(final String name, final UUID value) {
|
||||
return setContext(name, value, PiiKind.None);
|
||||
}
|
||||
|
||||
|
@ -406,9 +439,9 @@ public class LogManager {
|
|||
* @param name Name of the context property
|
||||
* @param value UUID/GUID value of the context property
|
||||
* @param piiKind PIIKind of the context
|
||||
* @return native value of status_t
|
||||
* @return Status enum corresponding to the native API execution status_t.
|
||||
*/
|
||||
public static int setContext(final String name, final UUID value, PiiKind piiKind) {
|
||||
public static Status setContext(final String name, final UUID value, final PiiKind piiKind) {
|
||||
if (name == null || name.trim().isEmpty())
|
||||
throw new IllegalArgumentException("name is null or empty");
|
||||
if (value == null)
|
||||
|
@ -416,42 +449,83 @@ public class LogManager {
|
|||
if (piiKind == null)
|
||||
throw new IllegalArgumentException("piiKind is null");
|
||||
|
||||
return nativeSetContextGuidValue(name, value.toString(), piiKind.getValue());
|
||||
return Status.getEnum(nativeSetContextGuidValue(name, value.toString(), piiKind.getValue()));
|
||||
}
|
||||
|
||||
private static native int nativeGetLogger();
|
||||
private static native long nativeGetLogger();
|
||||
|
||||
/**
|
||||
* Retrieves the ILogger interface of a Logger instance through which to log telemetry event.
|
||||
*
|
||||
* @return Instance of ILogger
|
||||
* @return Logger instance of the ILogger interface
|
||||
*/
|
||||
public static ILogger GetLogger() {
|
||||
return new Logger(nativeGetLogger());
|
||||
long logger = nativeGetLogger();
|
||||
if (logger == 0)
|
||||
return null;
|
||||
else
|
||||
return new Logger(logger);
|
||||
}
|
||||
|
||||
private static native int nativeGetLoggerWithSource(String source);
|
||||
private static native long nativeGetLoggerWithSource(String source);
|
||||
|
||||
/**
|
||||
* Retrieves the ILogger interface of a Logger instance through which to log telemetry event.
|
||||
*
|
||||
* @param source Source name of events sent by this logger instance
|
||||
* @return Instance of ILogger
|
||||
* @return Logger instance of the ILogger interface
|
||||
*/
|
||||
public static ILogger GetLogger(final String source) {
|
||||
return new Logger(nativeGetLoggerWithSource(source));
|
||||
long logger = nativeGetLoggerWithSource(source);
|
||||
if (logger == 0)
|
||||
return null;
|
||||
else
|
||||
return new Logger(logger);
|
||||
}
|
||||
|
||||
private static native int nativeGetLoggerWithTenantTokenAndSource(String tenantToken, String source);
|
||||
private static native long nativeGetLoggerWithTenantTokenAndSource(String tenantToken, String source);
|
||||
|
||||
/**
|
||||
* Retrieves the ILogger interface of a Logger instance through which to log telemetry event.
|
||||
*
|
||||
* @param tenantToken Token of the tenant with which the application is associated for collecting telemetry
|
||||
* @param source Source name of events sent by this logger instance
|
||||
* @return Instance of ILogger
|
||||
* @return Logger instance of the ILogger interface
|
||||
*/
|
||||
public static ILogger GetLogger(final String tenantToken, final String source) {
|
||||
return new Logger(nativeGetLoggerWithTenantTokenAndSource(tenantToken, source));
|
||||
long logger = nativeGetLoggerWithTenantTokenAndSource(tenantToken, source);
|
||||
if (logger == 0)
|
||||
return null;
|
||||
else
|
||||
return new Logger(logger);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the default DDV with the machine identifier.
|
||||
*
|
||||
* @param machineIdentifier Machine identifier string
|
||||
*/
|
||||
public native static void initializeDiagnosticDataViewer(String machineIdentifier);
|
||||
|
||||
/**
|
||||
* Enables the remote viewer for the default DDV connection.
|
||||
*
|
||||
* @param endpoint End point for the remote DDV
|
||||
* @return boolean value for success or failure
|
||||
*/
|
||||
public native static boolean enableRemoteViewer(String endpoint);
|
||||
|
||||
/**
|
||||
* Disable the default data viewer.
|
||||
*
|
||||
* @return boolean value for success or failure
|
||||
*/
|
||||
public native static boolean disableViewer();
|
||||
|
||||
/**
|
||||
* Check if the DDV viewer is enabled.
|
||||
*
|
||||
* @return boolean value for success or failure
|
||||
*/
|
||||
public native static boolean isViewerEnabled();
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ public enum NetworkCost {
|
|||
|
||||
private final int m_value;
|
||||
|
||||
private NetworkCost(int value) {
|
||||
NetworkCost(int value) {
|
||||
m_value = value;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ public enum NetworkType {
|
|||
/**
|
||||
* Any type of network.
|
||||
*/
|
||||
Any(1),
|
||||
Any(-1),
|
||||
|
||||
/**
|
||||
* The type of network is unknown.
|
||||
|
|
|
@ -16,7 +16,7 @@ class SemanticContext implements ISemanticContext {
|
|||
*
|
||||
* @param nativeISemanticContextPtr
|
||||
*/
|
||||
public SemanticContext(final long nativeISemanticContextPtr) {
|
||||
SemanticContext(final long nativeISemanticContextPtr) {
|
||||
m_nativeISemanticContextPtr = nativeISemanticContextPtr;
|
||||
}
|
||||
|
||||
|
@ -172,7 +172,7 @@ class SemanticContext implements ISemanticContext {
|
|||
*/
|
||||
@Override
|
||||
public void setDeviceClass(final String deviceClass) {
|
||||
setCommonField(Constants.COMMONFIELDS_DEVICE_MAKE, deviceClass);
|
||||
setCommonField(Constants.COMMONFIELDS_DEVICE_CLASS, deviceClass);
|
||||
}
|
||||
|
||||
private native void nativeSetNetworkCost(long nativeISemanticContextPtr, int networkCost);
|
||||
|
@ -243,21 +243,32 @@ class SemanticContext implements ISemanticContext {
|
|||
setCommonField(Constants.COMMONFIELDS_OS_BUILD, osBuild);
|
||||
}
|
||||
|
||||
private native void nativeSetUserId(long nativeISemanticContextPtr, String userId, int PiiKind_Identity);
|
||||
/**
|
||||
* Set the userId context information of telemetry event and default to PiiKind_Identity.
|
||||
*
|
||||
* @param userId Identifier that uniquely identifies a user in the application-specific user namespace
|
||||
*/
|
||||
@Override
|
||||
public void setUserId(final String userId) {
|
||||
setUserId(userId, PiiKind.Identity);
|
||||
}
|
||||
|
||||
private native void nativeSetUserId(long nativeISemanticContextPtr, String userId, int PiiKind);
|
||||
|
||||
/**
|
||||
* Set the userId context information of telemetry event.
|
||||
*
|
||||
* @param userId Identifier that uniquely identifies a user in the application-specific user namespace
|
||||
* @param piiKind_Identity PIIKind of the userId. Default to PiiKind_Identity, set it to PiiKind_None to denote it as non-PII.
|
||||
* @param piiKind PIIKind of the userId. Default to PiiKind_Identity, set it to PiiKind_None to denote it as non-PII.
|
||||
*/
|
||||
@Override
|
||||
public void setUserId(final String userId, final PiiKind piiKind_Identity) {
|
||||
public void setUserId(final String userId, final PiiKind piiKind) {
|
||||
if (userId == null || userId.trim().isEmpty())
|
||||
throw new IllegalArgumentException("userId is null or empty");
|
||||
if (piiKind_Identity == null)
|
||||
if (piiKind == null)
|
||||
throw new IllegalArgumentException("piiKind_Identity is null");
|
||||
|
||||
nativeSetUserId(m_nativeISemanticContextPtr, userId, piiKind_Identity.getValue());
|
||||
nativeSetUserId(m_nativeISemanticContextPtr, userId, piiKind.getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -324,10 +335,12 @@ class SemanticContext implements ISemanticContext {
|
|||
|
||||
/**
|
||||
* Sets the common Part A/B field.
|
||||
*
|
||||
* @param name Field name
|
||||
* @param value Field value in string
|
||||
*/
|
||||
private void setCommonField(final String name, final String value) {
|
||||
@Override
|
||||
public void setCommonField(final String name, final String value) {
|
||||
if (name == null || name.trim().isEmpty())
|
||||
throw new IllegalArgumentException("name is null or empty");
|
||||
if (value == null)
|
||||
|
@ -340,6 +353,7 @@ class SemanticContext implements ISemanticContext {
|
|||
|
||||
/**
|
||||
* Sets the common Part A/B field.
|
||||
*
|
||||
* @param name Field name
|
||||
* @param value Field value
|
||||
*/
|
||||
|
@ -353,10 +367,29 @@ class SemanticContext implements ISemanticContext {
|
|||
nativeSetCommonField(m_nativeISemanticContextPtr, name, value);
|
||||
}
|
||||
|
||||
private native void nativeSetCustomFieldString(long nativeISemanticContextPtr, String name, String value);
|
||||
|
||||
/**
|
||||
* Sets the custom Part C field.
|
||||
*
|
||||
* @param name Field name
|
||||
* @param value Field value in string
|
||||
*/
|
||||
@Override
|
||||
public void setCustomField(final String name, final String value) {
|
||||
if (name == null || name.trim().isEmpty())
|
||||
throw new IllegalArgumentException("name is null or empty");
|
||||
if (value == null)
|
||||
throw new IllegalArgumentException("value is null");
|
||||
|
||||
nativeSetCustomFieldString(m_nativeISemanticContextPtr, name, value);
|
||||
}
|
||||
|
||||
private native void nativeSetCustomField(long nativeISemanticContextPtr, String name, EventProperty value);
|
||||
|
||||
/**
|
||||
* Sets the custom Part C field.
|
||||
*
|
||||
* @param name Field name
|
||||
* @param value Field value
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
package com.microsoft.applications.events;
|
||||
|
||||
class StatusValues {
|
||||
static final int VALUE_EFAIL = -1;
|
||||
static final int VALUE_SUCCESS = 0;
|
||||
static final int VALUE_EPERM = 1;
|
||||
static final int VALUE_EALREADY = 103;
|
||||
static final int VALUE_ENOSYS = 40;
|
||||
static final int VALUE_ENOTSUP = 129;
|
||||
}
|
||||
|
||||
/**
|
||||
* The status enum corresponding to the native API execution status_t.
|
||||
*/
|
||||
public enum Status {
|
||||
/**
|
||||
* General failure
|
||||
*/
|
||||
EFAIL(StatusValues.VALUE_EFAIL),
|
||||
|
||||
/**
|
||||
* Success
|
||||
*/
|
||||
SUCCESS(StatusValues.VALUE_SUCCESS),
|
||||
|
||||
/**
|
||||
* Permission denied
|
||||
*/
|
||||
EPERM(StatusValues.VALUE_EPERM),
|
||||
|
||||
/**
|
||||
* Already done / already in progress
|
||||
*/
|
||||
EALREADY(StatusValues.VALUE_EALREADY),
|
||||
|
||||
/**
|
||||
* Not implemented or no-op
|
||||
*/
|
||||
ENOSYS(StatusValues.VALUE_ENOSYS),
|
||||
|
||||
/**
|
||||
* Not supported.
|
||||
*/
|
||||
ENOTSUP(StatusValues.VALUE_ENOTSUP);
|
||||
|
||||
private final int m_value;
|
||||
|
||||
Status(int value) {
|
||||
m_value = value;
|
||||
}
|
||||
|
||||
static Status getEnum(int value) {
|
||||
switch (value) {
|
||||
case StatusValues.VALUE_EFAIL :
|
||||
return EFAIL;
|
||||
case StatusValues.VALUE_SUCCESS :
|
||||
return SUCCESS;
|
||||
case StatusValues.VALUE_EPERM :
|
||||
return EPERM;
|
||||
case StatusValues.VALUE_EALREADY :
|
||||
return EALREADY;
|
||||
case StatusValues.VALUE_ENOSYS :
|
||||
return ENOSYS;
|
||||
case StatusValues.VALUE_ENOTSUP :
|
||||
return ENOTSUP;
|
||||
default :
|
||||
throw new IllegalArgumentException("Unsupported value: " + value);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,14 +9,13 @@ public enum TicketType {
|
|||
AAD_User(5),
|
||||
AAD_JWT(6);
|
||||
|
||||
|
||||
private final int m_value;
|
||||
|
||||
private TicketType(int value) {
|
||||
TicketType(int value) {
|
||||
m_value = value;
|
||||
}
|
||||
|
||||
int getValue() {
|
||||
return m_value;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -23,7 +23,7 @@ public enum TransmitProfile {
|
|||
|
||||
private final int m_value;
|
||||
|
||||
private TransmitProfile(int value) {
|
||||
TransmitProfile(int value) {
|
||||
m_value = value;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include <jni.h>
|
||||
#include <sstream>
|
||||
//#include <sstream>
|
||||
#include <include/public/EventProperties.hpp>
|
||||
#include "Version.hpp"
|
||||
|
||||
|
|
|
@ -1,105 +1,98 @@
|
|||
//#include "http/HttpClient_Android.hpp"
|
||||
#include "LogManagerBase.hpp"
|
||||
#include "LogManager.hpp"
|
||||
#include "ILogger.hpp"
|
||||
#include "JniUtils.hpp"
|
||||
//#include <algorithm>
|
||||
//#include <cstdio>
|
||||
//#include <sstream>
|
||||
//#include <vector>
|
||||
#include "LogManager.hpp"
|
||||
#include "modules/dataviewer/DefaultDataViewer.hpp"
|
||||
|
||||
//constexpr static auto Tag = "LogManagerBase_jni";
|
||||
using namespace MAT;
|
||||
LOGMANAGER_INSTANCE
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_com_microsoft_applications_events_LogManager_initializeWithoutTenantToken(
|
||||
JNIEXPORT jlong JNICALL Java_com_microsoft_applications_events_LogManager_nativeInitializeWithoutTenantToken(
|
||||
JNIEnv* /* env */,
|
||||
jclass /* this */) {
|
||||
ILogger* logger = Microsoft::Applications::Events::LogManager::Initialize();
|
||||
ILogger* logger = LogManager::Initialize();
|
||||
return reinterpret_cast<jlong>(logger);
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_com_microsoft_applications_events_LogManager_initializeWithTenantToken(
|
||||
JNIEXPORT jlong JNICALL Java_com_microsoft_applications_events_LogManager_nativeInitializeWithTenantToken(
|
||||
JNIEnv* env,
|
||||
jclass /* this */,
|
||||
jstring jTenantToken) {
|
||||
auto tenantToken = JStringToStdString(env, jTenantToken);
|
||||
ILogger* logger = Microsoft::Applications::Events::LogManager::Initialize(tenantToken);
|
||||
ILogger* logger = LogManager::Initialize(tenantToken);
|
||||
return reinterpret_cast<jlong>(logger);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_com_microsoft_applications_events_LogManager_flushAndTeardown(
|
||||
JNIEXPORT jint JNICALL Java_com_microsoft_applications_events_LogManager_nativeFlushAndTeardown(
|
||||
JNIEnv* /* env */,
|
||||
jclass /* this */) {
|
||||
return static_cast<jint>(Microsoft::Applications::Events::LogManager::FlushAndTeardown());
|
||||
return static_cast<jint>(LogManager::FlushAndTeardown());
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_com_microsoft_applications_events_LogManager_uploadNow(
|
||||
JNIEXPORT jint JNICALL Java_com_microsoft_applications_events_LogManager_nativeFlush(
|
||||
JNIEnv* /* env */,
|
||||
jclass /* this */) {
|
||||
return static_cast<jint>(Microsoft::Applications::Events::LogManager::UploadNow());
|
||||
return static_cast<jint>(LogManager::Flush());
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_com_microsoft_applications_events_LogManager_flush(
|
||||
JNIEXPORT jint JNICALL Java_com_microsoft_applications_events_LogManager_nativeUploadNow(
|
||||
JNIEnv* /* env */,
|
||||
jclass /* this */) {
|
||||
return static_cast<jint>(Microsoft::Applications::Events::LogManager::Flush());
|
||||
return static_cast<jint>(LogManager::UploadNow());
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_com_microsoft_applications_events_LogManager_pauseTransmission(
|
||||
JNIEXPORT jint JNICALL Java_com_microsoft_applications_events_LogManager_nativePauseTransmission(
|
||||
JNIEnv* /* env */,
|
||||
jclass /* this */) {
|
||||
return static_cast<jint>(Microsoft::Applications::Events::LogManager::PauseTransmission());
|
||||
return static_cast<jint>(LogManager::PauseTransmission());
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_com_microsoft_applications_events_LogManager_resumeTransmission(
|
||||
JNIEXPORT jint JNICALL Java_com_microsoft_applications_events_LogManager_nativeResumeTransmission(
|
||||
JNIEnv* /* env */,
|
||||
jclass /* this */) {
|
||||
return static_cast<jint>(Microsoft::Applications::Events::LogManager::ResumeTransmission());
|
||||
return static_cast<jint>(LogManager::ResumeTransmission());
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_com_microsoft_applications_events_LogManager_setIntTransmitProfile(
|
||||
JNIEXPORT jint JNICALL Java_com_microsoft_applications_events_LogManager_nativeSetIntTransmitProfile(
|
||||
JNIEnv* /* env */,
|
||||
jclass /* this */,
|
||||
jint jProfile) {
|
||||
return static_cast<jint>(Microsoft::Applications::Events::LogManager::SetTransmitProfile(
|
||||
return static_cast<jint>(LogManager::SetTransmitProfile(
|
||||
static_cast<TransmitProfile>(jProfile)));
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_com_microsoft_applications_events_LogManager_setTransmitProfileString(
|
||||
JNIEXPORT jint JNICALL Java_com_microsoft_applications_events_LogManager_nativeSetTransmitProfileString(
|
||||
JNIEnv* env,
|
||||
jclass /* this */,
|
||||
jstring jstrProfile) {
|
||||
return static_cast<jint>(Microsoft::Applications::Events::LogManager::SetTransmitProfile(JStringToStdString(env, jstrProfile)));
|
||||
return static_cast<jint>(LogManager::SetTransmitProfile(JStringToStdString(env, jstrProfile)));
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_com_microsoft_applications_events_LogManager_loadTransmitProfilesString(
|
||||
JNIEXPORT jint JNICALL Java_com_microsoft_applications_events_LogManager_nativeLoadTransmitProfilesString(
|
||||
JNIEnv* env,
|
||||
jclass /* this */,
|
||||
jstring jstrProfilesJson) {
|
||||
return static_cast<jint>(Microsoft::Applications::Events::LogManager::LoadTransmitProfiles(JStringToStdString(env, jstrProfilesJson)));
|
||||
return static_cast<jint>(LogManager::LoadTransmitProfiles(JStringToStdString(env, jstrProfilesJson)));
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_com_microsoft_applications_events_LogManager_resetTransmitProfiles(
|
||||
JNIEXPORT jint JNICALL Java_com_microsoft_applications_events_LogManager_nativeResetTransmitProfiles(
|
||||
JNIEnv* /* env */,
|
||||
jclass /* this */) {
|
||||
return static_cast<jint>(Microsoft::Applications::Events::LogManager::ResetTransmitProfiles());
|
||||
return static_cast<jint>(LogManager::ResetTransmitProfiles());
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL Java_com_microsoft_applications_events_LogManager_getTransmitProfileName(
|
||||
JNIEnv* env,
|
||||
jclass /* this */) {
|
||||
std::string profileName = Microsoft::Applications::Events::LogManager::GetTransmitProfileName();
|
||||
std::string profileName = LogManager::GetTransmitProfileName();
|
||||
return static_cast<jstring>(env->NewStringUTF(profileName.c_str()));
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_com_microsoft_applications_events_LogManager_nativeGetSemanticContext(
|
||||
JNIEnv* env,
|
||||
jclass /* this */) {
|
||||
return reinterpret_cast<jlong>(Microsoft::Applications::Events::LogManager::GetSemanticContext());
|
||||
return reinterpret_cast<jlong>(LogManager::GetSemanticContext());
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_com_microsoft_applications_events_LogManager_nativeSetContextStringValue(
|
||||
|
@ -110,7 +103,7 @@ JNIEXPORT jlong JNICALL Java_com_microsoft_applications_events_LogManager_native
|
|||
jint piiKind) {
|
||||
auto name = JStringToStdString(env, jstrName);
|
||||
auto value = JStringToStdString(env, jstrValue);
|
||||
return static_cast<jint>(Microsoft::Applications::Events::LogManager::SetContext(name, value, static_cast<PiiKind>(piiKind)));
|
||||
return static_cast<jint>(LogManager::SetContext(name, value, static_cast<PiiKind>(piiKind)));
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_com_microsoft_applications_events_LogManager_nativeSetContextIntValue(
|
||||
|
@ -120,7 +113,7 @@ JNIEXPORT jlong JNICALL Java_com_microsoft_applications_events_LogManager_native
|
|||
jint jValue,
|
||||
jint piiKind) {
|
||||
auto name = JStringToStdString(env, jstrName);
|
||||
return static_cast<jint>(Microsoft::Applications::Events::LogManager::SetContext(name, static_cast<int32_t>(jValue), static_cast<PiiKind>(piiKind)));
|
||||
return static_cast<jint>(LogManager::SetContext(name, static_cast<int32_t>(jValue), static_cast<PiiKind>(piiKind)));
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_com_microsoft_applications_events_LogManager_nativeSetContextLongValue(
|
||||
|
@ -130,7 +123,7 @@ JNIEXPORT jlong JNICALL Java_com_microsoft_applications_events_LogManager_native
|
|||
jlong jValue,
|
||||
jint piiKind) {
|
||||
auto name = JStringToStdString(env, jstrName);
|
||||
return static_cast<jint>(Microsoft::Applications::Events::LogManager::SetContext(name, static_cast<int64_t>(jValue), static_cast<PiiKind>(piiKind)));
|
||||
return static_cast<jint>(LogManager::SetContext(name, static_cast<int64_t>(jValue), static_cast<PiiKind>(piiKind)));
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_com_microsoft_applications_events_LogManager_nativeSetContextDoubleValue(
|
||||
|
@ -140,7 +133,7 @@ JNIEXPORT jlong JNICALL Java_com_microsoft_applications_events_LogManager_native
|
|||
jdouble jValue,
|
||||
jint piiKind) {
|
||||
auto name = JStringToStdString(env, jstrName);
|
||||
return static_cast<jint>(Microsoft::Applications::Events::LogManager::SetContext(name, static_cast<double>(jValue), static_cast<PiiKind>(piiKind)));
|
||||
return static_cast<jint>(LogManager::SetContext(name, static_cast<double>(jValue), static_cast<PiiKind>(piiKind)));
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_com_microsoft_applications_events_LogManager_nativeSetContextBoolValue(
|
||||
|
@ -150,7 +143,7 @@ JNIEXPORT jlong JNICALL Java_com_microsoft_applications_events_LogManager_native
|
|||
jboolean jValue,
|
||||
jint piiKind) {
|
||||
auto name = JStringToStdString(env, jstrName);
|
||||
return static_cast<jint>(Microsoft::Applications::Events::LogManager::SetContext(name, static_cast<bool>(jValue), static_cast<PiiKind>(piiKind)));
|
||||
return static_cast<jint>(LogManager::SetContext(name, static_cast<bool>(jValue), static_cast<PiiKind>(piiKind)));
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_com_microsoft_applications_events_LogManager_nativeSetContextTimeTicksValue(
|
||||
|
@ -160,7 +153,7 @@ JNIEXPORT jlong JNICALL Java_com_microsoft_applications_events_LogManager_native
|
|||
jlong jValue,
|
||||
jint piiKind) {
|
||||
auto name = JStringToStdString(env, jstrName);
|
||||
return static_cast<jint>(Microsoft::Applications::Events::LogManager::SetContext(name, time_ticks_t(static_cast<uint64_t>(jValue)), static_cast<PiiKind>(piiKind)));
|
||||
return static_cast<jint>(LogManager::SetContext(name, time_ticks_t(static_cast<uint64_t>(jValue)), static_cast<PiiKind>(piiKind)));
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_com_microsoft_applications_events_LogManager_nativeSetContextGuidValue(
|
||||
|
@ -171,22 +164,22 @@ JNIEXPORT jlong JNICALL Java_com_microsoft_applications_events_LogManager_native
|
|||
jint piiKind) {
|
||||
auto name = JStringToStdString(env, jstrName);
|
||||
auto value = JStringToStdString(env, jstrValue);
|
||||
return static_cast<jint>(Microsoft::Applications::Events::LogManager::SetContext(name, GUID_t(value.c_str()), static_cast<PiiKind>(piiKind)));
|
||||
return static_cast<jint>(LogManager::SetContext(name, GUID_t(value.c_str()), static_cast<PiiKind>(piiKind)));
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_com_microsoft_applications_events_LogManager_nativeGetLogger(
|
||||
JNIEnv* /* env */,
|
||||
jclass /* this */){
|
||||
ILogger* logger = (Microsoft::Applications::Events::LogManager::GetLogger());
|
||||
jclass /* this */) {
|
||||
ILogger* logger = LogManager::GetLogger();
|
||||
return reinterpret_cast<jlong>(logger);
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_com_microsoft_applications_events_LogManager_nativeGetLoggerWithSource(
|
||||
JNIEnv* env,
|
||||
jclass /* this */,
|
||||
jstring jstrSource){
|
||||
jstring jstrSource) {
|
||||
auto source = JStringToStdString(env, jstrSource);
|
||||
ILogger* logger = (Microsoft::Applications::Events::LogManager::GetLogger(source));
|
||||
ILogger* logger = LogManager::GetLogger(source);
|
||||
return reinterpret_cast<jlong>(logger);
|
||||
}
|
||||
|
||||
|
@ -197,8 +190,45 @@ JNIEXPORT jlong JNICALL Java_com_microsoft_applications_events_LogManager_native
|
|||
jstring jstrSource){
|
||||
auto tenantToken = JStringToStdString(env, jstrTenantToken);
|
||||
auto source = JStringToStdString(env, jstrSource);
|
||||
ILogger* logger = (Microsoft::Applications::Events::LogManager::GetLogger(tenantToken, source));
|
||||
ILogger* logger = LogManager::GetLogger(tenantToken, source);
|
||||
return reinterpret_cast<jlong>(logger);
|
||||
}
|
||||
|
||||
std::shared_ptr<DefaultDataViewer> g_spDefaultDataViewer;
|
||||
|
||||
JNIEXPORT void JNICALL Java_com_microsoft_applications_events_LogManager_initializeDiagnosticDataViewer(
|
||||
JNIEnv* env,
|
||||
jclass /* this */,
|
||||
jstring jstrMachineIdentifier) {
|
||||
auto machineIdentifier = JStringToStdString(env, jstrMachineIdentifier);
|
||||
g_spDefaultDataViewer = std::make_shared<DefaultDataViewer>(nullptr, machineIdentifier);
|
||||
LogManager::GetDataViewerCollection().RegisterViewer(std::static_pointer_cast<IDataViewer>(g_spDefaultDataViewer));
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_com_microsoft_applications_events_LogManager_enableRemoteViewer(
|
||||
JNIEnv* env,
|
||||
jclass /* this */,
|
||||
jstring jstrEndpoint) {
|
||||
if (g_spDefaultDataViewer == nullptr)
|
||||
return false;
|
||||
|
||||
auto endpoint = JStringToStdString(env, jstrEndpoint);
|
||||
return g_spDefaultDataViewer->EnableRemoteViewer(endpoint);
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_com_microsoft_applications_events_LogManager_disableViewer(
|
||||
JNIEnv* env,
|
||||
jclass /* this */) {
|
||||
if (g_spDefaultDataViewer == nullptr)
|
||||
return false;
|
||||
|
||||
return g_spDefaultDataViewer->DisableViewer();
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_com_microsoft_applications_events_LogManager_isViewerEnabled(
|
||||
JNIEnv* env,
|
||||
jclass /* this */) {
|
||||
return LogManager::GetDataViewerCollection().IsViewerEnabled();
|
||||
}
|
||||
|
||||
}
|
|
@ -54,9 +54,9 @@ JNIEXPORT void JNICALL Java_com_microsoft_applications_events_SemanticContext_na
|
|||
jobject /* this */,
|
||||
jlong nativeSemanticContextPtr,
|
||||
jstring jstrUserId,
|
||||
jint PiiKind_Identity) {
|
||||
jint piiKind) {
|
||||
auto userId = JStringToStdString(env, jstrUserId);
|
||||
reinterpret_cast<ISemanticContext*>(nativeSemanticContextPtr)->SetUserId(userId, static_cast<PiiKind>(PiiKind_Identity));
|
||||
reinterpret_cast<ISemanticContext*>(nativeSemanticContextPtr)->SetUserId(userId, static_cast<PiiKind>(piiKind));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_com_microsoft_applications_events_SemanticContext_nativeSetCommonFieldString(
|
||||
|
@ -77,7 +77,19 @@ JNIEXPORT void JNICALL Java_com_microsoft_applications_events_SemanticContext_na
|
|||
jstring jstrName,
|
||||
jobject jEventProperty) {
|
||||
auto name = JStringToStdString(env, jstrName);
|
||||
reinterpret_cast<ISemanticContext*>(nativeSemanticContextPtr)->SetCommonField(name, GetEventProperty(env, jEventProperty));
|
||||
auto prop = GetEventProperty(env, jEventProperty);
|
||||
reinterpret_cast<ISemanticContext*>(nativeSemanticContextPtr)->SetCommonField(name, prop);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_com_microsoft_applications_events_SemanticContext_nativeSetCustomFieldString(
|
||||
JNIEnv* env,
|
||||
jobject /* this */,
|
||||
jlong nativeSemanticContextPtr,
|
||||
jstring jstrName,
|
||||
jstring jstrValue) {
|
||||
auto name = JStringToStdString(env, jstrName);
|
||||
auto value = JStringToStdString(env, jstrValue);
|
||||
reinterpret_cast<ISemanticContext*>(nativeSemanticContextPtr)->SetCustomField(name, value);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_com_microsoft_applications_events_SemanticContext_nativeSetCustomField(
|
||||
|
@ -87,7 +99,8 @@ JNIEXPORT void JNICALL Java_com_microsoft_applications_events_SemanticContext_na
|
|||
jstring jstrName,
|
||||
jobject jEventProperty) {
|
||||
auto name = JStringToStdString(env, jstrName);
|
||||
reinterpret_cast<ISemanticContext*>(nativeSemanticContextPtr)->SetCustomField(name, GetEventProperty(env, jEventProperty));
|
||||
auto prop = GetEventProperty(env, jEventProperty);
|
||||
reinterpret_cast<ISemanticContext*>(nativeSemanticContextPtr)->SetCustomField(name, prop);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_com_microsoft_applications_events_SemanticContext_nativeSetTicket (
|
||||
|
|
Загрузка…
Ссылка в новой задаче