public static void SendMessage(this StreamWriter writer, ReportType type, MessageLevel level, string message)
		{
			var encodedMessage = Convert.ToBase64String(Encoding.UTF8.GetBytes(message));
			var report = "{0}|{1}|{2}".FormatWith(type, level, encodedMessage);
			writer.WriteLine(report);
			writer.Flush();
		}
Example #2
0
        /// <summary>
        /// Creates a new generc message event arg.
        /// </summary>
        /// <param name="sourceLineNumbers">Source line numbers for the message.</param>
        /// <param name="id">Id for the message.</param>
        /// <param name="level">Level for the message.</param>
        /// <param name="format">Format message for arguments.</param>
        /// <param name="messageArgs">Arguments for the format string.</param>
        public WixGenericMessageEventArgs(SourceLineNumberCollection sourceLineNumbers, int id, MessageLevel level, string format, params object[] messageArgs)
            : base(sourceLineNumbers, id, format, messageArgs)
        {
            this.resourceManager = new GenericResourceManager();

            this.Level = level;
        }
Example #3
0
 private void SendMessage(ReportType type, MessageLevel level, string message)
 {
     var encodedMessage = Convert.ToBase64String(Encoding.UTF8.GetBytes(message));
     var report = "{0}|{1}|{2}".FormatWith(type, level, encodedMessage);
     _output.WriteLine(report);
     _output.Flush();
 }
 public void Log(string message, MessageLevel messageLevel)
 {
     if(EventLog != null)
     {
         EventLog(message, messageLevel);
     }
 }
 public void OnPackageOperationMessageLogged(MessageLevel level, string message, params object[] args)
 {
     if (PackageOperationMessageLogged != null) {
         var eventArgs = new PackageOperationMessageLoggedEventArgs(level, message, args);
         PackageOperationMessageLogged(this, eventArgs);
     }
 }
Example #6
0
        public void Write(MessageLevel level, Exception ex)
        {
            if (this.MessageReceived == null) return;

            MessageEventArgs msgArgs = new MessageEventArgs(level, ex.GetAllMessage());
            this.MessageReceived(null, msgArgs);
        }
Example #7
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="message"><c>String</c> that specifies the name of the <c>LogMessage</c>.</param>
 /// <param name="level"><c>MessageLevel</c> that specifies the level of the <c>LogMessage</c>.</param>
 /// <returns><c>LogMessage</c> object</returns>
 public LogMessage(
     String message,
     MessageLevel level)
 {
     this.Message = message;
     this.Level = level;
 }
        public IObservable<bool> Post(string url, string message, MessageLevel level = MessageLevel.Info)
        {
            // Create an HttpClient and send content payload
            using (var httpClient = HttpClient)
            {
            #if __IOS__ || __ANDROID__ || NET45
                var content = new FormUrlEncodedContent(new Dictionary<string, string>
                {
                    {"message", message},
                    {"level", level.ToString().ToLower()}
                });
            #endif
            #if NETFX_CORE
                var content = new HttpFormUrlEncodedContent(new Dictionary<string, string>
                {
                    {"message", message},
                    {"level", level.ToString().ToLower()}
                });
            #endif

            #if __IOS__ || __ANDROID__ || NET45
                return httpClient.PostAsync(new Uri(url), content)
                    .ToObservable()
                    .Select(response => response.IsSuccessStatusCode);
            #endif
            #if NETFX_CORE
                return httpClient.PostAsync(new Uri(url), content)
                    .AsTask()
                    .ToObservable()
                    .Select(response => response.IsSuccessStatusCode);
            #endif
            }
        }
		public PackageOperationMessageLoggedEventArgs(
			MessageLevel level,
			string message,
			params object[] args)
		{
			this.Message = new PackageOperationMessage(level, message, args);
		}
Example #10
0
        public Task ShowMessage(string message, string title, MessageLevel level)
        {
            //TODO:Need to implement tooltip and message logging in case for none
              return Task.Factory.StartNew(() =>
              {
            switch (this._messageTarget)
            {
              case MessageTarget.MessageBox:
            if (this.InvokeRequired)
            {
              this.Invoke(new Action(() =>
              {
                MessageBox.Show(message, title, MessageBoxButtons.OK, FrmMain.GetIcon(level));
              }));
            }
            else
              MessageBox.Show(message, title, MessageBoxButtons.OK, FrmMain.GetIcon(level));
            break;
              case MessageTarget.ToolTip:
            break;
              case MessageTarget.None:
            break;
              default:
            break;
            }

              });
        }
Example #11
0
        /// <summary>
        /// Last chance logging if primary logging sink fails.  Usually used on application boot strapping.  Log file will be located in
        /// either the file location of Log.LastChangeLogFile or in the default folder of the running application.  NOTE:  Bypasses
        /// any configured log provider (log4Net, NLog, TraceLog, etc) and writes directly to text file.  Use with extreme care and is
        /// not configured for high performance.
        /// </summary>
        /// <param name="logLevel">Level this message will be logged at</param>
        /// <param name="message">Text of message</param>
        /// <param name="args">Arguments to supply to message text (if any)</param>
        public static void LastChanceLog(MessageLevel logLevel, string message, params object[] args)
        {
            string logMessage = "";
            try
            {
                _lastChanceLock.EnterWriteLock();

                if (CoreConfig.Log.IsLastChanceLogEnabled == false) return; // last chance logging not enabled

                logMessage = TextUtils.StringFormat("{0:yyyy-MM-dd HH:mm:ss.fff} {1} {2}", DateTime.Now, logLevel.ToString().ToUpper(), TextUtils.StringFormat(message, args));

                File.AppendAllText(CoreConfig.Log.LastChanceLogFile, logMessage + Environment.NewLine);
            }
            catch (Exception ex)
            {
                try // write to event log if unable to log to last chance file.  This is really the last chance of the last chance!
                {
                    EventLog.WriteEntry("Application Error", string.Format(logMessage, args), EventLogEntryType.Error);
                    EventLog.WriteEntry("Application Error", string.Format(ex.ToString()), EventLogEntryType.Error);
                }
                catch (Exception ex2) //couldn't write log to last chance log file or event viewer so swallow exception
                {
                    System.Diagnostics.Debug.WriteLine(string.Format("Error in LastChanceLog: {0}{1}{2}", ex2.Message, Environment.NewLine, logMessage));
                }
            }
            finally
            {
                _lastChanceLock.ExitWriteLock();
            }
        }
        public void Log(MessageLevel level, string message, params object[] args)
        {
            var calleeType = new StackTrace().GetFrame(1).GetMethod().DeclaringType ?? GetType();

            var logger = LogManager.GetLogger(calleeType);

            Action<Action<FormatMessageHandler>> logMethod;

            switch (level)
            {
                case MessageLevel.Debug:
                    logMethod = logger.Debug;
                    break;
                case MessageLevel.Info:
                    logMethod = logger.Info;
                    break;
                case MessageLevel.Error:
                    logMethod = logger.Error;
                    break;
                case MessageLevel.Warning:
                default:
                    logMethod = logger.Warn;
                    break;
            }

            logMethod(m => m(message, args));
        }
        public void Log(MessageLevel level, string message, params object[] args)
        {
            if (args.Length > 0)
            {
                message = string.Format(CultureInfo.CurrentCulture, message, args);
            }

            switch (level)
            {
                case MessageLevel.Debug:
                    _logger.LogDebug(message);
                    break;

                case MessageLevel.Info:
                    _logger.LogMinimal(message);
                    break;

                case MessageLevel.Warning:
                    _logger.LogWarning(message);
                    break;

                case MessageLevel.Error:
                    _logger.LogError(message);
                    break;
            }
        }
 public LogMessageAttributes(Stream stream)
 {
     Classification = (MessageClass)stream.ReadByte();
     Level = (MessageLevel)stream.ReadByte();
     MessageSuppression = (MessageSuppression)stream.ReadByte();
     Flags = (MessageFlags)stream.ReadByte();
 }
 public LogMessageAttributes(MessageClass classification, MessageLevel level, MessageSuppression messageSuppression, MessageFlags flags)
 {
     Classification = classification;
     Level = level;
     MessageSuppression = messageSuppression;
     Flags = flags;
 }
 public void SetNewMessage(MessageLevel Level,string Message,string CodeIndex)
 {
     MessageItem newItem = new MessageItem();
     newItem.CodeIndex = CodeIndex;
     newItem.Message = Message;
     newItem.SelectedMessageLevel = Level;
 }
Example #17
0
 public Message(MessageLevel level, int code, string phrase, params string[] phraseTokens)
 {
     Level = level;
     Code = code;
     Phrase = phrase;
     Tokens = phraseTokens;
 }
Example #18
0
 internal TidyMessage(Lexer lexer, string message, MessageLevel level)
 {
     _filename = String.Empty;
     _line = lexer.lines;
     _column = lexer.columns;
     _message = message;
     _level = level;
 }
        public FileSystemMessenger(string baseDirectory, MessageLevel minimumLevel)
        {
            if (baseDirectory == null)
                throw new ArgumentNullException("baseDirectory");

            this.logDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, baseDirectory);
            this.minimumLevel = minimumLevel;
        }
Example #20
0
 public Message(MessageType type, MessageLevel level, Dictionary<string, string> data)
 {
     CreatedAt = DateTime.Now;
     Type = type;
     Data = data;
     Level = level;
     WasRead = false;
 }
 private StatusReport(string text, MessageLevel level, OperationType type, ReportType reportType)
 {
     Message = text;
     MessageLevel = level;
     OperationType = type;
     MessageTime = DateTime.Now;
     ReportType = reportType;
 }
        private void SendMessage(ReportType type, MessageLevel level, string message)
        {
            var encodedMessage = Convert.ToBase64String(Encoding.UTF8.GetBytes(message));
            var report = $"{type}|{level}|{encodedMessage}";
            _output.WriteLine(report);
            _output.Flush();

        }
 /// <summary>
 /// Initializes a new instance of the <see cref="LogMessage"/> class.
 /// </summary>
 /// <param name="level">The level.</param>
 /// <param name="text">The text.</param>
 public LogMessage(MessageLevel level, string text)
 {
     this.Level = level;
     this.Text = text;
     this.Time = DateTime.UtcNow;
     this.ThreadId = System.Threading.Thread.CurrentThread.ManagedThreadId;
     this.AppDomainId = AppDomain.CurrentDomain.Id;
 }
Example #24
0
 public Error(MessageLevel category, string message, int code, Node node)
     : this()
 {
     Node = node;
     Message = message;
     Code = code;
     Category = category;
 }
Example #25
0
        public void AddMessage(MessageLevel level, string text, params object[] args)
        {
            var formattedText = args.Length > 0 ?
                string.Format(text, args) :
                text;

            _callback.Invoke(new Message(formattedText, level));
        }
Example #26
0
 internal TidyMessage(string filename, int line, int column, string message, MessageLevel level, TidyOptions options)
 {
     _filename = filename;
     _line = line;
     _column = column;
     _message = message;
     _level = level;
 }
		public PackageOperationMessage(
			MessageLevel level,
			string message,
			params object[] args)
		{
			this.Level = level;
			this.message = message;
			this.args = args;
		}
Example #28
0
 private void AddMessage(MessageLevel level, string message)
 {
     // for the dialog we ignore debug messages
     if (level != MessageLevel.Debug)
     {
         AddMessageToDialog(level, message);
     }
     _outputConsole.WriteLine(message);
 }
Example #29
0
 static void WriteLine(DateTime msgTime, MessageLevel msglvl, int threadid, string threadName, string msg)
 {
     string message;
     DateTime msgtime = DateTime.Now;
     if(threadName == null)
         message = "<" + _processid + "." + threadid + "> " + Enum.Format(typeof(MessageLevel), msglvl, "G") + " - " + msgtime.ToLongTimeString() + " - " + msg; 
     else
         message = "<" + _processid+ "." + threadid + ". " + threadName +"> "+ Enum.Format(typeof(MessageLevel), msglvl, "G") +" - "+msgtime.ToLongTimeString()+" - "+msg; 
     Console.WriteLine("\n" + message);
 }
Example #30
0
        /// <summary>
        /// コンストラクタ。
        /// </summary>
        /// <param name="item">メッセージ定義のKeyValueMap。</param>
        /// <param name="arguments">メッセージパラメータ。</param>
        public ProvidedMessage(
            KeyValueMap item,
            dynamic[] arguments)
        {
            _Id = item["Id"];
            _MessageLevel = item["Level"];
            Message = item["Message"];

            Arguments = arguments;
        }
Example #31
0
        /// <summary>
        /// Posts a log message to be written to the database as soon as possible.
        /// </summary>
        /// <param name="level">The message level.</param>
        /// <param name="message">The message text.</param>
        public void WriteMessage(MessageLevel level, string message)
        {
            var now = DateTime.UtcNow;

            lock (this.syncLock)
            {
                if (this.completed.HasValue)
                {
                    throw new InvalidOperationException($"Log scope {this.Name} has already been completed.");
                }

                if (this.maxLevel < (int)level)
                {
                    this.maxLevel = (int)level;
                }

                // scope has not been created yet or waiting on messages to be written
                if (!this.ScopeId.IsCompleted || this.writeLogMessagesTask != null)
                {
                    this.entries.Add(new LogEntry(this.ExecutionLogger.GetNextLogEntrySequence(), level, message));
                    if (this.writeLogMessagesTask == null)
                    {
                        this.writeLogMessagesTask = this.ScopeId.ContinueWith(this.MessagesWritten);
                    }
                }
                // scope is created and nothing is being written
                else
                {
                    this.writeLogMessagesTask = Task.Run(() => RompDb.WriteLogMessagesAsync(
                                                             executionId: this.ExecutionId,
                                                             scopeSequence: this.ScopeId.Result.Value,
                                                             new[] { new LogEntry(this.ExecutionLogger.GetNextLogEntrySequence(), level, message) }
                                                             )).ContinueWith(this.MessagesWritten);
                }
            }
        }
Example #32
0
        private string GetPreambula(MessageLevel type)
        {
            string preambula;

            switch (type)
            {
            case MessageLevel.Error:
                preambula = "E";
                break;

            case MessageLevel.Info:
                preambula = "I";
                break;

            case MessageLevel.Warning:
                preambula = "W";
                break;

            default:
                preambula = "";
                break;
            }
            return(preambula);
        }
Example #33
0
        public void Log(MessageLevel level, string message, params object[] args)
        {
            if (level == MessageLevel.Debug)
            {
                return;
            }

            if (Logger.IsInfoEnabled)
            {
                Logger.Info(string.Format(message, args));
                return;
            }

            if (Logger.IsOperationsEnabled)
            {
                switch (level)
                {
                case MessageLevel.Warning:
                case MessageLevel.Error:
                    Logger.Operations(string.Format(message, args));
                    break;
                }
            }
        }
Example #34
0
        public void Log(MessageLevel level, string message, params object[] args)
        {
            // Add a prefix to the message to make it easier to determine the source
            string prefixedMessage = LogMessagePrefix + message;

            switch (level)
            {
            case MessageLevel.Debug:
                this.logger.LogDebug(prefixedMessage, args);
                break;

            case MessageLevel.Error:
                this.logger.LogError(prefixedMessage, args);
                break;

            case MessageLevel.Warning:
                this.logger.LogWarning(prefixedMessage, args);
                break;

            default:
                this.logger.LogInfo(prefixedMessage, args);
                break;
            }
        }
Example #35
0
        private string ParseLogMessage(string message, out MessageLevel level)
        {
            level = MessageLevel.NA;

            if (string.IsNullOrWhiteSpace(message))
            {
                return("");
            }

            // Parse log message level
            if ((object)m_logMessageLevelExpression != null)
            {
                Match match = m_logMessageLevelExpression.Match(message);

                if (match.Success)
                {
                    if (!m_messageLevelMap.TryGetValue(match.Value, out level))
                    {
                        level = MessageLevel.NA;
                    }
                }
            }

            // Parse log message text
            if ((object)m_logMessageTextExpression != null)
            {
                MatchCollection matches = m_logMessageTextExpression.Matches(message);

                if (matches.Count > 0)
                {
                    return(string.Join(" ", matches.Cast <Match>().Select(match => match.Value)));
                }
            }

            return(message);
        }
Example #36
0
 public void PutMessage(MessageLevel messageLevel, ushort receiverNodeId, ushort receiverWorkerId, ushort senderNodeId, ushort senderWorkerId, int messageType, object content)
 {
     //see if it is a local worker that is the receiver
     lock (_localWorkers)
     {
         //Message msg = new Message(messageLevel, new WorkerAddress(receiverNodeId, receiverWorkerId), new WorkerAddress(senderNodeId, senderWorkerId), messageType, content);
         if (WorkerAddress.IsBroadcastAddress(receiverNodeId, receiverWorkerId)) //broadcast address
         {
             foreach (Worker worker in _localWorkers.Values)
             {
                 worker.PutMessage(messageLevel, receiverNodeId, receiverWorkerId, senderNodeId, senderWorkerId, messageType, CloneContent(content)); //clone the message to prevent shared state
             }
         }
         else if (_localWorkers.ContainsKey(receiverWorkerId))
         {
             _localWorkers[receiverWorkerId].PutMessage(messageLevel, receiverNodeId, receiverWorkerId, senderNodeId, senderWorkerId, messageType, CloneContent(content));
         }
         else
         if (!SystemMessages.IsSystemMessageType(messageType))     //we don't care about that
         {
             Log.Error("Node.PutMessage : Cannot dispatch message");
         }
     }
 }
Example #37
0
        /// <summary>
        /// Processs the input level and apply policy and rules
        /// </summary>
        /// <param name="Level">The original level of the message</param>
        /// <returns>The processed level</returns>
        private MessageLevel ResolveLevel(MessageLevel Level)
        {
            int tempLevel = (int)Level;

            if (MessageHost.NestedLevelDecrement > 0)
            {
                int depth = _stackDepth - 2;
                if (_fromStopFunction)
                {
                    depth--;
                }
                tempLevel = tempLevel + depth * MessageHost.NestedLevelDecrement;
            }

            if (MessageHost.MessageLevelModifiers.Count > 0)
            {
                foreach (MessageLevelModifier modifier in MessageHost.MessageLevelModifiers.Values)
                {
                    if (modifier.AppliesTo(FunctionName, ModuleName, _Tags))
                    {
                        tempLevel = tempLevel + modifier.Modifier;
                    }
                }
            }

            if (tempLevel > 9)
            {
                tempLevel = 9;
            }
            if (tempLevel < 1)
            {
                tempLevel = 1;
            }

            return((MessageLevel)tempLevel);
        }
Example #38
0
 public List <object> GetCachedMessages(MessageIntent intent, MessageLevel level)
 {
     return(new List <object>());
 }
Example #39
0
 public void ClearCache(MessageIntent intent, MessageLevel level)
 {
     Messages.Clear();
 }
Example #40
0
 public bool CacheMessage(MessageIntent intent, MessageLevel level, Exception ex, params string[] messagePortions)
 {
     return(Message(intent, level, messagePortions));
 }
Example #41
0
 public Message(object header, object content, MessageLevel level = MessageLevel.Information)
 {
     Level   = level;
     Header  = header;
     Content = content;
 }
Example #42
0
 static void OnActionOutput(MessageLevel level, string message, Exception ex)
 {
     Console.ForegroundColor = ConsoleColor.Yellow;
     Console.WriteLine("{0} | {1} | {2}", level, message, ex?.StackTrace);
     Console.ForegroundColor = ConsoleColor.Gray;
 }
 public void Log(MessageLevel level, string message, params object[] args)
 {
     packageManagementEvents.OnPackageOperationMessageLogged(level, message, args);
 }
Example #44
0
 public Task LogAsync(MessageLevel level, string message)
 {
     return(Task.CompletedTask);
 }
 public LogMessage(MessageLevel level, string content)
 {
     Level   = level;
     Content = content;
 }
 protected override void LogCore(MessageLevel level, string formattedMessage)
 {
     // We don't want this cmdlet to print anything
 }
Example #47
0
 public bool Message(MessageIntent intent, MessageLevel level, Exception ex, params string[] messagePortions)
 {
     Messages.Add(new Tuple <MessageIntent, MessageLevel, string[]>(intent, level, messagePortions));
     return(true);
 }
 public void PutMessage(MessageLevel messageLevel, ushort receiverNodeId, ushort receiverWorkerId, ushort senderNodeId, ushort senderWorkerId, int messageType, object content)
 {
     Proxy.PutMessage(messageLevel, receiverNodeId, receiverWorkerId, senderNodeId, senderWorkerId, messageType, content);
 }
Example #49
0
 public static void WriteLine(string Message, MessageLevel Level)
 {
     OutputLine(Message, Level);
 }
Example #50
0
 /// <summary>
 /// Writes a line to the server console.
 /// </summary>
 /// <param name="Message">The message to be displayed.</param>
 /// <param name="Level">The level of the message.</param>
 /// <param name="Params">Parameters to format the message with.</param>
 public static void WriteLine(string Message, MessageLevel Level, params object[] Params)
 {
     OutputLine(string.Format(Message, Params), Level);
 }
Example #51
0
 internal void WriteHelperMessage(MessageLevel level, string message)
 {
     WriteMessage(level, message);
 }
Example #52
0
 private static void Message_OnMessage(string sender, MessageLevel level, string message)
 {
     Console.WriteLine(message);
 }
Example #53
0
 public void Log(MessageLevel level, string message)
 {
 }
Example #54
0
        /// <summary>
        /// Processes the process phase of the cmdlet
        /// </summary>
        protected override void ProcessRecord()
        {
            #region Perform Transforms
            if ((!_fromStopFunction) && (Target != null))
            {
                Target = ResolveTarget(Target);
            }

            if (!_fromStopFunction)
            {
                if (Exception != null)
                {
                    Exception = ResolveException(Exception);
                }
                else if (ErrorRecord != null)
                {
                    Exception tempException = null;
                    for (int n = 0; n < ErrorRecord.Length; n++)
                    {
                        // If both Exception and ErrorRecord are specified, override the first error record's exception.
                        if ((n == 0) && (Exception != null))
                        {
                            tempException = Exception;
                        }
                        else
                        {
                            tempException = ResolveException(ErrorRecord[n].Exception);
                        }
                        if (tempException != ErrorRecord[n].Exception)
                        {
                            ErrorRecord[n] = new ErrorRecord(tempException, ErrorRecord[n].FullyQualifiedErrorId, ErrorRecord[n].CategoryInfo.Category, ErrorRecord[n].TargetObject);
                        }
                    }
                }
            }

            if (Level != MessageLevel.Warning)
            {
                Level = ResolveLevel(Level);
            }
            #endregion Perform Transforms

            #region Exception Integration

            /*
             *  While conclusive error handling must happen after message handling,
             *  in order to integrate the exception message into the actual message,
             *  it becomes necessary to first integrate the exception and error record parameters into a uniform view
             *
             *  Note: Stop-PSFFunction never specifies this parameter, thus it is not necessary to check,
             *  whether this function was called from Stop-PSFFunction.
             */
            if ((ErrorRecord == null) && (Exception != null))
            {
                ErrorRecord    = new ErrorRecord[1];
                ErrorRecord[0] = new ErrorRecord(Exception, String.Format("{0}_{1}", ModuleName, FunctionName), ErrorCategory.NotSpecified, Target);
            }
            #endregion Exception Integration

            #region Error handling
            PsfExceptionRecord errorRecord = null;
            if (ErrorRecord != null)
            {
                if (!_fromStopFunction)
                {
                    if (EnableException)
                    {
                        foreach (ErrorRecord record in ErrorRecord)
                        {
                            WriteError(record);
                        }
                    }
                }

                errorRecord = LogHost.WriteErrorEntry(ErrorRecord, FunctionName, ModuleName, _Tags, _timestamp, _MessageSystem, System.Management.Automation.Runspaces.Runspace.DefaultRunspace.InstanceId, Environment.MachineName);
            }
            #endregion Error handling

            LogEntryType channels = LogEntryType.None;

            #region Warning handling
            if (Level == MessageLevel.Warning)
            {
                if (!_silent)
                {
                    if (!String.IsNullOrEmpty(Once))
                    {
                        string onceName = String.Format("MessageOnce.{0}.{1}", FunctionName, Once).ToLower();
                        if (!(Configuration.ConfigurationHost.Configurations.ContainsKey(onceName) && (bool)Configuration.ConfigurationHost.Configurations[onceName].Value))
                        {
                            WriteWarning(_MessageStreams);
                            channels = channels | LogEntryType.Warning;

                            Configuration.Config cfg = new Configuration.Config();
                            cfg.Module      = "messageonce";
                            cfg.Name        = String.Format("{0}.{1}", FunctionName, Once).ToLower();
                            cfg.Hidden      = true;
                            cfg.Description = "Locking setting that disables further display of the specified message";
                            cfg.Value       = true;

                            Configuration.ConfigurationHost.Configurations[onceName] = cfg;
                        }
                    }
                    else
                    {
                        WriteWarning(_MessageStreams);
                        channels = channels | LogEntryType.Warning;
                    }
                }
                WriteDebug(_MessageStreams);
                channels = channels | LogEntryType.Debug;
            }
            #endregion Warning handling

            #region Message handling
            if (!_silent)
            {
                if ((MessageHost.MaximumInformation >= (int)Level) && (MessageHost.MinimumInformation <= (int)Level))
                {
                    if (!String.IsNullOrEmpty(Once))
                    {
                        string onceName = String.Format("MessageOnce.{0}.{1}", FunctionName, Once).ToLower();
                        if (!(Configuration.ConfigurationHost.Configurations.ContainsKey(onceName) && (bool)Configuration.ConfigurationHost.Configurations[onceName].Value))
                        {
                            InvokeCommand.InvokeScript(false, ScriptBlock.Create(_writeHostScript), null, _MessageHost);
                            channels = channels | LogEntryType.Information;

                            Configuration.Config cfg = new Configuration.Config();
                            cfg.Module      = "messageonce";
                            cfg.Name        = String.Format("{0}.{1}", FunctionName, Once).ToLower();
                            cfg.Hidden      = true;
                            cfg.Description = "Locking setting that disables further display of the specified message";
                            cfg.Value       = true;

                            Configuration.ConfigurationHost.Configurations[onceName] = cfg;
                        }
                    }
                    else
                    {
                        //InvokeCommand.InvokeScript(_writeHostScript, _MessageHost);
                        InvokeCommand.InvokeScript(false, ScriptBlock.Create(_writeHostScript), null, _MessageHost);
                        channels = channels | LogEntryType.Information;
                    }
                }
            }

            if ((MessageHost.MaximumVerbose >= (int)Level) && (MessageHost.MinimumVerbose <= (int)Level))
            {
                if ((_callStack.Count() > 1) && _callStack.ElementAt(_callStack.Count() - 2).InvocationInfo.BoundParameters.ContainsKey("Verbose"))
                {
                    InvokeCommand.InvokeScript(@"$VerbosePreference = 'Continue'");
                }
                //SessionState.PSVariable.Set("VerbosePreference", ActionPreference.Continue);

                WriteVerbose(_MessageStreams);
                channels = channels | LogEntryType.Verbose;
            }

            if ((MessageHost.MaximumDebug >= (int)Level) && (MessageHost.MinimumDebug <= (int)Level))
            {
                bool restoreInquire = false;
                if (_isDebug)
                {
                    if (Breakpoint.ToBool())
                    {
                        InvokeCommand.InvokeScript(false, ScriptBlock.Create(@"$DebugPreference = 'Inquire'"), null, null);
                    }
                    else
                    {
                        InvokeCommand.InvokeScript(false, ScriptBlock.Create(@"$DebugPreference = 'Continue'"), null, null);
                        restoreInquire = true;
                    }
                    WriteDebug(String.Format("{0} | {1}", Line, _MessageStreams));
                    channels = channels | LogEntryType.Debug;
                }
                else
                {
                    WriteDebug(_MessageStreams);
                    channels = channels | LogEntryType.Debug;
                }

                if (restoreInquire)
                {
                    InvokeCommand.InvokeScript(false, ScriptBlock.Create(@"$DebugPreference = 'Inquire'"), null, null);
                }
            }
            #endregion Message handling

            #region Logging
            LogEntry entry = LogHost.WriteLogEntry(_MessageSystem, channels, _timestamp, FunctionName, ModuleName, _Tags, Level, System.Management.Automation.Runspaces.Runspace.DefaultRunspace.InstanceId, Environment.MachineName, File, Line, _callStack, String.Format("{0}\\{1}", Environment.UserDomainName, Environment.UserName), errorRecord, String, StringValues, Target);
            #endregion Logging

            foreach (MessageEventSubscription subscription in MessageHost.Events.Values)
            {
                if (subscription.Applies(entry))
                {
                    try { InvokeCommand.InvokeScript(subscription.ScriptBlock.ToString(), entry); }
                    catch (Exception e) { WriteError(new ErrorRecord(e, "", ErrorCategory.NotSpecified, entry)); }
                }
            }
        }
Example #55
0
 public void Log(MessageLevel level, string message, params object[] args)
 {
 }
Example #56
0
 public MsgToggleAttribute(string message, MessageLevel messageLevel) : base(message)
 {
     this.messageLevel = messageLevel;
 }
Example #57
0
        /// <summary>
        /// This is used to execute the build assembler instance using the specified configuration file and
        /// manifest file.
        /// </summary>
        /// <param name="configuration">The build assembler configuration</param>
        /// <param name="manifest">The manifest file</param>
        public virtual void Execute(XPathDocument configuration, string manifest)
        {
            Task builder = Task.Factory.StartNew(() =>
            {
                try
                {
                    XPathNavigator configNav = configuration.CreateNavigator();

                    // See if a verbosity level has been specified.  If so, set it.
                    var verbosity = configNav.SelectSingleNode("/configuration/@verbosity");
                    MessageLevel level;

                    if (verbosity == null || !Enum.TryParse <MessageLevel>(verbosity.Value, out level))
                    {
                        level = MessageLevel.Info;
                    }

                    this.VerbosityLevel = level;

                    if (level > MessageLevel.Info)
                    {
                        messageLog.Add(LogMessage(LogLevel.Info, "Loading configuration..."));
                    }

                    // Load the context
                    XPathNavigator contextNode = configNav.SelectSingleNode(
                        "/configuration/dduetools/builder/context");

                    if (contextNode != null)
                    {
                        this.Context.Load(contextNode);
                    }

                    // Find all available build components
                    this.CreateComponentContainer(configNav.SelectSingleNode(
                                                      "/configuration/dduetools/builder/componentLocations"));

                    // Load the build components
                    XPathNavigator componentsNode = configNav.SelectSingleNode(
                        "/configuration/dduetools/builder/components");

                    if (componentsNode != null)
                    {
                        this.AddComponents(componentsNode);
                    }

                    // Proceed through the build manifest, processing all topics named there
                    if (level > MessageLevel.Info)
                    {
                        messageLog.Add(LogMessage(LogLevel.Info, "Processing topics..."));
                    }

                    int count = this.Apply(manifest);

                    messageLog.Add(LogMessage(LogLevel.Info, String.Format(CultureInfo.CurrentCulture,
                                                                           "Processed {0} topic(s)", count)));

                    if (warningCount != 0)
                    {
                        messageLog.Add(LogMessage(LogLevel.Info, String.Format(CultureInfo.CurrentCulture,
                                                                               "{0} warning(s)", warningCount)));
                    }
                }
                finally
                {
                    messageLog.CompleteAdding();
                }
            }, tokenSource.Token);

            Task logger = Task.Factory.StartNew(() =>
            {
                foreach (var msg in messageLog.GetConsumingEnumerable())
                {
                    messageLogger(msg.Item1, msg.Item2);
                }
            }, tokenSource.Token);

            Task.WaitAll(new[] { builder, logger }, tokenSource.Token);
        }
Example #58
0
 public MsgToggleAttribute(string message, int height, MessageLevel messageLevel) : base(message, height)
 {
     this.messageLevel = messageLevel;
 }
Example #59
0
 public MessageLevel CalculateMessageLevel(IMessaging messaging, Message message, MessageLevel defaultMessageLevel) => defaultMessageLevel;
Example #60
0
 public MsgToggleAttribute(string message, int height, bool isInverted, MessageLevel messageLevel) :
     this(message, height, isInverted)
 {
     this.messageLevel = messageLevel;
 }