Ejemplo n.º 1
0
 // We use the same HttpClient for all calls to the same subscription; this allows DNS and proxy details to be
 // cached across requests. Note that HttpClient allows parallel operations.
 internal static HttpClient CreateHttpClient (Subscription subscription, string msVersion, Func<IEnumerable<TraceListener>> listenerFunc)
 {
     var handler = new WebRequestHandler();
     handler.ClientCertificates.Add(subscription.ManagementCertificate);
     var logger = new LoggingHandler(handler, listenerFunc);
     var client = new HttpClient(logger, true);
     client.DefaultRequestHeaders.Add("x-ms-version", msVersion);
     return client;
 }
Ejemplo n.º 2
0
    private HttpClient CreateRetryClient(HttpMessageHandler messageHandler)
    {
        var loggingHandler = new LoggingHandler(messageHandler, Logger);
        var retryHandler   = new RetryHandler(loggingHandler, Logger);

        return(new HttpClient(retryHandler)
        {
            BaseAddress = base.HttpClient.BaseAddress
        });
    }
Ejemplo n.º 3
0
        public void Dispose()
        {
            if (_loggingHandler != null)
            {
                _loggingHandler.Dispose();
                _loggingHandler = null;
            }

            //base.Dispose(disposing);
        }
Ejemplo n.º 4
0
 public EmployeesRepository()
 {
     //Repository Initializations
     _configurationHandler = new ConfigurationHandler();
     _loggingHandler       = new LoggingHandler();
     _dataHandler          = new DataHandler();
     _connectionString     = _configurationHandler.ConnectionString;
     _connectionProvider   = _configurationHandler.ConnectionProvider;
     _dbProviderFactory    = DbProviderFactories.GetFactory(_connectionProvider);
 }
Ejemplo n.º 5
0
        public void UpdateUserAndRoles(UserDomain userDomain)
        {
            // PATCH /users

            try
            {
                var userEntity = Context.Users.FirstOrDefault(u => u.Id == userDomain.Id);

                if (userEntity == null)
                {
                    throw new UseCaseException {
                              UserErrorMessage = $"User with ID '{userDomain.Id}' could not be found"
                    }
                }
                ;

                userEntity.Email     = userDomain.Email;
                userEntity.Name      = userDomain.Name;
                userEntity.Status    = userDomain.Status;
                userEntity.CreatedAt = userDomain.CreatedAt;
                userEntity.SubId     = userDomain.SubId;
                Context.SaveChanges();

                // add any role associations this user does not already have
                if (userDomain.UserRoles != null)
                {
                    // Since we are updating the user, clear any current role associations even if the request
                    // contains an empty list of roles. The behaviour is to clear the associated roles if an empty
                    // list of roles is provided
                    ClearUserRoles(userEntity.Id);

                    var rolesInDomain = GetRoleNamesFromUserDomain(userDomain);
                    if (rolesInDomain != null)
                    {
                        // add any valid new roles
                        var validRoles = UserRoleValidator.ToValidList(rolesInDomain);

                        if (validRoles.Any())
                        {
                            AddRolesToUser(userEntity.Id, validRoles);
                        }
                    }
                }
            }
            catch (DbUpdateException dbe)
            {
                HandleDbUpdateException(dbe);
            }
            catch (Exception e)
            {
                LoggingHandler.LogError(e.Message);
                LoggingHandler.LogError(e.StackTrace);
                throw;
            }
        }
        private void Player_SongStopped(object sender, EventArgs e)
        {
            Title           = WindowName;
            TitleLabel.Text = ArtistLabel.Text = Properties.Resources.MAINWINDOW_NOTHINGPLAYING;
            ProgressTimer.Stop();
            CoverArtBox.Source = null;
            SetIntegrations(PlaybackStatus.Stopped);
            SetCoverArtVisibility(false);

            LoggingHandler.Log("Stopping!");
        }
        public async Task SendMessage(NotifyMessageTypes messageType, string[] addresses, string message)
        {
            if (messageType == null || addresses == null)
            {
                LoggingHandler.LogError("Notify request with invalid arguments");
                throw new ArgumentException("Notify request with invalid arguments");
            }
            var template        = string.Empty;
            var personalisation = new Dictionary <string, dynamic>();

            switch (messageType)
            {
            case NotifyMessageTypes.Reminder:
                template = _reminderTemplate;
                break;

            case NotifyMessageTypes.AdminNotification:
                template = _adminNotificationTemplate;
                break;

            case NotifyMessageTypes.StatusUpdate:
                template = _statusTemplate;
                break;

            case NotifyMessageTypes.NotReverified:
                template = _notReverifiedTemplate;
                break;

            case NotifyMessageTypes.NotApproved:
                template = _notApprovedTemplate;
                personalisation.Add("status_message", message ?? "");
                break;
            }

            try
            {
                for (int a = 0; a < addresses.Length; a++)
                {
                    await _client.SendEmailAsync(addresses[a], template, personalisation).ConfigureAwait(false);
                }
            }
            catch (NotifyClientException e)
            {
                LoggingHandler.LogError("Gov Notify send error");
                LoggingHandler.LogError(e.Message);
                LoggingHandler.LogError(e.StackTrace);
            }
            catch (Exception e)
            {
                LoggingHandler.LogError(e.Message);
                LoggingHandler.LogError(e.StackTrace);
                throw;
            }
        }
        public async Task <SynonymsResponse> ExecuteUpdate(string accessToken, SynonymUpdateRequest requestParams)
        {
            LoggingHandler.LogInfo("Initiating update process.");
            SynonymsResponse response = new SynonymsResponse();

            await UpdateSynonymChanges(accessToken, requestParams.GoogleFileId, requestParams.SheetName,
                                       requestParams.SheetRange, requestParams.GoogleApiKey).ConfigureAwait(false);

            response.Success = true;
            return(response);
        }
        public GitLabTestContext(TestContext testOutput, HttpClientHandler handler = null)
        {
            TestContext = testOutput;

            _loggingHandler = new LoggingHandler();

            _loggingHandler.InnerHandler = handler ?? new HttpClientHandler();

            _httpClient = new HttpClient(_loggingHandler, disposeHandler: true);
            AdminClient = CreateClient(DockerContainer.AdminUserToken);
        }
        public void HandleAsync_WithGenericResponse_CallsInnerHandleAsync()
        {
            var loggerMock     = new Mock <ILogger>();
            var handlerMock    = new Mock <IRequestHandler <TestRequestWithResponse, TestResponse> >();
            var loggingHandler = new LoggingHandler <TestRequestWithResponse, TestResponse>(loggerMock.Object, handlerMock.Object);
            var request        = new TestRequestWithResponse();

            loggingHandler.HandleAsync(request);

            handlerMock.Verify(x => x.HandleAsync(request), Times.Once);
        }
        public void TestServerStreamingWithException()
        {
            GoogleAdsConfig config  = new GoogleAdsConfig();
            LoggingHandler  handler = new LoggingHandler(config);

            handler.WriteSummaryLogs = delegate(LogEntry logEntry)
            {
                Assert.AreEqual(config.ServerUrl, logEntry.Host);
                Assert.AreEqual(TEST_METHOD_IN_LOGS, logEntry.Method);
                CompareMetadata(TEST_REQUEST_METADATA, logEntry.RequestHeaders);
                Assert.True(logEntry.IsFailure);
                HelloException helloException = logEntry.Exception as HelloException;
                Assert.NotNull(helloException);

                Assert.AreEqual(TEST_REQUEST_ID, helloException.RequestId);

                Assert.NotNull(helloException.Failure);
                Assert.AreEqual(1, helloException.Failure.Errors.Count);
                Assert.NotNull(helloException.Failure.Errors[0].ErrorCode);
                Assert.NotNull(helloException.Failure.Errors[0].ErrorCode.RequestError);
            };
            handler.WriteDetailedLogs = delegate(LogEntry logEntry)
            {
                Assert.AreEqual(config.ServerUrl, logEntry.Host);
                Assert.AreEqual(TEST_METHOD_IN_LOGS, logEntry.Method);
                CompareMetadata(TEST_REQUEST_METADATA, logEntry.RequestHeaders);
                CompareMetadata(TEST_RESPONSE_METADATA, logEntry.ResponseHeaders);
                Assert.AreSame(TEST_REQUEST, logEntry.Request);

                // Response is null if there's an exception.
                Assert.IsNull(logEntry.Response);

                Assert.AreEqual(TEST_CUSTOMER_ID, logEntry.CustomerId);
                Assert.True(logEntry.IsFailure);
                HelloException helloException = logEntry.Exception as HelloException;
                Assert.NotNull(helloException);

                Assert.AreEqual(TEST_REQUEST_ID, helloException.RequestId);

                Assert.NotNull(helloException.Failure);
                Assert.AreEqual(1, helloException.Failure.Errors.Count);
                Assert.NotNull(helloException.Failure.Errors[0].ErrorCode);
                Assert.NotNull(helloException.Failure.Errors[0].ErrorCode.RequestError);
            };

            ClientInterceptorContext <HelloRequest, HelloResponse> context =
                GetClientInterceptorContext();
            AsyncServerStreamingCall <HelloResponse> call =
                StreamingContinuationWithException <HelloResponse>();

            handler.HandleAsyncServerStreamingLogging(TEST_REQUEST,
                                                      null, context, new AggregateException(TEST_EXCEPTION),
                                                      call);
        }
Ejemplo n.º 12
0
        // We use the same HttpClient for all calls to the same subscription; this allows DNS and proxy details to be
        // cached across requests. Note that HttpClient allows parallel operations.
        internal static HttpClient CreateHttpClient(Subscription subscription, string msVersion, Func <IEnumerable <TraceListener> > listenerFunc)
        {
            var handler = new WebRequestHandler();

            handler.ClientCertificates.Add(subscription.ManagementCertificate);
            var logger = new LoggingHandler(handler, listenerFunc);
            var client = new HttpClient(logger, true);

            client.DefaultRequestHeaders.Add("x-ms-version", msVersion);
            return(client);
        }
Ejemplo n.º 13
0
        public DiscordIntegration()
        {
            LoggingHandler.Log("Starting Discord integration");

            client = new DiscordRpcClient("656678380283887626");
            client.Initialize();
            client.OnRpcMessage += (sender, e) =>
            {
                LoggingHandler.Log($"Discord: {e.Type}");
            };
        }
Ejemplo n.º 14
0
        public OrganisationDomain AssociateUserWithOrganisation(int userId, int organisationId)
        {
            OrganisationDomain response = null;

            try
            {
                // check organisation actually exists before creating association in database
                var orgEntity = Context.Organisations.FirstOrDefault(o => o.Id == organisationId);

                if (orgEntity == null)
                {
                    throw new UseCaseException()
                          {
                              UserErrorMessage = $"The supplied organisation ID '{organisationId}' was not found",
                              DevErrorMessage  = $"The [organisations] table does not contain an organisation with ID = {organisationId}"
                          };
                }

                var userOrg = Context.UserOrganisations.FirstOrDefault(u => u.UserId == userId);

                // check if an association already exists and modify this one if it does
                if (userOrg != null)
                {
                    userOrg.OrganisationId = organisationId;
                    Context.UserOrganisations.Update(userOrg);
                }
                else
                {
                    // create new organisation <-> user association
                    userOrg = new UserOrganisation()
                    {
                        CreatedAt      = DateTime.UtcNow,
                        UserId         = userId,
                        OrganisationId = organisationId
                    };
                    Context.UserOrganisations.Add(userOrg);
                }

                Context.SaveChanges();
                response = _mapper.ToDomain(orgEntity);
            }
            catch (DbUpdateException e)
            {
                HandleDbUpdateException(e);
            }
            catch (Exception e)
            {
                LoggingHandler.LogError(e.Message);
                LoggingHandler.LogError(e.StackTrace);
                throw;
            }

            return(response);
        }
Ejemplo n.º 15
0
        public async void Initialize(string[] initialFile)
        {
            LoggingHandler.Log("Reading library...");

            LiteDatabase library;

            try
            {
#if DEBUG // allow multiple instances of FMP in debug (at the expense of stability with heavy library use)
                library = new LiteDatabase($"Filename=\"{Path.Combine(App.DataFolderLocation, "database.fdb2")}\";Connection=shared");
#else
                library = new LiteDatabase(Path.Combine(App.DataFolderLocation, "database.fdb2"));
#endif
                Library = new GUILibrary(library, NotificationHandler, Dispatcher);
            }
            catch (IOException) // library is *probably* being used by another FMP, write initial files, hopefully existing FMP will pick them up
            {
                File.WriteAllLines(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "FRESHMusicPlayer", "instance"), initialFile ?? Array.Empty <string>());
                Application.Current.Shutdown();
                return; // stop initial files from trying to load
            }

            watcher.Filter = "instance";
            watcher.IncludeSubdirectories = false;
            watcher.EnableRaisingEvents   = true;
            watcher.Changed += (object sender, FileSystemEventArgs args) =>
            {
                Dispatcher.Invoke(async() =>
                {
                    var files = File.ReadAllLines(args.FullPath);
                    if (files.Length != 0) // user wants to play a file
                    {
                        Player.Queue.Clear();
                        Player.Queue.Add(files);
                        await Player.PlayAsync();
                    }
                    else // user might've forgotten fmp is open, let's flash
                    {
                        Activate();
                        Topmost = true;
                        Topmost = false;
                    }
                    File.Delete(args.FullPath);
                });
            };
            LoggingHandler.Log("Ready to go!");

            if (initialFile != null)
            {
                Player.Queue.Add(initialFile);
                await Player.PlayAsync();
            }
        }
Ejemplo n.º 16
0
        public void Handle_InnerIsCalled()
        {
            IRequestHandler <Request, string> inner = Substitute.For <IRequestHandler <Request, string> >();
            var logger = Substitute.For <ILogger>();

            var handler = new LoggingHandler <Request, string>(inner, logger);

            handler.Handle(new Request());

            logger.Received().Information(Arg.Is <string>(s => s.Contains("Logging:")));
            inner.Received().Handle(Arg.Any <Request>());
        }
Ejemplo n.º 17
0
        public async Task <IList <IList <object> > > ReadSheetToObjectRowListAsync(string spreadSheetId, string sheetName, string sheetRange)
        {
            SpreadsheetsResource.ValuesResource.GetRequest getter =
                _sheetsService.Spreadsheets.Values.Get(spreadSheetId, $"{sheetName}!{sheetRange}");
            LoggingHandler.LogInfo("Executing client API call");
            ValueRange response = await getter.ExecuteAsync().ConfigureAwait(false);

            LoggingHandler.LogInfo("Execution completed");
            IList <IList <object> > values = response.Values;

            return(values);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Initialize the simple logger by passing in a logging handler.
        /// </summary>
        /// <param name="handler">The logging handler must be type of LoggingHandler</param>
        public static void Init(LoggingHandler handler)
        {
            lock (locker)
            {
                if (null != instance)
                {
                    throw new InvalidOperationException("SimpleLogger has been initialized.");
                }

                instance = new SimpleLogger(handler);
            }
        }
 public static IServiceCollection AddLoggingEndpoint(this IServiceCollection services)
 {
     services.AddSingleton <ILifecycle>((p) =>
     {
         var context   = p.GetRequiredService <IApplicationContext>();
         var logger    = p.GetRequiredService <ILogger <LoggingHandler> >();
         var handler   = new LoggingHandler(context, LogLevel.Error, logger);
         var errorChan = GetRequiredChannel <ISubscribableChannel>(context, IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME);
         return(new EventDrivenConsumerEndpoint(context, errorChan, handler));
     });
     return(services);
 }
        public async Task <IDictionary <string, string[]> > ReadSpreadsheetAsync(string spreadSheetId, string sheetName, string sheetRange, string googleApiKey)
        {
            LoggingHandler.LogInfo("Initialise Google API.");
            await _googleClient.InitialiseWithGoogleApiKey(googleApiKey).ConfigureAwait(false);

            LoggingHandler.LogInfo("Initialisation complete.  Getting spreadsheet rows.");
            IList <IList <object> > values =
                await _googleClient.ReadSheetToObjectRowListAsync(spreadSheetId, sheetName, sheetRange).ConfigureAwait(false);

            if (values == null || !values.Any())
            {
                LoggingHandler.LogError("No data found.  Unresolved issue, so just return without making any updates.");
                return(null);
            }
            LoggingHandler.LogInfo("Spreadsheet rows received.  Parsing data.");
            //Start Synonyms
            IDictionary <string, string[]> synonymGroups = new Dictionary <string, string[]>();

            foreach (IList <object> row in values.Skip(2))
            {
                if (row.Count > 1)
                {
                    try
                    {
                        string synonymGroupName = row[0].ToString().Trim();
                        if (synonymGroupName.Length > 0)
                        {
                            List <string> words = new List <string>();
                            foreach (object cell in row) //Include group name.
                            {
                                if (cell != null)
                                {
                                    string word = cell.ToString().Trim();
                                    if (word.Length > 0)
                                    {
                                        words.Add(word);
                                    }
                                }
                            }
                            synonymGroups.Add(synonymGroupName, words.ToArray());
                        }
                    }
                    catch (NullReferenceException e)
                    {
                        LoggingHandler.LogError(e.Message);
                        LoggingHandler.LogError(e.StackTrace);
                        Debugger.Break();
                    }
                }
            }
            return(synonymGroups);
        }
Ejemplo n.º 21
0
 protected virtual void Dispose(bool bDisposing)
 {
     // Check to see if Dispose has already been called.
     if (!_bDisposed)
     {
         if (bDisposing)
         {
             // Dispose managed resources.
             _loggingHandler = null;
         }
     }
     _bDisposed = true;
 }
Ejemplo n.º 22
0
        public async Task UpdateSynonyms()
        {
            var updateRequest = new SynonymUpdateRequest
            {
                GoogleFileId = Environment.GetEnvironmentVariable("SYNONYMS_GOOGLE_FILE_ID"),
                SheetName    = Environment.GetEnvironmentVariable("SYNONYMS_SHEET_NAME"),
                SheetRange   = Environment.GetEnvironmentVariable("SYNONYMS_SHEET_RANGE"),
                GoogleApiKey = Environment.GetEnvironmentVariable("GOOGLE_API_KEY")
            };

            LoggingHandler.LogInfo("Starting process of updating synonyms.");
            await _synonymsUseCase.ExecuteUpdate(null, updateRequest).ConfigureAwait(false);
        }
Ejemplo n.º 23
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (_loggingHandler != null)
                {
                    _loggingHandler.Dispose();
                    _loggingHandler = null;
                }
            }

            base.Dispose(disposing);
        }
Ejemplo n.º 24
0
        private static HttpClient CreateHttpClient()
        {
            // 使用 LoggingHandler 为 HttpClient 添加日志功能

            var handler = new LoggingHandler(Log,
                                             () => LoggingEnabled,
                                             new HttpClientHandler
            {
                AutomaticDecompression = DecompressionMethods.Deflate |
                                         DecompressionMethods.GZip
            });

            return(new HttpClient(handler));
        }
 public List <TaxonomyDomain> GetTaxonomiesByVocabulary(string vocabulary)
 {
     try
     {
         var taxonomies = Context.Taxonomies.Where(x => x.Vocabulary == vocabulary);
         return(_mapper.ToDomain(taxonomies));
     }
     catch (Exception e)
     {
         LoggingHandler.LogError(e.Message);
         LoggingHandler.LogError(e.StackTrace);
         throw;
     }
 }
 public List <TaxonomyDomain> GetAllTaxonomies()
 {
     try
     {
         var taxonomies = Context.Taxonomies.AsQueryable();
         return(_mapper.ToDomain(taxonomies));
     }
     catch (Exception e)
     {
         LoggingHandler.LogError(e.Message);
         LoggingHandler.LogError(e.StackTrace);
         throw;
     }
 }
Ejemplo n.º 27
0
        public async Task HttpClientNoPollyUse()
        {
            var urlTest             = "https://appulate.com/admin22";
            var requestHandler      = new HttpClientHandler();
            var loggingHandler      = new LoggingHandler();
            var timeoutHandler      = new TimeoutHandler();
            var noPollyRetryHandler = new NoPollyRetryHandler();

            //order of any additional handlers here is important.
            var httpClient =
                HttpClientFactory.Create(requestHandler, loggingHandler, timeoutHandler, noPollyRetryHandler);

            var response = await httpClient.GetAsync(urlTest);
        }
Ejemplo n.º 28
0
        public UserDomain AddUser(AdminCreateUserRequest requestData, string subId)
        {
            // POST /users

            UserDomain userDomain = null;

            var userEntity = new User()
            {
                CreatedAt = requestData.CreatedAt.HasValue
                    ? requestData.CreatedAt
                    : DateTime.UtcNow,
                Email  = requestData.Email,
                Name   = requestData.Name,
                Status = requestData.Status,
                SubId  = subId
            };

            try
            {
                // add the user
                Context.Users.Add(userEntity);
                Context.SaveChanges();

                if (requestData.OrganisationId.HasValue)
                {
                    AssociateUserWithOrganisation(userEntity.Id, requestData.OrganisationId.Value);
                }

                if (requestData.Roles != null)
                {
                    var validatedRoles = UserRoleValidator.ToValidList(requestData.Roles);
                    AddRolesToUser(userEntity.Id, validatedRoles);
                }

                // refresh the user domain object
                userDomain = GetUserById(userEntity.Id);
            }
            catch (DbUpdateException dbe)
            {
                HandleDbUpdateException(dbe);
            }
            catch (Exception e)
            {
                LoggingHandler.LogError(e.Message);
                LoggingHandler.LogError(e.StackTrace);
                throw;
            }

            return(userDomain);
        }
Ejemplo n.º 29
0
        public async Task TorSharpToolFetcher_CheckForUpdates(ToolDownloadStrategy strategy)
        {
            using (var te = TestEnvironment.Initialize(_output))
            {
                // Arrange
                var settings = te.BuildSettings();
                settings.ToolDownloadStrategy = strategy;

                using (var httpClientHandler = new HttpClientHandler())
                    using (var loggingHandler = new LoggingHandler(_output)
                    {
                        InnerHandler = httpClientHandler
                    })
                        using (var httpClient = new HttpClient(loggingHandler))
                            using (var proxy = new TorSharpProxy(settings))
                            {
                                _output.WriteLine(settings);
                                var fetcher = _httpFixture.GetTorSharpToolFetcher(settings, httpClient);
                                var initial = await fetcher.CheckForUpdatesAsync();

                                await fetcher.FetchAsync(initial);

                                var prefix         = ToolUtility.GetPrivoxyToolSettings(settings).Prefix;
                                var extension      = Path.GetExtension(initial.Privoxy.DestinationPath);
                                var fakeOldPrivoxy = Path.Combine(settings.ZippedToolsDirectory, $"{prefix}0.0.1{extension}");
                                File.Move(initial.Privoxy.DestinationPath, fakeOldPrivoxy);

                                // Act
                                var newerVersion = await fetcher.CheckForUpdatesAsync();

                                await fetcher.FetchAsync(newerVersion);

                                var upToDate = await fetcher.CheckForUpdatesAsync();

                                // Assert
                                Assert.True(initial.HasUpdate);
                                Assert.Equal(ToolUpdateStatus.NoLocalVersion, initial.Privoxy.Status);
                                Assert.Equal(ToolUpdateStatus.NoLocalVersion, initial.Tor.Status);

                                Assert.True(newerVersion.HasUpdate);
                                Assert.Equal(ToolUpdateStatus.NewerVersionAvailable, newerVersion.Privoxy.Status);
                                Assert.Equal(ToolUpdateStatus.NoUpdateAvailable, newerVersion.Tor.Status);

                                Assert.False(upToDate.HasUpdate);
                                Assert.Equal(ToolUpdateStatus.NoUpdateAvailable, upToDate.Privoxy.Status);
                                Assert.Equal(ToolUpdateStatus.NoUpdateAvailable, upToDate.Tor.Status);
                            }
            }
        }
Ejemplo n.º 30
0
        private async Task <IRestResponse> ExecuteAsync(RestRequest request)
        {
            BeforeIntercept(request);

            var response = await RestClient.ExecuteAsync(request).ConfigureAwait(false);

            RaiseForInfluxError(response, response.Content);

            response.Content = AfterIntercept(
                (int)response.StatusCode,
                () => LoggingHandler.ToHeaders(response.Headers),
                response.Content);

            return(response);
        }
 public SynonymWordDomain GetSynonymWord(int id)
 {
     try
     {
         var synonymWord = Context.SynonymWords
                           .FirstOrDefault(o => o.Id == id);
         return(_mapper.ToDomain(synonymWord));
     }
     catch (Exception e)
     {
         LoggingHandler.LogError(e.Message);
         LoggingHandler.LogError(e.StackTrace);
         throw;
     }
 }
        /// <summary>
        /// Initialize the simple logger by passing in a logging handler.
        /// </summary>
        /// <param name="handler">The logging handler must be type of LoggingHandler</param>
        public static void Init(LoggingHandler handler)
        {
            lock (locker)
            {

                if (null != instance)
                {
                    throw new InvalidOperationException("SimpleLogger has been initialized.");
                }

                instance = new SimpleLogger(handler);
            }
        }
 private SimpleLogger(LoggingHandler handler)
 {
     if (handler == null)
     {
         throw new ArgumentNullException("handler");
     }
 }