public void addLog(string method, string kind, string msg, LogType logType) { string localPath = ""; string logPath = AppDomain.CurrentDomain.BaseDirectory + "log/" + logType.ToString() + "/"; localPath = string.Format(logPath + "{0:yyyyMMdd}.log", DateTime.Now); lock (localPath) { StreamWriter writer = null; try { System.IO.FileInfo info = new FileInfo(localPath); if (!info.Directory.Exists) info.Directory.Create(); writer = new StreamWriter(localPath, true, System.Text.Encoding.UTF8); writer.WriteLine(string.Format("{0}[{1:HH:mm:ss}] 方法{2} 用户:{3}[end]", kind, DateTime.Now, method, msg)); } catch { if (writer != null) writer.Close(); } finally { if (writer != null) writer.Close(); } } }
private void Application_logMessageReceived(string _log, string _stack, LogType _type) { if (_type == LogType.Exception || _type == LogType.Error) { sw.WriteLine(System.DateTime.Now.ToString() + " | " + _log + " | " + _stack + " | " + _type.ToString()); } }
public static Boolean IsIncluded(this ECLogLevel logLevel, LogType logType) { ECLogLevel inputLevel; switch (logType) { case LogType.Error: inputLevel = ECLogLevel.Error; break; case LogType.Assert: inputLevel = ECLogLevel.Error; break; case LogType.Warning: inputLevel = ECLogLevel.Warning; break; case LogType.Log: inputLevel = ECLogLevel.Log; break; case LogType.Exception: inputLevel = ECLogLevel.Exception; break; default: inputLevel = ECLogLevel.All; break; } return (Int32)inputLevel <= (Int32)logLevel; }
private static void LogCallback(string message, string trace, LogType type) { if (System.Array.IndexOf(logTypes, type) != -1) { string supportData = null; try { if (collectSupportData != null) { supportData = collectSupportData(); } } catch { } try { var form = new WWWForm(); form.AddField("application", SafeString(appName)); form.AddField("version", SafeString(version)); form.AddField("userData", SafeString(userData)); form.AddField("supportData", SafeString(supportData)); form.AddField("userId", SafeString(userId)); form.AddField("message", SafeString(message)); form.AddField("trace", SafeString(trace)); new WWW(uri, form.data); } catch { } } }
public void LogFormat(LogType logType, UnityEngine.Object context, string format, params object[] args) { Debug.logger.logHandler.LogFormat(logType, context, format, args); if (UILogView.sInstance != null) { UILogView.sInstance.AddLog (string.Format (format, args)); } }
public static void Initialize(string file) { config = new Config(file); if (config != null) { IsInitialized = true; LogLevel = (LogType)config.Read("Log.Level", 0x7, true); LogDirectory = config.Read("Log.Directory", "Logs/World"); LogConsoleFile = config.Read("Log.Console.File", ""); LogPacketFile = config.Read("Log.Packet.File", ""); LogWriter fl = null; if (LogConsoleFile != "") { if (!Directory.Exists(LogDirectory)) Directory.CreateDirectory(LogDirectory); fl = new LogWriter(LogDirectory, LogConsoleFile); } Log.Initialize(LogLevel, fl); if (LogPacketFile != "") PacketLog.Initialize(LogDirectory, LogPacketFile); } ReadConfig(); }
public void Log(string message, LogType logType, string userUsername) { GlobalContext.Properties["LogType"] = logType.ToString(); GlobalContext.Properties["UserUsername"] = userUsername; log.Info(message); }
void HandleLog(string logString, string stackTrace, LogType type) { lock(queueLock) { queue.Enqueue(new Log(logString, stackTrace, type)); } }
public void log(string msg, int lvl, LoggingException e, LogType l, params Object[] p) { if (lvl <= this._maxLvl) { Logging.logStream(Console.Out, msg, lvl, e, l, p); } }
public void Write(string logfilename, string log, LogType lt) { #if UNITY_IPHONE || UNITY_ANDROID return; #endif string filePathName = WriteFile(logfilename); FileStream fs = new FileStream(filePathName, FileMode.Append); StreamWriter sw = new StreamWriter(fs); //开始写入 sw.WriteLine(""); // string str = "["; str += System.DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");//默认当天时间。 str += "]"; str += "\t"; str += lt.ToString(); str += "\t"; str += log; sw.Write(str); //清空缓冲区 sw.Flush(); //关闭流 sw.Close(); fs.Close(); }
public static void WriteLine( LogType logType, string line ) { try { LogType textLogVerboseFlag = sVerboseEnabled ? LogType.TextLogVerbose : (LogType)0; DateTime now = DateTime.Now; string dateLine = string.Format( "[{0} {1:d2}{2:d2}{3:d2}] {4}", now.ToShortDateString(), now.Hour, now.Minute, now.Second, line ); if ( ( logType & ( LogType.AppLog | LogType.Error ) ) > 0 ) GUI.MainForm.Instance.LogBox.WriteLine( now, line, ( ( logType & LogType.Error ) > 0 ) ? System.Drawing.Color.Red : System.Drawing.Color.Black ); if ( (logType & ( LogType.DebugLog | LogType.Error | textLogVerboseFlag ) ) > 0 ) System.Diagnostics.Debug.WriteLine( dateLine ); if ( (logType & ( LogType.TextLog | LogType.Error | textLogVerboseFlag ) ) > 0 ) { ReloadLogFile(); if ( mFileLog != null ) { mFileLog.WriteLine( dateLine ); mFileLog.Flush(); } } if ( LogLineEvent != null ) LogLineEvent( line ); } catch ( System.Exception ) { } }
public void Log( LogType type, string message ) { if( type == LogType.Error ) { Console.Write( DateTime.Now.ToString( LogTimeFormat ) + " > " ); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine( "ERROR: " + message ); Console.ForegroundColor = defaultCol; } else if( type == LogType.Warning ) { Console.Write( DateTime.Now.ToString( LogTimeFormat ) + " > " ); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine( "Warning: " + message ); Console.ForegroundColor = defaultCol; } else if( type == LogType.BotActivity ) { Console.Write( DateTime.Now.ToString( LogTimeFormat ) + " > " ); Console.ForegroundColor = ConsoleColor.DarkGray; Console.WriteLine( message ); Console.ForegroundColor = defaultCol; } else if( type == LogType.Chat ) { Console.Write( DateTime.Now.ToString( LogTimeFormat ) + " > " ); AppendChat( message ); } #if DEBUG else if( type == LogType.Debug ) { Console.Write( DateTime.Now.ToString( LogTimeFormat ) + " > " ); Console.WriteLine( "DEBUG: " + message ); } #endif }
/// <summary> /// Handles captured messages from the debug console /// </summary> /// <param name="logString">The message displayed</param> /// <param name="stackTrace">Stack trace of where the message occured (Mainly used with error and exception messaged)</param> /// <param name="type">What kind of message (Log, Warning, Warning, Error, Exception, Assert)</param> private void handleLog(string logString, string stackTrace, LogType type) { //If it's a log, just output it if (type.Equals(LogType.Log)) { println(logString); }//If it's a warning, include that type (Warning) else if(type.Equals(LogType.Warning)) { println(type + ": " + logString); }//Otherwise, it is serious and output the type, log, and stacktrace else { //Wrapping lines messes up the console //This curbs it a bit, but still allows for some stack output //Since in an error, reading what's wrong is most important if (stackTrace.Length < 250) { println(type + ": " + logString + " " + stackTrace); } else { println(type + ": " + logString + " " + stackTrace.Substring(0, 250)); } } }
public static void Log(string data, LogType type, bool writeToConsole) { string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\NJournals\\logs"; DirectoryInfo di = new DirectoryInfo(path); if (!di.Exists) { di.Create(); } if (writeToConsole) { Console.WriteLine(data); } using (StreamWriter sw = new StreamWriter(path + "\\NJournals" + DateTime.Now.ToString("MM-dd-yy") + ".log", true)) { sw.WriteLine("[" + type.ToString() + "] " + data); /*if (type != LogType.INFO && type != LogType.WARNING && type != LogType.ERR){ sw.WriteLine("[" + type.ToString() + "] " + data); } else { sw.WriteLine(data); }*/ } }
void Log (LogType type, string message) { using (var streamWriter = new StreamWriter(dir + _name, true)) { streamWriter.WriteLine(DateTime.Now.ToLongTimeString() + " | " + type.ToString().ToUpper() + " | " + message); } }
/// <summary> /// Default constructor for creating a log event /// </summary> /// <param name="log">Message of the log event</param> /// <param name="logType">Type of log event</param> /// <param name="textColor">Color of the text</param> /// <param name="bgColor">Color of the background</param> public LogEventArgs(string log, LogType logType, Color textColor, Color bgColor) { Message = log; LogType = logType; TextColor = textColor; BackgroundColor = bgColor; }
public static void Log(this object e, string logMessage = "", LogType type = LogType.SystemLog, string defaultSchema = "system", int severityLevel = 0) { if (_logSeverityLevel == -1) _logSeverityLevel = new AppConfig<ApplicationConfiguration>().GetConfigValue<int>("LogSeverityLevel"); if ((e as Exception) != null) type = LogType.ExceptionLog; else if ((e as string) != null) logMessage += e; if (severityLevel > _logSeverityLevel) return; logMessage = logMessage.Replace("'", "''"); switch (type) { case LogType.ExceptionLog: var innerException = (Exception)e; logMessage += innerException.Message; while (innerException.InnerException != null) { logMessage += innerException.Message; innerException = innerException.InnerException; } AppLogger.Error(logMessage); break; case LogType.SystemLog: AppLogger.Info(logMessage); break; case LogType.ScheduledLog: DAL.DefaultDb.ExecuteNonQuery(CommandType.Text, string.Format(Resources.Resources.LogScript_sql, defaultSchema, (int)type, logMessage)); AppLogger.Info(logMessage); break; } }
private static void Log(LogType logType, string text) { if (logType == LogType.Error) Debug.LogError("[AssetBundleManager] " + text); else if (m_LogMode == LogMode.All) Debug.Log("[AssetBundleManager] " + text); }
/// <summary> /// Default constructor for creating a log event /// </summary> /// <param name="log">Message of the log event</param> /// <param name="logType">Type of log event</param> public LogEventArgs(string log, LogType logType) { Message = log; LogType = logType; TextColor = Color.White; BackgroundColor = Color.Black; }
/// <summary> /// Write a message log /// </summary> /// <param name="logType">Value of LogType</param> /// <param name="message">Message to log</param> /// <param name="messageId">Id of the message</param> /// <remarks> /// The message is completed with some information like: /// Date/time /// Url and UserAgent if available /// </remarks> public override void Write(LogType logType, string message, int messageId) { base.Write(logType, message, messageId); message = EnrichMessage(message); WriteTrace(logType, message, messageId); }
static void logCallback(string condition, string stackTrace, LogType type) { if (type > LogType.Warning) return; string msg = ""; msg = string.Format("{0}{1}\n{2}", msg, condition, stackTrace); log(msg); }
public static void Write(LogType lt, string location, string message) { switch (lt) { case LogType.ERROR: Console.ForegroundColor = ConsoleColor.Red; Console.Write("[" + location + "] "); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(message); break; case LogType.MESSAGE: Console.ForegroundColor = ConsoleColor.Green; Console.Write("[" + location + "] "); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(message); break; case LogType.WARNING: Console.ForegroundColor = ConsoleColor.Yellow; Console.Write("[" + location + "] "); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(message); break; } }
/// <summary> /// Handles the standard unity log output. /// </summary> /// <param name='logString'> /// Log string. /// </param> /// <param name='stackTrace'> /// Stack trace. /// </param> /// <param name='type'> /// Type. /// </param> public void HandleUnityLog(string logString, string stackTrace, LogType type) { if (stackTrace == null) stackTrace = "(null)"; if (logString == null) logString = "(null)"; switch(type) { case LogType.Log: _log(logString, "Unity3D.Debug.Log", "DEBUG"); break; case LogType.Warning: _log(logString, "Unity3D.Debug.LogWarning", "WARN"); break; case LogType.Error: _log(logString, "Unity3D.Debug.LogError", "ERROR"); break; case LogType.Exception: _log(logString + ": " + stackTrace, "Unity3D.Debug.LogException", "FATAL"); break; case LogType.Assert: _log(logString, "Unity3D.Debug.LogAssert", "INFO"); break; default: _log(logString, "Unity3D.Debug.Log", "INFO"); break; } }
private static string GetMessage(LogType type, string message, Exception exception = null) { string messageToLog = string.Empty; if (exception != null) { messageToLog = string.Format(LogMessageException, GetTimeStamp(), type.ToString(), message, exception.GetType(), exception.Message, (exception.InnerException != null && exception.InnerException.Message != null) ? exception.InnerException.Message : "None", exception.Source ); } else { messageToLog = string.Format(LogMessageBrief, GetTimeStamp(), type.ToString(), message ); } return messageToLog; }
public void Write(string Message, LogType MessageType) { string sAssembly = Assembly.GetCallingAssembly().FullName; string sMethod = qualifiedObjName(); this.Write(sAssembly, sMethod, Message, MessageType); }
// Log Handler public static void Log(LogType lt, string format, params object[] parameters) { if (bot.InvokeRequired) bot.Invoke(new LogInvoke(Log), new object[] { lt, format, parameters }); else bot.Log(lt, String.Format(format, parameters)); }
public Task<bool> LogAsync(LogType type, string message) { var messageToLog = GetMessage(type, message); System.Diagnostics.Debug.WriteLine(messageToLog); return Task.FromResult(true); }
private static void HandleLog(string condition, string stackTrace, LogType type) { for (var i = 0; i < _callbacks.Count; ++i) { _callbacks[i](condition, stackTrace, type); } }
public static void LogTrace(LogType logType, string message, params object[] args) { try { switch (logType) { case LogType.Debug: log.DebugFormat(message, args); break; case LogType.Error: log.ErrorFormat(message, args); break; case LogType.Fatal: log.FatalFormat(message, args); break; case LogType.Info: log.InfoFormat(message, args); break; case LogType.Warn: log.WarnFormat(message, args); break; } } catch (Exception e) { log.WarnFormat(e.Message); } }
public static void Write(LogType lt, string message) { StackFrame frame = new StackFrame(1); MethodBase method = frame.GetMethod(); string loc = method.DeclaringType.Name; Write(lt, loc == "Main" ? "MapleSharp" : loc, message); }
public LogMessage(Exception exception) { LogType = LogType.Exception; Exception = exception; }
/// <summary>Initializes with the title that will be used when logging to the event log.</summary> /// <param name="name">String app name.</param> /// <param name="loglevel">Minimum log level.</param> public EventLogger(string name, LogType loglevel) : this(name) { this.level = loglevel; }
private void OnException(string logString, string stackTrace, LogType type) { Main.m_Event.Throw(this, Main.m_ReferencePool.Spawn <EventException>().Fill(logString, stackTrace, type)); }
/// ----------------------------------------------------------------------------- /// <summary> /// This Constructor builds a LogEntry from its type and description /// </summary> /// <remarks> /// </remarks> /// <param name="description">The description (detail) of the entry</param> /// <param name="type">The type of LogEntry</param> /// ----------------------------------------------------------------------------- public LogEntry(LogType type, string description) { Type = type; _description = description; }
void log(string cond, string trace, LogType lt) { logText += cond; logText += "\n"; }
private static void ProcessExceptionReport(string message, string stackTrace, LogType type) { //string text = string.Concat(" [SYS_", type, "]: ", message, '\n', stackTrace); //switch (type) //{ // case LogType.Assert: // Assertion(text); // break; // case LogType.Error: // case LogType.Exception: // Error(text); // break; // case LogType.Log: // Info(text); // break; // case LogType.Warning: // Warning(text); // break; // default: // break; //} }
private void OnApplicationLogMessageReceived(string condition, string stackTrace, LogType type) { if (type == LogType.Exception) { IsBusy = false; } }
private extern static int LSLog(LogType type, string unused, string message);
public UserLogModel(long userId, LogType logType) { UserId = userId; LogType = logType; }
public LogMessage(LogType logType, string message) { LogType = logType; Message = message; }
public void Log(LogType type, ISession session, string message, params object[] parameters) { Log(type, session, string.Format(message, parameters)); }
public static void Log(LogType type, string message) { LSLog(type, null, message); }
public void Register(OnConnectCallback onconnect, OnCloseCallback onclose, OnMessageCallback onmessage, LogType log = null) { this.onconnect = onconnect; this.onclose = onclose; this.onmessage = onmessage; this.log = log; if (this.log == null) { this.log = Console.WriteLine; } }
void ShowTips(string msg, string stackTrace, LogType type) { tips += msg; }
private void OnLogMessageReceived(string condition, string stacktrace, LogType type) { Show(condition, _messageShowDuration); }
public bool EnableLog(LogType logType) { return((int)(this.Options.LogLevel) <= (int)logType); }
private void IncrementCount(LogType type) { counts[type] = counts.ContainsKey(type) ? counts[type] + 1 : 1; UpdateCountTexts(); }
/// <summary> /// Called when the application calls Debug.Log and friends /// </summary> /// <param name="condition">The message</param> /// <param name="stackTrace">The stack trace</param> /// <param name="type">The type of log</param> private void Application_logMessageReceivedThreaded(string condition, string stackTrace, LogType type) { LogCallback(condition, stackTrace, type); }
/// <summary> /// Construct a log item /// </summary> /// <param name="value"></param> /// <param name="color"></param> public LogItem(string value, LogType logType, (bool, bool, ConsoleColor) p)
private void DecrementCount(LogType type) { counts[type] = counts.ContainsKey(type) ? counts[type] - 1 : 0; UpdateCountTexts(); }
internal ClientLoggerEventArgs(LogType logType, string message, Exception exception = null) { LogType = logType; Message = message; Exception = exception; }
public LogOutEventArgs(LogType messclass, string str) { messClass = messclass; mess = str; }
public static T Print <T>(this T t, string pattern = null, bool type = false, LogType logType = LogType.Log) { var str = t?.ToString() ?? "null"; if (pattern != null) { str = pattern.Contains("$") ? pattern.Replace("$", str) : $"{pattern} {str}"; } if (type) { str = $"({t.GetType().Name}) {str}"; } switch (logType) { case LogType.Log: Debug.Log(str); break; case LogType.Error: Debug.LogError(str); break; } return(t); }
/// <summary> /// This static function logs after some time, till log all texts that send will be saved as lines. /// You can set interval to log. /// </summary> /// <param name="type">Type of the log</param> /// <param name="level">Log level of the log</param> /// <param name="text">Text</param> /// <param name="p">This parameter is only used on EventLog type, it gives an id to event</param> public static void LogTimed(LogType type, LogLevel level, string text, params int[] p) { if ((logLevel & (Int32)level) == 0) { return; } switch (type) { case LogType.CONSOLE: { #if !NETFX_CORE if (!timedConsoleLog.ContainsKey(level)) { timedConsoleLog.Add(level, new StringBuilder()); } if (timedConsoleLog[level].ToString() == "") { timerConsole.Start(); if (!timerConsoleAdded) { timerConsole.Tick += new EventHandler(ConsoleTimerLog); timerConsoleAdded = true; } } timedConsoleLog[level].Append(DateTime.Now.ToString() + ":" + level + ":" + "Resto" + ":" + text + "\r\n"); #endif } break; case LogType.EVENTLOG: { } break; case LogType.FILE: { #if !NETFX_CORE if (!timedFileLog.ContainsKey(level)) { timedFileLog.Add(level, new List <FileLogData>()); } if (timedFileLog[level].Count == 0) { timerFileLog.Start(); if (!timerFileLogAdded) { timerFileLog.Tick += new EventHandler(FileTimerLog); timerFileLogAdded = true; } } FileLogData fld = new FileLogData(); fld.level = level; fld.time = DateTime.Now; fld.data = "Resto" + ":" + text; timedFileLog[level].Add(fld); //timedFleLog[level].AppendLine(DateTime.Now.ToString() + ":" + level + ":" + "Resto" + ":" + text); #endif } break; } ; }
internal void Log(string message, LogType type = LogType.Info, [CallerMemberName] string functionName = "") { logging.Log(message, type, functionName); }
/// <summary> /// Similar to <see cref="LogAssert.Expect(LogType, Regex)"/>, but **must** be used instead of that, /// for Responsible to be able to successfully ignore errors. /// See also <seealso cref="UnityErrorLogInterceptor"/>. /// <see cref="LogAssert.ignoreFailingMessages"/> is respected /// </summary> /// <param name="logType">Log type to expect</param> /// <param name="regex">Regular expression to match in the expected message</param> public void ExpectLog(LogType logType, Regex regex) => this.errorLogInterceptor.ExpectLog(logType, regex);
public void TestFileCreation_AddNewBreadcrumbToFile_SuccessfullyAddedBreadcrumb(LogType testedLevel) { var currentTime = DateTimeHelper.TimestampMs(); const string breadcrumbMessage = "foo"; var breadcrumbFile = new InMemoryBreadcrumbFile(); var breadcrumbsStorageManager = new BacktraceStorageLogManager(Application.temporaryCachePath) { BreadcrumbFile = breadcrumbFile }; var breadcrumbsManager = new BacktraceBreadcrumbs(breadcrumbsStorageManager); var unityEngineLogLevel = breadcrumbsManager.ConvertLogTypeToLogLevel(testedLevel); var logTypeThatUnsupportCurrentTestCase = (Enum.GetValues(typeof(UnityEngineLogLevel)) as IEnumerable <UnityEngineLogLevel>) .First(n => n == unityEngineLogLevel); breadcrumbsManager.EnableBreadcrumbs(ManualBreadcrumbsType, logTypeThatUnsupportCurrentTestCase); var added = breadcrumbsManager.Log(breadcrumbMessage, testedLevel); Assert.IsTrue(added); var data = ConvertToBreadcrumbs(breadcrumbFile); Assert.AreEqual(1, data.Count()); var breadcrumb = data.First(); Assert.AreEqual(ManualBreadcrumbsType, (BacktraceBreadcrumbType)breadcrumb.Type); Assert.AreEqual(unityEngineLogLevel, breadcrumb.Level); Assert.AreEqual(breadcrumbMessage, breadcrumb.Message); // round timestamp because timestamp value in the final json will reduce decimal part. Assert.That(Math.Round(currentTime, 0), Is.LessThanOrEqualTo(Math.Round(breadcrumb.Timestamp, 0))); }
public void LogFormat(LogType logType, UnityEngine.Object context, string format, params object[] args) { Debug.unityLogger.logHandler.LogFormat(logType, context, format, args); }
public BackendEventLog(string id, LogType logType, string logMessage) : base(id, EventType.Log) { LogType = logType; LogMessage = logMessage; }
public abstract Logger CreateLogger(LogType logType);