public static void LogMessage(LogSeverity severity, string message, string additionalInfo = "", string correlationId = null)
        {
            LogDeviceDetails logModel = new LogDeviceDetails(severity, message, additionalInfo);
            LogSQLiteModel   dbModel  = new LogSQLiteModel(logModel, null, null, correlationId);

            ServiceLocator.Current.GetInstance <ILoggingManager>().SaveNewLog(dbModel);
        }
Exemplo n.º 2
0
        public LogSQLiteModel(LogDeviceDetails info, LogApiDetails apiDetails = null, LogExceptionDetails e = null)
        {
            ReportedTime    = info.ReportedTime;
            Severity        = info.Severity.ToString();
            Description     = info.Description;
            ApiVersion      = info.ApiVersion;
            BuildVersion    = info.BuildVersion;
            BuildNumber     = info.BuildNumber;
            DeviceOSVersion = info.DeviceOSVersion;
            AdditionalInfo  = info.AdditionalInfo;

            if (apiDetails != null)
            {
                Api             = apiDetails.Api;
                ApiErrorCode    = apiDetails.ApiErrorCode;
                ApiErrorMessage = apiDetails.ApiErrorMessage;
            }

            if (e != null)
            {
                ExceptionType            = e.ExceptionType;
                ExceptionMessage         = e.ExceptionMessage;
                ExceptionStackTrace      = e.ExceptionStackTrace;
                InnerExceptionType       = e.InnerExceptionType;
                InnerExceptionMessage    = e.InnerExceptionMessage;
                InnerExceptionStackTrace = e.InnerExceptionStackTrace;
            }
        }
Exemplo n.º 3
0
        public async void SystemDateTimeIsIncorrect_NtpIsEqualToPersisted_ShouldUseDefault()
        {
            SystemTime.ResetDateTime();
            DateTime currentTime = DateTime.UtcNow.AddYears(-3);

            SystemTime.SetDateTime(currentTime);

            NTPUtcDateTime ntpUtcDateTime =
                Mock.Of <NTPUtcDateTime>(ntp =>
                                         ntp.GetNTPUtcDateTime() == Task.FromResult(LocalPreferencesHelper.LastNTPUtcDateTime));

            try
            {
                new FetchExposureKeysHelper().UpdateLastNTPDateTime(ntpUtcDateTime);
            }
            catch
            {
                // ignore as ZipDownloader is not mocked in this test
            }
            LogDeviceDetails logModel =
                new LogDeviceDetails(
                    LogSeverity.WARNING,
                    "message",
                    "additionalInfo");

            Assert.Equal(Conf.DATE_TIME_REPLACEMENT, logModel.ReportedTime);

            SystemTime.ResetDateTime();
        }
Exemplo n.º 4
0
        public async void SystemDateTimeIsCorrect_ShouldUseSystemDateTime()
        {
            SystemTime.ResetDateTime();
            DateTime currentTime = DateTime.UtcNow;

            SystemTime.SetDateTime(currentTime);

            try
            {
                new FetchExposureKeysHelper()
                .UpdateLastNTPDateTime();
            }
            catch
            {
                // ignore as ZipDownloader is not mocked in this test
            }

            LogDeviceDetails logModel =
                new LogDeviceDetails(
                    LogSeverity.WARNING,
                    "message",
                    "additionalInfo");

            Assert.Equal(currentTime, logModel.ReportedTime);

            SystemTime.ResetDateTime();
        }
Exemplo n.º 5
0
        public async void SystemDateTimeIsIncorrectInTheFuture_ShouldUseNTP()
        {
            SystemTime.ResetDateTime();
            DateTime currentTime = DateTime.UtcNow.AddYears(3);

            SystemTime.SetDateTime(currentTime);

            try
            {
                await new FetchExposureKeysHelper()
                .FetchExposureKeyBatchFilesFromServerAsync(
                    null,
                    CancellationToken.None);
            }
            catch
            {
                // ignore as ZipDownloader is not mocked in this test
            }

            LogDeviceDetails logModel =
                new LogDeviceDetails(
                    LogSeverity.WARNING,
                    "message",
                    "additionalInfo");

            Assert.True(currentTime > logModel.ReportedTime);

            SystemTime.ResetDateTime();
        }
        public static void LogException(LogSeverity severity, Exception e, string contextDescription, string additionalInfo = "", string correlationId = null)
        {
            LogDeviceDetails    logModel = new LogDeviceDetails(severity, contextDescription, additionalInfo);
            LogExceptionDetails eModel   = new LogExceptionDetails(e);
            LogSQLiteModel      dbModel  = new LogSQLiteModel(logModel, null, eModel, correlationId);

            ServiceLocator.Current.GetInstance <ILoggingManager>().SaveNewLog(dbModel);
        }
        public static void LogApiError(LogSeverity severity, ApiResponse apiResponse, bool erroredSilently,
                                       string additionalInfo = "", string overwriteMessage = null)
        {
            string errorMessage = overwriteMessage ?? apiResponse.ErrorLogMessage;
            string message      = errorMessage
                                  + (erroredSilently ? " (silent)" : " (error shown)");
            LogDeviceDetails    logModel = new LogDeviceDetails(severity, message, additionalInfo);
            LogApiDetails       apiModel = new LogApiDetails(apiResponse);
            LogExceptionDetails eModel   = null;

            if (apiResponse.Exception != null)
            {
                eModel = new LogExceptionDetails(apiResponse.Exception);
            }
            LogSQLiteModel dbModel = new LogSQLiteModel(logModel, apiModel, eModel);

            ServiceLocator.Current.GetInstance <ILoggingManager>().SaveNewLog(dbModel);
        }