コード例 #1
0
ファイル: RemoteLogger.cs プロジェクト: mrbuchanan/historian
        public async Task LogAsync(string contents, string channel, MessageKind kind = MessageKind.Information, string title = null, params string[] tags)
        {
            // check inputs
            if (string.IsNullOrEmpty(title))
            {
                title = kind.ToString();
            }

            // create message
            var message = new Message()
            {
                Contents = contents,
                Channel  = channel,
                Kind     = kind,
                Title    = title
            };

            // check and add tags
            if (tags != null)
            {
                tags.ToList();
            }

            // send message
            await DoSendAsync(message, _configuration);
        }
コード例 #2
0
        public void Log(string contents, string channel, MessageKind kind = MessageKind.Information, string title = null, params string[] tags)
        {
            // check inputs
            if (string.IsNullOrWhiteSpace(title))
            {
                title = kind.ToString();
            }

            // create message
            var message = new Message()
            {
                Contents = contents,
                Channel  = channel,
                Kind     = kind,
                Title    = title
            };

            // check and add tags
            if (tags != null)
            {
                message.Tags = tags.ToList();
            }

            // log the message
            Log(message);
        }
コード例 #3
0
    void AddMessage(MessageKind kind, string format, params object[] args)
    {
        var msg1 = string.Format(format, args);
        var msg2 = string.Format("{0}: {1}\n", kind.ToString("G").PadRight(16, ' '), msg1);

        textviewLog.Buffer.Text += msg2;
    }
コード例 #4
0
        public virtual void MessageWithoutLocalizing(string message, MessageKind kind = MessageKind.Progress)
        {
            dynamic messageBundle = new DynamicJson();

            messageBundle.message = message;
            messageBundle.kind    = kind.ToString();
            _bloomWebSocketServer.SendBundle(_clientContext, "message", messageBundle);
            // for any old-style listeners
            _bloomWebSocketServer.SendString(_clientContext, "progress", message);
        }
コード例 #5
0
ファイル: Message.cs プロジェクト: botworx/botworx-dotnet
        public override string ToString()
        {
            string clauseString = "";

            if (Clause != null)
            {
                clauseString = Clause.ToString();
            }
            else
            {
                clauseString = "null";
            }

            string msgString = string.Format("{0} {1} ", Kind.ToString(), clauseString);

            return(msgString);
        }
コード例 #6
0
ファイル: SiteCrawler.cs プロジェクト: eugene-tt/Code-Samples
 private void doReport(MessageKind msgKind, string msgText)
 {
     // Depends on the message kind and if we have the handlers
     if (onReport != null && msgKind != MessageKind.Trace)
     {
         // Inform the caller only of a meaningful stuff
         onReport(msgKind, msgText);
     }
     else
     {
         // Trace and unhandled messages go to the debug console
         string debugMessage = String.Format("{0}: {1} - {2}",
                                             DateTime.Now.ToShortTimeString(),
                                             msgKind.ToString(),
                                             msgText.ToString()
                                             );
         System.Diagnostics.Debug.WriteLine(debugMessage);
     }
 }
コード例 #7
0
ファイル: MemoryLogger.cs プロジェクト: mrbuchanan/historian
        public void Log(string contents, string channel, MessageKind kind = MessageKind.Information, string title = null, params string[] tags)
        {
            if (string.IsNullOrWhiteSpace(title))
            {
                title = kind.ToString();
            }

            var message = new Message()
            {
                Contents = contents,
                Channel  = channel,
                Kind     = kind,
                Title    = title
            };

            if (tags != null)
            {
                message.Tags = tags.ToList();
            }

            Log(message);
        }
コード例 #8
0
ファイル: ConsoleLogger.cs プロジェクト: chris1201/binskim
        public static string GetMessageText(BinaryAnalyzerContext context, string message, MessageKind messageKind)
        {
            string path = null;
            Uri    uri  = context.Uri;

            if (uri != null)
            {
                // If a path refers to a URI of form file://blah, we will convert to the local path
                if (uri.IsAbsoluteUri && uri.Scheme == Uri.UriSchemeFile)
                {
                    path = uri.LocalPath;
                }
                else
                {
                    path = uri.ToString();
                }
            }

            string issueType = null;

            switch (messageKind)
            {
            case MessageKind.ConfigurationError:
            {
                issueType = "CONFIGURATION ERROR";
                break;
            }

            case MessageKind.InternalError:
            {
                issueType = "INTERNAL ERROR";
                break;
            }

            case MessageKind.Fail:
            {
                issueType = "error";
                break;
            }

            case MessageKind.Pending:
            {
                issueType = "pending";
                break;
            }

            case MessageKind.Pass:
            {
                issueType = "pass";
                break;
            }

            case MessageKind.NotApplicable:
            case MessageKind.Note:
            {
                issueType = "note";
                break;
            }

            default:
            {
                throw new InvalidOperationException("Unknown message kind:" + messageKind.ToString());
            }
            }

            string detailedDiagnosis = NormalizeMessage(message, enquote: false);

            return((path != null ? (path + ": ") : "") +
                   issueType + ": " +
                   context.Rule.Id + ": " +
                   detailedDiagnosis);
        }