static void _Log(string message, LOG_TYPE log_type) { var st = new StackTrace(true); var sf = st.GetFrame(2); var fpath = sf.GetFileName(); var fline = sf.GetFileLineNumber(); XCon.Inst.Log(new LogData{message= message, fpath= fpath, fline= fline, log_type= log_type}); }
public static void Trace(LOG_TYPE logType, Int64 groupId, string message, [CallerMemberName] string callerName = null, [CallerFilePath] string callerFilePath = null, [CallerLineNumber] int lineNumber = 0) { var index = (int)logType - (int)LOG_TYPE.START_TRACE; if (EnableTraceTypeIndexList[index] == false) { return; } AddLog(OP_LOG_LEVEL.TRACE, logType, groupId, message, callerName, ShortFilePathName(callerFilePath), lineNumber); }
//파일쓰기 public void Log( string str, LOG_TYPE LogType = LOG_TYPE.NONE ) { //CNetLog.AssertX(null != str, "null != str"); string strMessage; if (LOG_TYPE.NONE == LogType) { WriteLine(str); return; } else if( LOG_TYPE.INFO == LogType ) { strMessage = String.Format("[INFO]{0}", str); } else {//타입이 안정해지면 다 ERROR 타입으로 strMessage = String.Format("[ERROR]{0}", str); } WriteLine(strMessage); }
private void LOG(LOG_TYPE logtype, ConsoleColor? fg_color, string format, params object[] args) { Log log; if (m_DicLogs.TryGetValue((int)logtype, out log)) { string str; if (args.Length > 0) { str = string.Format(format, args); } else { str = format; } log.LOG(str); lock (m_ConsoleLock) { Console.ForegroundColor = null != fg_color ? (ConsoleColor)fg_color : s_default_cc_[(int)logtype]; Console.WriteLine(str); Console.ResetColor(); } } else { throw (new Exception("LOG error!!!!!")); } }
// see System.ConsoleColor for color names public static void Log(LOG_TYPE logtype, ConsoleColor cc, string format, params object[] args) { LogSys.Instance.LOG(logtype, cc, format, args); }
public static void Log(LOG_TYPE logtype, string format, params object[] args) { LogSys.Instance.LOG(logtype, null, format, args); }
public bool MakeActionLog(LOG_TYPE typeLog, string guestId) { string sql = "INSERT INTO [t_log] (logtime, guest_id, log_type) VALUES (getdate(), @guestId, @typeLog);"; SqlParameter[] parms = new SqlParameter[2]; parms[0] = new SqlParameter("guestId", SqlDbType.NVarChar); parms[0].Value = guestId; parms[1] = new SqlParameter("typeLog", SqlDbType.SmallInt); parms[1].Value = (int)typeLog; int iInserted = SqlHelper.ExecuteNonQuery(getSqlConnStr(), CommandType.Text, sql, parms); if (iInserted == 1) return true; else return false; }
/// <summary> /// Writes data to the log file specified in the constructor. /// </summary> /// <param name="logtype">Used from the LOG_TYPE enumeration to determine whether the log is verbose, info, error, etc...</param> /// <param name="message">This is the data that will be written to the log.</param> /// <param name="code_local">Optional. This is the location of the code where the information is being logged.</param> /// <returns>True/False depending on if the write is successful.</returns> public bool WriteLog(LOG_TYPE logtype, string message, [CallerFilePath]string codeName=null, [CallerMemberName]string code_local=null) { string full_path = _path + "\\" + _name; string codefile = codeName.Split('\\').Last(); try { StreamWriter log_writer = new StreamWriter(full_path, true); //Date [LOG_TYPE] Message (Code location) if (logtype == LOG_TYPE.VERBOSE) { Console.WriteLine($"Out>[{logtype}]\t{message}\t({codefile}->{code_local})"); log_writer.WriteLine($"{System.DateTime.Now}[{logtype}]\t{message}\t({codefile}->{code_local})"); } else { log_writer.WriteLine($"{System.DateTime.Now}[{logtype}]\t{message}\t({codefile}->{code_local})"); } log_writer.Close(); return true; } catch (Exception err) { errormsg = "[Log>>WriteLog]: " + err.Message; return false; } }
private RpcLogger(string name = "" ) { this.name = name; _loglevel = LOG_TYPE.DEBUG; _loghandlers = new Dictionary<string, RpcLogHandler>(); }
public RpcLogger setLevel(LOG_TYPE type) { _loglevel = type; return this; }
public RpcLogger print(string msg, LOG_TYPE type) { if (_loglevel > type) { return this; } string typestr = ""; if (type == LOG_TYPE.DEBUG) typestr = "DEBUG"; if (type == LOG_TYPE.INFO) typestr = "INFO"; if (type == LOG_TYPE.WARN) typestr = "WARN"; if (type == LOG_TYPE.ERROR) typestr = "ERROR"; msg = string.Format("{0} {1} {2}", DateTime.UtcNow,typestr,msg); foreach ( KeyValuePair<string,RpcLogHandler> kv in this._loghandlers) { kv.Value.write( msg ); } return this; }
Color getColorFromLogType(LOG_TYPE log_type) { switch (log_type) { case LOG_TYPE.NORMAL : return this.color_normal; case LOG_TYPE.WARNING: return this.color_warning; case LOG_TYPE.ERROR : return this.color_error; default : return Color.white; } }
private void add_log(string log, LOG_TYPE log_type) { FlowDocument doc = this.rtbLog.Document;// new FlowDocument(); Paragraph p = new Paragraph(); // Paragraph 类似于 html 的 P 标签 SolidColorBrush br = new SolidColorBrush(); switch (log_type) { case LOG_TYPE.kNormalInfo: br.Color = Color.FromRgb(0, 0, 0); break; case LOG_TYPE.kWarnning: br.Color = Color.FromRgb(255, 255, 0); break; case LOG_TYPE.kSuccess: br.Color = Color.FromRgb(0, 255, 0); break; case LOG_TYPE.kError: br.Color = Color.FromRgb(255, 0, 0); break; } p.Foreground = br; Run r = new Run(log); // Run 是一个 Inline 的标签 p.Inlines.Add(r); doc.Blocks.Add(p); //this.rtbLog.Document = doc; }
/// <summary> /// 实例化一个采用默认值的日志请求信息类 /// </summary> public LogRequestInformation( ) { LogType = LOG_TYPE.Manager; StartTime = DateTime.Today.AddDays( 0 ); EndTime = DateTime.Today; }