internal static eRetorno DoLog(eConfig config, eLog log) { var retorno = new eRetorno(); switch (config.LogType) { case provider.All: retorno = nSqlLog.DoLog(config, log); return(!retorno.sucesso ? retorno : nTextLog.DoLog(config, log)); case provider.Sql: return(nSqlLog.DoLog(config, log)); case provider.Text: return(nTextLog.DoLog(config, log)); case provider.SqlonErrorText: retorno = nSqlLog.DoLog(config, log); return(!retorno.sucesso ? nTextLog.DoLog(config, log) : retorno); default: retorno.sucesso = false; retorno.mensagem = Error.ProviderNaoInformado; return(retorno); } }
// 유틸 함수 ----------------------------------------------------------- // Log public static string Log(string a_sLog, eLog a_eLogType = eLog.Log, string a_sFileName = Path.sLogFile, [CallerFilePath] string a_sFilePath = "", [CallerLineNumber] int a_nLineNum = 0) { StringBuilder s = new StringBuilder("["); s.Append(DateTime.Now); s.Append("]"); if (a_eLogType == eLog.Error) { s.Append("[Error]["); } s.Append(System.IO.Path.GetFileName(a_sFilePath)); s.Append(" - "); s.Append(a_nLineNum); s.Append("] : "); s.Append(a_sLog); File.Wright(Path.FileName_inMyDocument(Path.eDocumentFile.Log), s.ToString()); return(s.ToString()); }
internal static eRetorno DoLog(eConfig config, eLog log) { var retorno = new eRetorno(); try { var path = Directory.Exists(config.TextFilePath) ? config.TextFilePath : AppDomain.CurrentDomain.BaseDirectory; var searchName = config.TextFileName + DateTime.Now.ToString("yyyyMMdd"); var fileName = ""; var count = 0; foreach (var file in new DirectoryInfo(path).GetFiles().Where(c => c.Name.Contains(searchName)).OrderBy( o => o.CreationTime)) { if ((file.Length) / 1024 < config.TextFileMaxByte - 1) { fileName = file.Name; break; } count++; } if (fileName.Equals("")) { fileName = searchName + ((count > 0 ? "(" + (count) + ")" : "")) + ".log"; } var pathFile = Path.Combine(path, fileName); var writer = new StreamWriter(pathFile, true); writer.WriteLine(string.Format("{0} : Class -> {1} | Method -> {2} | Message -> {3} | Error -> {4}", DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"), log.Classe, log.Metodo, log.Mensagem, log.Message)); writer.Close(); retorno.sucesso = true; } catch (Exception ex) { retorno.sucesso = false; retorno.mensagem = ex.Message; } return(retorno); }
public static eRetorno LogMe(erro level, Exception exception = null, Type objType = null, string mensagem = null) { var log = new eLog { Level = (int)level, Classe = (objType == null) ? null : objType.FullName, Mensagem = mensagem }; if (exception == null) { return(nLog.DoLog(_config, log)); } log.Stack = exception.StackTrace; log.Message = exception.Message; log.Metodo = exception.TargetSite.Name; return(nLog.DoLog(_config, log)); }
protected override void DrawButton(int id, Rect rect) { base.DrawButton(id, rect); if (GUI.Button(new Rect(mRect.x - 72, mRect.y + 36 * 1, 72, 36), "Log")) { mLogType = eLog.LOG; } if (GUI.Button(new Rect(mRect.x - 72, mRect.y + 36 * 2, 72, 36), "Warning")) { mLogType = eLog.WARNING; } if (GUI.Button(new Rect(mRect.x - 72, mRect.y + 36 * 3, 72, 36), "Error")) { mLogType = eLog.ERROR; } if (GUI.Button(new Rect(mRect.x - 72, mRect.y + 36 * 4, 72, 36), "Exception")) { mLogType = eLog.EXCEPTION; } if (GUI.Button(new Rect(mRect.x - 72, mRect.y + 36 * 5, 72, 36), "↑")) { AddLine(); } if (GUI.Button(new Rect(mRect.x - 72, mRect.y + 36 * 6, 72, 36), "↓")) { DelLine(); } if (GUI.Button(new Rect(mRect.x - 72, mRect.y + 36 * 7, 72, 36), "Clear")) { Clear(); } }
internal eRetorno GravaLog(eConfig config, eLog log) { var retorno = new eRetorno() { sucesso = true }; try { var sqlComm = new SqlCommand { CommandType = CommandType.StoredProcedure, CommandText = "USP_01_INSERT_BUSTED" }; var logInfo = log.GetType().GetProperties(); foreach (var propertyInfo in logInfo.Where(propertyInfo => propertyInfo.GetValue(log) != null)) { sqlComm.Parameters.Add(new tratamentoDados().tratarParamentros(log, propertyInfo)); } using (var conexao = new connection(config, out retorno)) if (retorno.sucesso) { ValidarDataBase(conexao, out retorno); if (retorno.sucesso) { retorno = conexao.ExecuteNonQuery(sqlComm); } } } catch (Exception ex) { retorno.sucesso = false; retorno.mensagem = ex.Message; } return(retorno); }
internal static eRetorno DoLog(eConfig config, eLog log) { return(new dLog().GravaLog(config, log)); }