1 //
2 // Copyright (c) ZeroC, Inc. All rights reserved.
3 //
4 
5 namespace Ice
6 {
7     /// <summary>
8     /// Class to support custom loggers. Applications using a custom logger
9     /// instantiate a LoggerPlugin with a custom logger and
10     /// return the instance from their PluginFactory implementation.
11     /// </summary>
12     public class LoggerPlugin : Plugin
13     {
14         /// <summary>
15         /// Installs a custom logger for a communicator.
16         /// </summary>
17         /// <param name="communicator">The communicator using the custom logger.</param>
18         /// <param name="logger">The custom logger for the communicator.</param>
19         public
LoggerPlugin(Communicator communicator, Logger logger)20         LoggerPlugin(Communicator communicator, Logger logger)
21         {
22             if(communicator == null)
23             {
24                 PluginInitializationException ex = new PluginInitializationException();
25                 ex.reason = "Communicator cannot be null";
26                 throw ex;
27             }
28 
29             if(logger == null)
30             {
31                 PluginInitializationException ex = new PluginInitializationException();
32                 ex.reason = "Logger cannot be null";
33                 throw ex;
34             }
35 
36             IceInternal.Instance instance = IceInternal.Util.getInstance(communicator);
37             instance.setLogger(logger);
38         }
39 
40         /// <summary>
41         /// Called by the Ice run time during communicator initialization. The derived class
42         /// can override this method to perform any initialization that might be required
43         /// by a custom logger.
44         /// </summary>
45         public void
initialize()46         initialize()
47         {
48         }
49 
50         /// <summary>
51         /// Called by the Ice run time when the communicator is destroyed. The derived class
52         /// can override this method to perform any finalization that might be required
53         /// by a custom logger.
54         /// </summary>
55         public void
destroy()56         destroy()
57         {
58         }
59     }
60 }
61