/// <summary> /// Write a log message. /// </summary> /// <param name="message">Log message.</param> /// <param name="startNewLine">Start a new line before this message. True by default.</param> /// <param name="style">The style of the message</param> public static void WriteLog(string message, bool startNewLine = true, LogStyle style = LogStyle.Default) { if (UtilCallBackFunctions.WriteLog != null) { UtilCallBackFunctions.WriteLog(message, startNewLine, style); } }
// --------------------------------------------------------- // @ GUI private void OnGUI() { System.Action showTraceImpl = () => { }; /// creates an empty method by default int index = 0; /// Set the logs start position Vector2 pos = TopLeft; foreach (OnScreenLog log in mLogs) { // Set Log style LogStyle style = Style.GetStyle(log.Type); Color styleColour = style.FontColour; mLogStyle.normal.textColor = styleColour; mLogStyle.fontStyle = style.FontStyle; /// Calculate the log size float logScale = Style.FontSize * log.NumOfBreakLines + MarginTop; float traceLogScale = 0.0f; // If show tracing: allocate to print the trace log if (ShowTrace) { // Set Trace Log Style mTraceStyle.normal.textColor = styleColour; /// calculate the trace log size traceLogScale = Style.TraceFontSize * log.NumOfTraceBreakLines + TraceMarginTop - INTERNAL_TRACE_PADDING; /// allocate the print trace log showTraceImpl = () => { /// offset the trace by size of the log message (putting the trace log right underneath) pos.y += mDirection * (logScale + TraceMarginTop); mBoundingBox.position = pos; GUI.Label(mBoundingBox, log.LogTrace, mTraceStyle); }; } // Print the Log mBoundingBox.position = pos; GUI.Label(mBoundingBox, (++index).ToString() + ": " + log.Log, mLogStyle); /// this is used to avoid having to call the same if statement twice! /// by setting the value to nothing by default, and then in the ONE if statement, /// set it to a new internal method that offsets and prints the trace log showTraceImpl(); /// offset the trace by the number of log messages pos.y += mDirection * (logScale + traceLogScale); } /// if clear screen overflow is enabled and the position has exceeded the screen size, start dequeing the top if (ClearScreenOverflow && pos.y > Screen.height) { mLogs.Dequeue(); } }
public LogEntriesResult(string log, string conditions, string minutes, string from, string until, string include, string exclude) { this.log = String.IsNullOrEmpty(log) ? "log" : log; this.conditions = conditions; this.include = include; this.exclude = exclude; if (!String.IsNullOrEmpty(from)) // use from/until style { this.style = LogStyle.from_until; try { var max_span = TimeSpan.FromHours(24); this.from = DateTime.Parse(from).ToUniversalTime(); if (String.IsNullOrEmpty(until)) { this.until = this.from + TimeSpan.FromHours(1); } else { this.until = DateTime.Parse(until).ToUniversalTime(); } if (this.until > this.from + max_span) { this.until = this.from + max_span; } } catch (Exception e) { GenUtils.PriorityLogMsg("exception", "LogEntriesResult: From/Until", e.Message + e.StackTrace); } } else // use recent minutes style { this.style = LogStyle.recent; try { var max = Convert.ToInt32(settings["max_log_minutes"]); var recent = Convert.ToInt32(settings["recent_log_minutes"]); if (minutes != null) { this.minutes = Convert.ToInt32(minutes); if (this.minutes > max) { this.minutes = max; } } else { this.minutes = recent; } } catch (Exception e) { GenUtils.PriorityLogMsg("exception", "LogEntriesResult: Recent", e.Message + e.StackTrace); } } }
static void DisplayLogStyleLabels(LogStyle style, string name) { GUIStyle skin = new GUIStyle(); skin.normal.textColor = style.FontColour; skin.fontStyle = style.FontStyle; EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(name); EditorGUILayout.LabelField("(" + name + ")", skin); EditorGUILayout.EndHorizontal(); }
void DisplayLogStyles() { EditorGUILayout.LabelField("Log Types", EditorStyles.boldLabel); for (int i = 0; i < mEnumNames.Length; i++) { LogStyle style = mTarget.Logs[i]; EditorGUILayout.BeginVertical(EditorStyles.helpBox); DisplayLogStyleLabels(style, mEnumNames[i]); DiplayLogStyle(style); EditorGUILayout.EndVertical(); } }
public void AppendGameLog(string key, LogStyle style, object arg0 = null, object arg1 = null, object arg2 = null) { var log = GameString.Current.BattleLog(key); if (log != null) { LogAppended(string.Format(this, log, arg0, arg1, arg2), style); } else if (key != Ls.NO_KEY) { AppendGameLog(Ls.NO_KEY, LogStyle.SYS, key); } }
/// update individual style! void UpdateStyle(LogStyle style) { Color styleColour = style.FontColour; // Log Style mLogStyle.normal.textColor = styleColour; mLogStyle.fontStyle = style.FontStyle; mLogStyle.font = Style.FontFace; mLogStyle.fontSize = Style.FontSize; // Trace Log Style mTraceStyle.fontSize = Style.TraceFontSize; mTraceStyle.normal.textColor = styleColour; }
private void ProcessStepStatus(LogStyle style) { if (this.DetectContext != null && this.DetectContext.StepStatusChanged != null && (!stepStatus.ContainsKey(StepIndex) || stepStatus[StepIndex] != style)) { this.DetectContext.StepStatusChanged(this.DetectContext.Id, StepIndex, style); this.stepStatus[StepIndex] = style; } if (style != LogStyle.Default) { StepIndex++; } }
public async Task <CommandResult> SetLogStyle(LogStyle value) { var g = await _databaseService.GetOrCreateGuildAsync(Context.Guild); if (value == g.LogStyle) { return(new QuiccbanFailResult(string.Format(_responseService.Get("log_style_already_same"), value))); } g.LogStyle = value; await _databaseService.UpdateGuildAsync(g); return(new QuiccbanSuccessResult(string.Format(_responseService.Get("log_style_success"), value))); }
/// <summary> /// Write a log message. /// </summary> /// <param name="level">Log level. Will throw exception when using LogLevel.Error</param> /// <param name="msg">Log message.</param> /// <param name="startNewLine">Start a new line before this message when to UI. True by default.</param> /// <param name="style">The style of the message</param> public void AddLog(LogLevel level, string msg, bool startNewLine = true, LogStyle style = LogStyle.Default) { switch (level) { case LogLevel.Information: case LogLevel.Warning: DetectorUtil.WriteLog(msg, startNewLine, style); break; case LogLevel.Error: AddLog(LogLevel.Information, msg); // PTM will handle the exception and pop up a dialog box to user. throw new Exception(msg); default: break; } }
public static void Add(LogStyle style, string message) { if (!File.Exists(AppPath + "\\operationlog.txt")) { CreateLog(); } using (StreamWriter streamWriter = new StreamWriter(AppPath + "\\operationlog.txt", true, System.Text.Encoding.Default)) { string input = String.Format("[{0}] {1}: {2}", StringError(style), DateTime.Now, message ); streamWriter.WriteLine(input); } }
/// <summary> /// Write a log message. /// </summary> /// <param name="msg">Log message.</param> /// <param name="level">Log level.</param> /// <param name="startNewLine">Start a new line before this message when to UI. True by default.</param> /// <param name="style">The style of the message</param> public void AddLog(string msg, LogLevel level, bool startNewLine = true, LogStyle style = LogStyle.Default) { switch (level) { case LogLevel.Advanced: if (this != null) this.AppendLog("[" + DateTime.Now + "]" + msg); break; case LogLevel.Normal: AddLog(msg, LogLevel.Advanced); DetectorUtil.WriteLog(msg, startNewLine, style); break; case LogLevel.Error: AddLog(msg, LogLevel.Advanced); throw new Exception(msg); default: break; } }
private static string StringError(LogStyle style) { if (style == LogStyle.Error) { return("Error"); } if (style == LogStyle.Information) { return("Information"); } if (style == LogStyle.Warning) { return("Warning"); } return("null"); }
/// <summary> /// Write a log message. /// </summary> /// <param name="msg">Log message.</param> /// <param name="level">Log level.</param> /// <param name="startNewLine">Start a new line before this message when to UI. True by default.</param> /// <param name="style">The style of the message</param> public void AddLog(LogLevel level, string msg, bool startNewLine = true, LogStyle style = LogStyle.Default) { switch (level) { case LogLevel.Information: DetectorUtil.WriteLog("[" + DateTime.Now + "]" + msg); break; case LogLevel.Warning: DetectorUtil.WriteLog(msg, startNewLine, style); break; case LogLevel.Error: AddLog(LogLevel.Information, msg); throw new Exception(msg); default: break; } }
public void GameLogAppended(string text, LogStyle style) { if (!style.HasFlag(LogStyle.HiddenAfterBattle)) { if (style.HasFlag(LogStyle.NoBr)) { TextReport.Append(text); } else { TextReport.AppendLine(text); } } UIDispatcher.Invoke(() => { var align = style.HasFlag(LogStyle.Center) ? TextAlignment.Center : style.HasFlag(LogStyle.EndTurn) ? TextAlignment.Right : TextAlignment.Left; var color = SBrushes.GetBrush(style); var bold = style.HasFlag(LogStyle.Bold); if (!style.HasFlag(LogStyle.NoBr)) { text = text.LineBreak(); } if (!style.HasFlag(LogStyle.HiddenInBattle)) { RealTime.AddText(text, color, align, bold); } if (!style.HasFlag(LogStyle.HiddenAfterBattle)) { Full.AddText(text, color, align, bold); } Nest.AutoScroll(); if (beginTurn) { //Nest.nowTurn = new LinkedListNode<TextElement>(currentRealTime.Inlines.Last()); //Nest.turnsBookmark.AddLast(Nest.nowTurn); beginTurn = false; } }); }
private void OnLogEvent(string strLog, LogStyle Style) { BeginInvoke((Action)(() => { if (m_txtLogs.TextLength >= 5000) { m_txtLogs.ResetText(); } if (Style == LogStyle.HighLight) { m_txtLogs.SelectionStart = m_txtLogs.TextLength; m_txtLogs.SelectionLength = 0; m_txtLogs.SelectionColor = Color.Red; m_txtLogs.AppendText(strLog + '\n'); m_txtLogs.SelectionColor = m_txtLogs.ForeColor; } else { m_txtLogs.AppendText(strLog + '\n'); } })); }
/// <summary> /// Write a log message. /// </summary> /// <param name="msg">Log message.</param> /// <param name="level">Log level.</param> /// <param name="startNewLine">Start a new line before this message when to UI. True by default.</param> /// <param name="style">The style of the message</param> public void AddLog(string msg, LogLevel level, bool startNewLine = true, LogStyle style = LogStyle.Default) { switch (level) { case LogLevel.Advanced: if (this != null) { this.AppendLog("[" + DateTime.Now + "]" + msg); } break; case LogLevel.Normal: AddLog(msg, LogLevel.Advanced); DetectorUtil.WriteLog(msg, startNewLine, style); break; case LogLevel.Error: AddLog(msg, LogLevel.Advanced); throw new Exception(msg); default: break; } }
/// <summary> /// Creates a new instance of SysEEPLog /// </summary> /// <param name="clientinfo">Information of client</param> /// <param name="style">Log style</param> /// <param name="status">Log status</param> /// <param name="time">Datetime</param> /// <param name="title">Title of log</param> /// <param name="description">Description of log</param> public SysEEPLog(object[] clientinfo, LogStyle style, LogStatus status, DateTime time, string title, string description) : base(INFOREMOTEMODULE_ASSEMBLY, SYSEEPLOG_TYPE, new object[] { clientinfo, style, status, time, title, description }) { }
public LogEntriesResult(string log, string conditions, string minutes, string from, string until, string include, string exclude) { this.log = String.IsNullOrEmpty(log) ? "log" : log; this.conditions = conditions; this.include = include; this.exclude = exclude; if ( ! String.IsNullOrEmpty(from) && ! String.IsNullOrEmpty(until) ) // use from/until style { this.style = LogStyle.from_until; try { var max_span = TimeSpan.FromHours(24); this.from = DateTime.Parse(from).ToUniversalTime(); this.until = DateTime.Parse(until).ToUniversalTime(); if ( this.until > this.from + max_span ) this.until = this.from + max_span; } catch (Exception e) { GenUtils.PriorityLogMsg("exception", "LogEntriesResult: From/Until", e.Message + e.StackTrace); } } else // use recent minutes style { this.style = LogStyle.recent; try { var max = Convert.ToInt32(settings["max_log_minutes"]); var recent = Convert.ToInt32(settings["recent_log_minutes"]); if (minutes != null) { this.minutes = Convert.ToInt32(minutes); if (this.minutes > max) this.minutes = max; } else this.minutes = recent; } catch (Exception e) { GenUtils.PriorityLogMsg("exception", "LogEntriesResult: Recent", e.Message + e.StackTrace); } } }
public DetectingItem(string content, DetectingStatus status, LogStyle style) { this.DetectingContent = content; this.DetectingStatus = status; this.Style = style; }
/// <summary> /// Write a log message. /// </summary> /// <param name="message">Log message.</param> /// <param name="startNewLine">Start a new line before this message. True by default.</param> /// <param name="style">The style of the message</param> public static void WriteLog(string message, bool startNewLine = true, LogStyle style = LogStyle.Default) { if (UtilCallBackFunctions.WriteLog != null) UtilCallBackFunctions.WriteLog(message, startNewLine, style); }
// Member Functions ------------------------------------------------------------------------------------- public static void CreateLog(string _logId, LogVerbosity _logVerbosity, LogStyle _style, Action <string> _outputAction) { m_Logs.Add(_logId, new MsgLog(_style, _logVerbosity, _outputAction));; }
public MsgLog(LogStyle _style, LogVerbosity _verbosity, Action <string> _outputAction) { Style = _style; m_VerbosityMask = (byte)_verbosity; m_OutputAction = _outputAction; }
public void Log(string strLog, LogStyle logStyle = LogStyle.Normal) { LogEventListener(strLog, logStyle); LogToFile(strLog); }
protected void AppendGameLog(string key, LogStyle style, ValueType arg0 = null, ValueType arg1 = null, ValueType arg2 = null) { Game.AppendGameLog(key, style, arg0, arg1, arg2); }
static void DiplayLogStyle(LogStyle style) { EditorGUILayout.BeginHorizontal(); SetGlobalStyle(ref style.FontStyle, ref style.FontColour); EditorGUILayout.EndHorizontal(); }