/// <summary> /// Initializes the log sink proxy. /// </summary> /// <param name="context">The context.</param> protected internal override void Initialize(InitializationContext context) { // Start the background thread. _backgroundThread = new Thread(ThreadExecute); _backgroundThread.IsBackground = false; _backgroundThread.Start(); // Call the base class implementation. base.Initialize(context); }
/// <summary> /// Initializes the log sink. /// </summary> /// <param name="context"></param> protected internal override void Initialize(InitializationContext context) { #region Sanity Check if (context == null) { throw new ArgumentNullException("context"); } #endregion _format = context.FormatPatternFactory.Create(_formatString); }
/// <summary> /// Initializes the log sink. /// </summary> /// <param name="context"></param> protected internal override void Initialize(InitializationContext context) { if (string.IsNullOrEmpty(this.Source)) { throw new BlackBoxException("Event log source have not been set."); } if (string.IsNullOrEmpty(this.Log)) { throw new BlackBoxException("Event log name have not been set."); } base.Initialize(context); }
/// <summary> /// Initializes the log sink. /// </summary> /// <param name="context"></param> protected internal override void Initialize(InitializationContext context) { #region Sanity Check if (context == null) { throw new ArgumentNullException("context"); } #endregion lock (_lock) { // Call the base class so the format message sink gets properly initialized. base.Initialize(context); // Create the LRU file cache and the file name pattern. _fileCache = new LruCache<string, TextWriter>(_fileCacheSize); _fileNamePattern = context.FormatPatternFactory.Create(_fileName); // Subscribe to the item removed event. _fileCache.ItemRemoved += new EventHandler<EventArgs<TextWriter>>(_fileCache_ItemRemoved); } }
internal virtual void PerformInitialization(InitializationContext context) { // Get the internal logger. _internalLogger = context.InternalLogger; // Initalize all filters. this.Filters.Initialize(context); // Perform custom initialization for this sink. this.Initialize(context); // We're now properly initialized. _isInitialized = true; }
/// <summary> /// Initializes the log sink. /// </summary> /// <param name="context">The context.</param> protected internal virtual void Initialize(InitializationContext context) { }
/// <summary> /// Initializes the log filter. /// </summary> /// <param name="context"></param> protected internal override void Initialize(InitializationContext context) { if (context == null) { throw new ArgumentNullException("context"); } if (string.IsNullOrEmpty(this.Condition)) { throw new BlackBoxException("The filter condition has not been set."); } // Parse the expression. _expression = context.ConditionFactory.ParseCondition(this.Condition); }
internal void Initialize(InitializationContext context) { _sinks.Initialize(context); _filters.Initialize(context); }
private void Configure(LogConfiguration configuration) { if (_disposed) { throw new ObjectDisposedException(this.GetType().FullName); } using (_lock.AcquireWriteLock()) { if (_configuration != null) { // TODO: Dispose the configuration here. throw new NotImplementedException("Configuration should be disposed."); } // Set the active configuration. _configuration = configuration ?? new LogConfiguration(); // Initialize the configuration. IEnumerable<Assembly> assemblies = _configuration.Assemblies; IInternalLogger internalLogger = _configuration.InternalLogger; using (var context = new InitializationContext(assemblies, internalLogger)) { _configuration.Initialize(context); } } }
/// <summary> /// Initializes the log sink. /// </summary> /// <param name="context"></param> protected internal override void Initialize(InitializationContext context) { #region Sanity Check if (context == null) { throw new ArgumentNullException("context"); } if (string.IsNullOrEmpty(this.Queue)) { throw new BlackBoxException("The message queue has not been set."); } #endregion // Create the message queue. if (!MessageQueue.Exists(this.Queue)) { if (this.CreateIfNotExists) { try { // Create the message queue. _messageQueue = MessageQueue.Create(this.Queue); } catch (MessageQueueException exception) { // The queue could not be created. string message = string.Format(CultureInfo.InvariantCulture, "Could not create message queue '{0}'.", this.Queue); throw new BlackBoxException(message, exception); } } else { // The message queue didn't exist and we're not allowed to create it. string message = string.Format(CultureInfo.InvariantCulture, "The message queue '{0}' do not exist.", this.Queue); throw new BlackBoxException(message); } } else { // Instanciate the message queue. _messageQueue = new MessageQueue(this.Queue, QueueAccessMode.Send); } // Initialize the label pattern. _labelPattern = context.FormatPatternFactory.Create(this.Label); // Call the base class so the format message sink gets properly initialized. base.Initialize(context); }