/// <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) { #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); } }
/// <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); }