C# Class CK.Monitoring.GrandOutput

ファイルを表示 Open project: Invenietis/ck-core Class Usage Examples

Public Methods

Method Description
Dispose ( ) : void

Calls Dispose(IActivityMonitor,int) with a SystemActivityMonitor and Timeout.Infinite.

Dispose ( IActivityMonitor monitor, int millisecondsBeforeForceClose = Timeout.Infinite ) : void

Closes this GrandOutput.

EnsureActiveDefault ( Action configurator = null ) : GrandOutput

Ensures that the Default GrandOutput is created and that any ActivityMonitor that will be created in this application domain will automatically have a GrandOutputClient registered for this Default GrandOutput. Use EnsureActiveDefaultWithDefaultSettings to initially configure this default.

This method is thread-safe (a simple lock protects it) and uses a ActivityMonitor.AutoConfiguration action that Registers newly created ActivityMonitor.

EnsureActiveDefaultWithDefaultSettings ( IActivityMonitor monitor = null ) : GrandOutput

Ensures that the Default GrandOutput is created (see EnsureActiveDefault) and configured with default settings: only one one channel with its minimal filter sets to Debug with one text file handler that writes .txt files in "SystemActivityMonitor.RootLogPath\GrandOutputDefault" directory. The SystemActivityMonitor.RootLogPath must be valid and if a GrandOutput.config file exists inside, it is loaded as the configuration. If it exists, it must be valid (otherwise an exception is thrown). Once loaded, the file is monitored and any change that occurs to it dynamically triggers a SetConfiguration with the new file.

GrandOutput ( IGrandOutputDispatcherStrategy dispatcherStrategy = null ) : System

Initializes a new GrandOutput.

Register ( IActivityMonitor monitor ) : GrandOutputClient

Ensures that a client for this GrandOutput is registered on a monitor.

RegisterGlobalSink ( IGrandOutputSink sink ) : void

Registers a IGrandOutputSink.

SetConfiguration ( GrandOutputConfiguration config, IActivityMonitor monitor = null, int millisecondsBeforeForceClose = Timeout.Infinite ) : bool

Attempts to set a new configuration.

UnregisterGlobalSink ( IGrandOutputSink sink ) : void

Unregisters a IGrandOutputSink.

WaitForNextConfiguration ( int configurationAttemptCount, int millisecondsTimeout ) : bool

Blocks the caller until the current ConfigurationAttemptCount is greater or equal to the given number and the last configuration has been applied (or this object is disposed).

Private Methods

Method Description
AttemptGarbageDeadClients ( ) : void
CreateDefaultConfig ( ) : GrandOutputConfiguration
DoGarbageDeadClients ( System.DateTime utcNow ) : int
ObtainChannel ( string topic ) : IChannel

Obtains an actual channel based on the activity IActivityMonitor.Topic (null when . This is called on the monitor's thread.

OnConfigurationClosing ( object sender, IChannel>.ConfiguredRouteHost e ) : void

This is called by the host when current configuration must be closed.

OnConfigurationReady ( ChannelHost e ) : void
OnDomainTermination ( object sender, EventArgs e ) : void
Reload ( object state ) : void
SignalConfigurationChanged ( ) : bool

Signals the clients referenced by weak refs that they need to obtain a new channel and returns true if at least one weak ref is not alive.

StartMonitoring ( IActivityMonitor monitor ) : void
_watcher_Changed ( object sender, FileSystemEventArgs unusedEventArgs ) : void
_watcher_Error ( object sender, ErrorEventArgs e ) : void

Method Details

Dispose() public method

Calls Dispose(IActivityMonitor,int) with a SystemActivityMonitor and Timeout.Infinite.
public Dispose ( ) : void
return void

Dispose() public method

Closes this GrandOutput.
public Dispose ( IActivityMonitor monitor, int millisecondsBeforeForceClose = Timeout.Infinite ) : void
monitor IActivityMonitor Monitor that will be used. Must not be null.
millisecondsBeforeForceClose int Maximal time to wait for current routes to be unlocked (see ).
return void

EnsureActiveDefault() static public method

Ensures that the Default GrandOutput is created and that any ActivityMonitor that will be created in this application domain will automatically have a GrandOutputClient registered for this Default GrandOutput. Use EnsureActiveDefaultWithDefaultSettings to initially configure this default.
This method is thread-safe (a simple lock protects it) and uses a ActivityMonitor.AutoConfiguration action that Registers newly created ActivityMonitor.
static public EnsureActiveDefault ( Action configurator = null ) : GrandOutput
configurator Action /// Optional action that can configure the default GrandOutput. /// If specified will be called after the creation of a new GrandOutput: it will not be called /// if a is already available. /// This parameter is optional since you can configure it at any time. ///
return GrandOutput

EnsureActiveDefaultWithDefaultSettings() static public method

Ensures that the Default GrandOutput is created (see EnsureActiveDefault) and configured with default settings: only one one channel with its minimal filter sets to Debug with one text file handler that writes .txt files in "SystemActivityMonitor.RootLogPath\GrandOutputDefault" directory. The SystemActivityMonitor.RootLogPath must be valid and if a GrandOutput.config file exists inside, it is loaded as the configuration. If it exists, it must be valid (otherwise an exception is thrown). Once loaded, the file is monitored and any change that occurs to it dynamically triggers a SetConfiguration with the new file.
static public EnsureActiveDefaultWithDefaultSettings ( IActivityMonitor monitor = null ) : GrandOutput
monitor IActivityMonitor An optional monitor.
return GrandOutput

GrandOutput() public method

Initializes a new GrandOutput.
public GrandOutput ( IGrandOutputDispatcherStrategy dispatcherStrategy = null ) : System
dispatcherStrategy IGrandOutputDispatcherStrategy Strategy to use to handle the throughput.
return System

Register() public method

Ensures that a client for this GrandOutput is registered on a monitor.
public Register ( IActivityMonitor monitor ) : GrandOutputClient
monitor IActivityMonitor The monitor onto which a must be registered.
return GrandOutputClient

RegisterGlobalSink() public method

Registers a IGrandOutputSink.
public RegisterGlobalSink ( IGrandOutputSink sink ) : void
sink IGrandOutputSink The sink to register.
return void

SetConfiguration() public method

Attempts to set a new configuration.
public SetConfiguration ( GrandOutputConfiguration config, IActivityMonitor monitor = null, int millisecondsBeforeForceClose = Timeout.Infinite ) : bool
config GrandOutputConfiguration The configuration that must be set.
monitor IActivityMonitor Optional monitor.
millisecondsBeforeForceClose int Optional timeout to wait before forcing the close of the currently active configuration.
return bool

UnregisterGlobalSink() public method

Unregisters a IGrandOutputSink.
public UnregisterGlobalSink ( IGrandOutputSink sink ) : void
sink IGrandOutputSink The sink to unregister.
return void

WaitForNextConfiguration() public method

Blocks the caller until the current ConfigurationAttemptCount is greater or equal to the given number and the last configuration has been applied (or this object is disposed).
public WaitForNextConfiguration ( int configurationAttemptCount, int millisecondsTimeout ) : bool
configurationAttemptCount int The number of configuration attempt count to wait for.
millisecondsTimeout int Maximum number of milliseconds to wait. Use or -1 for no limit.
return bool