public void WriteLine(LogKind logKind, string text)
        {
            Logger.Write(logKind, Prefix);
            Logger.WriteLine(logKind, text);

            isNewLine = true;
        }
Example #2
0
 public LogTemporary(LogKind logKind, SockObj sockObj, int messageNo, String detailInfomation)
 {
     LogKind = logKind;
     SockObj = sockObj;
     MessageNo = messageNo;
     DetailInfomation = detailInfomation;
 }
 public void Write(LogKind logKind, string text)
 {
     capturedOutput.Add(new OutputLine
     {
         Kind = logKind,
         Text = text
     });
 }
 public void Write(LogKind logKind, string format, params object[] args)
 {
     var s = string.Format(EnvironmentHelper.MainCultureInfo, format, args).AddPrefixMultiline(Prefix);
     if (!isNewLine)
         s = s.Remove(0, Prefix.Length);
     Logger.Write(logKind, s);
     isNewLine = s.EndsWith("\n");
 }
Example #5
0
 public void Write(LogKind logKind, string format, params object[] args)
 {
     CapturedOutput.Add(new OutputLine
     {
         Kind = logKind,
         Text = args.Length == 0 ? format : string.Format(CultureInfo.InvariantCulture, format, args)
     });
 }
        public void Write(LogKind logKind, string text)
        {
            if (isNewLine)
            {
                Logger.Write(logKind, Prefix);
                isNewLine = false;
            }

            Logger.Write(logKind, text);
        }
Example #7
0
 public OneLog(DateTime dt, LogKind logKind, String nameTag, long threadId, String remoteHostname, int messageNo, String message, String detailInfomation)
 {
     _dt = dt;
     _logKind = logKind;
     _nameTag = nameTag;
     _threadId = threadId;
     _remoteHostname = remoteHostname;
     _messageNo = messageNo;
     _message = message;
     _detailInfomation = detailInfomation;
 }
Example #8
0
 internal Log(LogKind kind, string message, Exception exception, [CallerFilePath] string fileName = null, [CallerLineNumber] int fileLine = 0, [CallerMemberName] string memberName = null)
 {
     this.kind = kind;
     this.message = message;
     this.exceptionMessage = exception.Message;
     #if DEBUG
     this.fileName = fileName;
     this.fileLine = fileLine;
     this.memberName = memberName;
     #endif
 }
Example #9
0
        public void Log(string msg, LogKind kind)
        {
            this.xwr.WriteStartElement("message", LogFileNamespace);
            switch (kind)
            {
                case LogKind.Error:
                    this.xwr.WriteAttributeString("kind", "error");
                    break;
                case LogKind.Warning:
                    this.xwr.WriteAttributeString("kind", "warning");
                    break;
            }

            this.xwr.WriteString(msg);
            this.xwr.WriteEndElement();
        }
Example #10
0
        public void Log(string msg, LogKind kind)
        {
            if (!atStartOfLine) {
            Console.WriteLine("...");
            atStartOfLine = true;
              }

              var savedColor = Console.ForegroundColor;

              switch (kind) {
            case LogKind.Error:
              Console.ForegroundColor = ConsoleColor.Red;
              break;
            case LogKind.Warning:
              Console.ForegroundColor = ConsoleColor.Yellow;
              break;
              }

              Console.WriteLine(msg);
              Console.ForegroundColor = savedColor;
        }
Example #11
0
        static void Log(LogKind kind, string message)
        {
            if (!DebugMode)
                return;

            if ((int)kind < (int)SettingsManager.Current.Verbosity)
                return;

            string kindStr = "";
            
            switch (kind)
            {
                case LogKind.Notice:
                    kindStr = "Notice: ";
                    break;
                case LogKind.Warning:
                    kindStr = "Warning: ";
                    break;
                case LogKind.Error:
                    kindStr = "Error: ";
                    break;
                case LogKind.Fatal:
                    kindStr = "Fatal: ";
                    break;
            }

            string logStr = "[" + DateTime.Now + "] " + kindStr + message;

            if (SettingsManager.Current.LogToDebugConsole)
            {
                Debug.WriteLine(logStr);
            }

            if (SettingsManager.Current.LogToFile)
            {
                SW.WriteLine(logStr);
            }

        }
Example #12
0
 public void Set(LogKind logKind,SockObj sockBase,int messageNo,string detailInfomation)
 {
     if (_logger != null){
         _logger.Set(logKind, sockBase, messageNo, detailInfomation);
     }
 }
Example #13
0
 public void WriteLine(LogKind logKind, string text) => Console.WriteLine(text);
 public void WriteLine(LogKind logKind, string text)
 {
     builder.AppendLine(text);
     Flush();
 }
Example #15
0
 public void WriteLine(LogKind logKind, string text)
 {
     _buffer.AppendLine(text);
 }
Example #16
0
 public override void WriteLine(LogKind logKind, string text)
 {
     _testOutputHelper.WriteLine(_currentLine + RemoveInvalidChars(text));
     _currentLine = "";
     base.WriteLine(logKind, text);
 }
 public void WriteLine(LogKind logKind, string text)
 {
     IsActivated = true;
 }
Example #18
0
 public virtual void Write(LogKind logKind, string format, params object[] args) =>
 builder.Append(string.Format(EnvironmentHelper.MainCultureInfo, format, args));
Example #19
0
 public void WriteLine(LogKind logKind, string text) => internalLogger.WriteLine(logKind, Escape(text));
 public override void Write(LogKind logKind, string text)
 {
     currentLine += RemoveInvalidChars(text);
     base.Write(logKind, text);
 }
 public override void WriteLine(LogKind logKind, string text)
 {
     testOutputHelper.WriteLine(currentLine + RemoveInvalidChars(text));
     currentLine = "";
     base.WriteLine(logKind, text);
 }
 public void Write(LogKind logKind, string format, params object[] args)
 {
     foreach (var logger in loggers)
         logger.Write(logKind, format, args);
 }
 private void WriteSimple(LogKind logKind, string text)
 {
     AddPrefixIfNeeded(logKind, text);
     Logger.Write(text);
 }
Example #24
0
 public new void Set(LogKind logKind, SockObj sockObj, int messageNo, String detailInfomation)
 {
     _ar.Add(new LogTemporary(logKind, sockObj, messageNo, detailInfomation));
 }
Example #25
0
        public void LogWithLocation(string code, string msg, Location loc, LogKind kind, bool isRelated)
        {
            this.xwr.WriteStartElement("message", LogFileNamespace);
            switch (kind) {
                case LogKind.Error:
                    this.xwr.WriteAttributeString("kind", "error");
                    break;
                case LogKind.Warning:
                    this.xwr.WriteAttributeString("kind", "warning");
                    break;
            }

            if (isRelated)
            {
                this.xwr.WriteAttributeString("isRelated", "true");
            }

            if (!String.IsNullOrEmpty(code))
            {
                this.xwr.WriteAttributeString("code", code);
            }

            this.WriteLocation(loc);
            this.xwr.WriteString(msg);
            this.xwr.WriteEndElement();
        }
Example #26
0
 public void WriteLine(LogKind logKind, string text) => _logger.WriteLine(logKind,
                                                                          $"{logKind.ToString()} - {text}");
 /// <summary>Write the line.</summary>
 /// <param name="logKind">Kind of text.</param>
 /// <param name="text">The text to write.</param>
 public void WriteLine(LogKind logKind, string text) => _writerLazy.Value.WriteLine(text);
Example #28
0
#pragma warning restore 420

        /// <summary>Checks if the line should be written.</summary>
        /// <param name="logKind">The kind of log message.</param>
        /// <returns><c>true</c> if the line should be written.</returns>
        protected virtual bool ShouldWrite(LogKind logKind) =>
        LogFilter == LogFilter.AllMessages ||
        _importantAreaCount > 0 ||
        // ReSharper disable once ArrangeRedundantParentheses
        ((logKind == LogKind.Error || logKind == LogKind.Hint) && LogFilter == LogFilter.PrefixedOrErrors);
 private string GetColor(LogKind logKind) =>
 colorScheme.TryGetValue(logKind, out var color) ? color : DefaultColor;
 public void WriteLine(LogKind logKind, string text)
 {
     IsActivated = true;
 }
Example #31
0
 /// <summary>
 /// Overloaded constructor.
 /// </summary>
 /// <param name="kind">message log type</param>
 /// <param name="message">The message to be logged</param>
 /// <param name="parameters">extended parameters</param>
 public MessageLogEventArgs(LogKind kind, string message, object[] parameters)
 {
     this.kind       = kind;
     this.message    = message;
     this.parameters = parameters;
 }
 public virtual void Write(LogKind logKind, string text) => builder.Append(text);
Example #33
0
 public override void WriteLine(LogKind logKind, string text)
 {
     testOutputHelper.WriteLine(currentLine + text);
     currentLine = "";
     base.WriteLine(logKind, text);
 }
Example #34
0
 public void WriteLine(LogKind logKind, string text)
 {
     Write(logKind, text);
     WriteLine();
 }
 public void Write(LogKind logKind, string text) => builder.Append(text);
 public void Write(LogKind logKind, string text)
 {
     this.output.Append(text);
 }
Example #37
0
 public override void Write(LogKind logKind, string text)
 {
     _currentLine += text;
     base.Write(logKind, text);
 }
 public void WriteLine(LogKind logKind, string text) => output.AppendLine(text);
Example #39
0
 private void WriteLog(LogKind kind, string message, Exception exception, string fileName, int fileLine, string memberName)
 {
     lock (this.syncRoot)
     {
         this.logs.Add(new Log(kind, message, exception, fileName, fileLine, memberName));
     }
 }
 private void Log(LogKind kind, string text, HtmlNode tnode = null)
 {
     string message = null;
     if (tnode != null)
     {
         if (this.currentFileName != null)
         {
             message = string.Format("{0} in {2} at ({3},{4}): {1}", kind.ToString().ToUpper(), text, this.currentFileName, tnode.Line, tnode.LinePosition);
         }
         else
         {
             message = string.Format("{0} at ({3},{4}): {1}", kind.ToString().ToUpper(), text, tnode.Line, tnode.LinePosition);
         }
     }
     else
     {
         message = string.Format("{0}: {1}", kind.ToString().ToUpper(), text);
     }
     if (LogFile != null)
     {
         LogFile.WriteLine(message);
     }
     else
     {
         Console.WriteLine(message);
     }
 }
Example #41
0
 void Log(LogKind logKind, int messageNo, string msg)
 {
     if(_logger != null){
         _logger.Set(logKind, _sockObj, messageNo, msg);
     }
 }
Example #42
0
 public void Write(LogKind logKind, string format, params object[] args) =>
     writer.Write(args.Length == 0 ? format : string.Format(cultureInfo, format, args));
 public override void WriteLine(LogKind logKind, string text)
 {
     testOutputHelper.WriteLine(text);
     base.WriteLine(logKind, text);
 }
Example #44
0
 public void WriteLine(LogKind logKind, string text)
 {
     stringBuilder.AppendLine(text);
 }
Example #45
0
 public void Write(LogKind logKind, string format, params object[] args)
 {
     Console.ForegroundColor = GetColor(logKind);
     Console.Write(args.Length == 0 ? format : string.Format(cultureInfo, format, args));
     Console.ForegroundColor = DefaultColor;
 }
Example #46
0
File: Logger.cs Project: tupipa/vcc
 public void Log(string msg, LogKind kind = LogKind.Message)
 {
     this.DoForAll(logger => logger.Log(msg, kind));
 }
 private void Write(LogKind logKind, Action <object> write, string text) =>
 write(WithStyle(text, "color:" + GetColor(logKind) + ";font-family:Consolas,'Lucida Console','Courier New',monospace"));
Example #48
0
 protected override void Init()
 {
     _dt = new DateTime(0);
     _logKind = LogKind.Normal;
     _threadId = 0;
     _nameTag = "UNKNOWN";
     _remoteHostname = "";
     _messageNo = 0;
     _message = "";
     _detailInfomation = "";
 }
Example #49
0
 public override void Write(LogKind logKind, string text)
 {
     _currentLine += RemoveInvalidChars(text);
     base.Write(logKind, text);
 }
 /// <summary>
 /// Overloaded constructor.
 /// </summary>
 /// <param name="kind">message log type</param>
 /// <param name="condition">the check condition</param>
 /// <param name="message">the error message to be logged</param>
 /// <param name="parameters">extended parameters</param>
 public MessageLogEventArgs(LogKind kind, bool condition, string message, object[] parameters)
 {
     this.kind = kind;
     this.condition = condition;
     this.message = message;
     this.parameters = parameters;
 }
 public void WriteLine(LogKind logKind, string text)
 {
 }
Example #52
0
 /// <summary>Writes text.</summary>
 /// <param name="logKind">Kind of text.</param>
 /// <param name="text">The text to write.</param>
 public void Write(LogKind logKind, string text) => _output.Write(text);
Example #53
0
 private ConsoleColor GetColor(LogKind logKind) =>
 colorScheme.ContainsKey(logKind) ? colorScheme[logKind] : DefaultColor;
 public LogType(LogKind kind, string msg)
 {
     Kind = kind;
     Message = msg;
 }
 public void WriteLine(LogKind logKind, string text)
 {
     Console.ForegroundColor = GetColor(logKind);
     Console.WriteLine(text);
     Console.ForegroundColor = DefaultColor;
 }
 /// <summary>
 /// Overloaded constructor.
 /// </summary>
 /// <param name="kind">message log type</param>
 /// <param name="message">the message to be logged</param>
 /// <param name="parameters">extended parameters</param>
 public MessageLogEventArgs(LogKind kind, string message, object[] parameters)
 {
     this.kind = kind;
     this.message = message;
     this.parameters = parameters;
 }
 public void Write(LogKind logKind, string text) => Write(logKind, Console.Write, text);
 public void WriteLine(LogKind logKind, string text)
 {
     Write(logKind, text);
     WriteLine();
 }
 private ConsoleColor GetColor(LogKind logKind) =>
     colorScheme.ContainsKey(logKind) ? colorScheme[logKind] : DefaultColor;
Example #60
0
        // Private Methods (2) 

        private static Guid AddLog(SPWeb spWeb, string message, string stackTrace, XElement details, LogKind kind,
                                   ObjectKind?objectKind, ActivityKind?activityKind)
        {
            Guid id = Guid.NewGuid();

            if (objectKind.HasValue)
            {
                details.Add(new XElement("ObjectKind", objectKind.Value.ToString()));
            }

            if (activityKind.HasValue)
            {
                details.Add(new XElement("ActivityKind", activityKind.Value.ToString()));
            }

            const string SQL =
                @"INSERT INTO SS_Logs (Id, Message, StackTrace, Details, Kind, WebId, UserId) VALUES (@Id, @Message, @StackTrace, @Details, @Kind, @WebId, @UserId)";

            SPSecurity.RunWithElevatedPrivileges(() =>
            {
                string cs = CoreFunctions.getReportingConnectionString(spWeb.Site.WebApplication.Id, spWeb.Site.ID);

                using (var sqlConnection = new SqlConnection(cs))
                {
                    using (var sqlCommand = new SqlCommand(SQL, sqlConnection))
                    {
                        sqlCommand.Parameters.AddWithValue("@Id", id);
                        sqlCommand.Parameters.AddWithValue("@Message", message);
                        sqlCommand.Parameters.AddWithValue("@StackTrace", stackTrace ?? string.Empty);
                        sqlCommand.Parameters.AddWithValue("@Details", details.ToString());
                        sqlCommand.Parameters.AddWithValue("@Kind", kind);
                        sqlCommand.Parameters.AddWithValue("@WebId", spWeb.ID);
                        sqlCommand.Parameters.AddWithValue("@UserId", spWeb.CurrentUser.ID);

                        sqlConnection.Open();
                        sqlCommand.ExecuteNonQuery();
                    }
                }
            });

            return(id);
        }