public void LoggerDescriptionCustomSerialization()
        {
            string className = "Class";
            string loggerAssemblyName = "Class";
            string loggerFileAssembly = null;
            string loggerSwitchParameters = "Class";
            LoggerVerbosity verbosity = LoggerVerbosity.Detailed;

            LoggerDescription description = new LoggerDescription(className, loggerAssemblyName, loggerFileAssembly, loggerSwitchParameters, verbosity);
            MemoryStream stream = new MemoryStream();
            BinaryWriter writer = new BinaryWriter(stream);
            BinaryReader reader = new BinaryReader(stream);
            try
            {
                stream.Position = 0;
                description.WriteToStream(writer);
                long streamWriteEndPosition = stream.Position;
                stream.Position = 0;
                LoggerDescription description2 = new LoggerDescription();
                description2.CreateFromStream(reader);
                long streamReadEndPosition = stream.Position;
                Assert.Equal(streamWriteEndPosition, streamReadEndPosition); // "Stream end positions should be equal"

                Assert.Equal(description.Verbosity, description2.Verbosity); // "Expected Verbosity to Match"
                Assert.Equal(description.LoggerId, description2.LoggerId); // "Expected Verbosity to Match"
                Assert.Equal(0, string.Compare(description.LoggerSwitchParameters, description2.LoggerSwitchParameters, StringComparison.OrdinalIgnoreCase)); // "Expected LoggerSwitchParameters to Match"
                Assert.Equal(0, string.Compare(description.Name, description2.Name, StringComparison.OrdinalIgnoreCase)); // "Expected Name to Match"
            }
            finally
            {
                reader.Close();
                writer = null;
                stream = null;
            }
        }
示例#2
0
        static internal LoggerDescription FactoryForTranslation(INodePacketTranslator translator)
        {
            LoggerDescription description = new LoggerDescription();

            ((INodePacketTranslatable)description).Translate(translator);
            return(description);
        }
示例#3
0
        public ForwardingLoggerRecord(ILogger centralLogger, LoggerDescription forwardingLoggerDescription)
        {
            // The logging service allows a null central logger, so we don't check for it here.
            ErrorUtilities.VerifyThrowArgumentNull(forwardingLoggerDescription, nameof(forwardingLoggerDescription));

            this.CentralLogger = centralLogger;
            this.ForwardingLoggerDescription = forwardingLoggerDescription;
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="centralLogger">The central logger</param>
        /// <param name="forwardingLoggerDescription">The description for the forwarding logger.</param>
        public ForwardingLoggerRecord(ILogger centralLogger, LoggerDescription forwardingLoggerDescription)
        {
            // The logging service allows a null central logger, so we don't check for it here.
            ErrorUtilities.VerifyThrowArgumentNull(forwardingLoggerDescription, "forwardingLoggerDescription");

            this.CentralLogger = centralLogger;
            this.ForwardingLoggerDescription = forwardingLoggerDescription;
        }
        /// <summary>
        /// Create a logger description from the class name and logger assembly
        /// This is used in any test which needs to register a distributed logger.
        /// </summary>
        /// <param name="loggerClassName">Fully qualified class name (dont for get ParentClass+Nestedclass, if nested)</param>
        /// <param name="loggerAssemblyName">Assembly name which contains class</param>
        /// <returns>A logger description which can be registered</returns>
        private LoggerDescription CreateLoggerDescription(string loggerClassName, string loggerAssemblyName, bool forwardAllEvents)
        {
            string eventsToForward = "CustomEvent";

            if (forwardAllEvents == true)
            {
                eventsToForward = "BuildStartedEvent;BuildFinishedEvent;ProjectStartedEvent;ProjectFinishedEvent;TargetStartedEvent;TargetFinishedEvent;TaskStartedEvent;TaskFinishedEvent;ErrorEvent;WarningEvent;HighMessageEvent;NormalMessageEvent;LowMessageEvent;CustomEvent;CommandLine";
            }

            LoggerDescription centralLoggerDescrption = new LoggerDescription
                                                                             (
                                                                              loggerClassName,
                                                                              loggerAssemblyName,
                                                                              null /*Not needed as we are loading from current assembly*/,
                                                                              eventsToForward,
                                                                              LoggerVerbosity.Diagnostic /*Not used, but the spirit of the logger is to forward everything so this is the most appropriate verbosity */
                                                                             );
            return centralLoggerDescrption;
        }
示例#6
0
 public ForwardingLoggerRecord(ILogger centralLogger, LoggerDescription forwardingLoggerDescription)
 {
     this.CentralLogger = centralLogger;
     this.ForwardingLoggerDescription = forwardingLoggerDescription;
 }
示例#7
0
 /// <summary>
 /// Registers a distributed logger.
 /// </summary>
 /// <param name="centralLogger">The central logger, which resides on the build manager.</param>
 /// <param name="forwardingLogger">The forwarding logger, which resides on the node.</param>
 /// <returns>True if successful.</returns>
 public bool RegisterDistributedLogger(ILogger centralLogger, LoggerDescription forwardingLogger)
 {
     throw new NotImplementedException();
 }
 /// <summary>
 /// Initialize the container class with the given centralLogger and forwardingLoggerDescription
 /// </summary>
 internal DistributedLoggerRecord(ILogger centralLogger, LoggerDescription forwardingLoggerDescription)
 {
     _centralLogger = centralLogger;
     _forwardingLoggerDescription = forwardingLoggerDescription;
 }
示例#9
0
 static internal LoggerDescription FactoryForTranslation(INodePacketTranslator translator)
 {
     LoggerDescription description = new LoggerDescription();
     ((INodePacketTranslatable)description).Translate(translator);
     return description;
 }
 public ForwardingLoggerRecord (ILogger centralLogger, LoggerDescription forwardingLoggerDescription)
 {
         this.CentralLogger = centralLogger;
         this.ForwardingLoggerDescription = forwardingLoggerDescription;
 }