public static DataTable getDataTable(string sql) { LogMode l = new LogMode(sql); DataTable dt = new DataTable(); OleDbDataAdapter da = new OleDbDataAdapter(); try { conn = DbUtil.getConn(); conn.Open(); cmd = new OleDbCommand(sql, conn); da.SelectCommand = cmd; da.Fill(dt); Const.info = "查询表"; l.act = "ok\t" + l.act; } catch (Exception e) { Const.info = e.Message; l.act = "fail:" + e.Message + "\t" + l.act; } finally { if (conn != null) { conn.Close(); } } insertLogMode(l); return dt; }
public static int exeSql(string sql) { LogMode l = new LogMode(sql); int i = -1; try { conn = DbUtil.getConn(); conn.Open(); cmd = new OleDbCommand(sql, conn); i = cmd.ExecuteNonQuery(); Const.info = "修改:" + i; l.act = "ok\t" + l.act; } catch (Exception e) { Const.info = e.Message; l.act = "fail:" + e.Message + "\t" + l.act; } finally { if (conn != null) { conn.Close(); } } insertLogMode(l); return i; }
private static void Out(string message, LogMode logMode = LogMode.Info) { if(mode != Configuration.eMode.Development) { return; } message.Insert(0, "[" + logMode.ToString() + "] "); switch(logMode) { default: case LogMode.Info: Debug.Log(message); break; case LogMode.Warning: Debug.LogWarning(message); break; case LogMode.Error: Debug.LogError(message); break; case LogMode.Fatal: #if UNITY_EDITOR EditorApplication.isPaused = true; #endif throw new Exception(message); } }
public Stopper(JStopWatch owner, string format, LogMode logMode, string endFormat, params object[] args) { _owner = owner; this.Format = format; this.LogMode = logMode; this.EndMsg = string.Format(endFormat, args); _startTime = DateTime.Now; }
public IDisposable Start(LogMode logMode, string startFormat, string endFormat, params object[] args) { if (!string.IsNullOrWhiteSpace(startFormat)) { JLog.Default.Write(logMode, startFormat, args); } Stopper stopper = new Stopper(this, Format, logMode, endFormat, args); return stopper; }
public bool IsLoggingEnbaled(int bucket, LogMode logMode) { if (_loggers.Contains(bucket)) { OperationLogger logger = _loggers[bucket] as OperationLogger; return logger.LoggingMode == logMode; } return false; }
public static void Log(object key, string message, LogMode mode, StaticLog type) { int logMode = 5; if (mode <= (LogMode)logMode) { string message2 = string.Format("{0} - {1}", key, message); string message3 = EngineLogger.AppendTraces(message2); ILog log = EngineLogger.loggers[type]; log.Info(message3); } }
public void StartLogging(int bucket, LogMode loggingMode) { if (!_loggers.Contains(bucket)) { _loggers.Add(bucket, new OperationLogger(bucket, loggingMode)); } else { OperationLogger logger = _loggers[bucket] as OperationLogger; logger.LoggingMode = loggingMode; logger.BucketTransfered = false; logger.Clear(); } }
public void Write(LogMode logMode, Exception ex) { if ((LogMode.Fatal & logMode) == LogMode.Fatal && Instance.IsFatalEnabled) Instance.Fatal(ex.ToString()); if ((LogMode.Error & logMode) == LogMode.Error && Instance.IsErrorEnabled) Instance.Error(ex); if ((LogMode.Warn & logMode) == LogMode.Warn && Instance.IsWarnEnabled) Instance.Warn(ex.ToString()); if ((LogMode.Info & logMode) == LogMode.Info && Instance.IsInfoEnabled) Instance.Info(ex.ToString()); if ((LogMode.Debug & logMode) == LogMode.Debug && Instance.IsDebugEnabled) Instance.Debug(ex.ToString()); }
/// <summary> /// Metodo que permite escribir un log en el Log viewer o en un archivo dependiendo del /// parametro /// </summary> /// <param name="pMessage">Mensaje del log.-</param> /// <param name="pFileName">Nombre del archivo donde se guarda el Log si modalidad log es <remarks "LogMode.File"</param> /// <param name="pSource">El origen por el cual la qplicacion es registrada </param> /// <param name="pLogMode">Si es "EventViewer" genera un registro en Event Viewer /// Si es "FileLog" genera una linea en un archivo de log</param> /// <param name="pEventLogEntryType">Espesifica el tipo de log, puede ser : /// Error , Warning, Information, SuccessAudit etc. /// </param> public static void WriteLog(string pMessage, string pFileName, string pSource, LogMode pLogMode, EventLogEntryType pEventLogEntryType) { if (pLogMode == LogMode.EventViewer) { EventLog.WriteEntry(pSource, pMessage, pEventLogEntryType); } if (pLogMode == LogMode.File) { StringBuilder wFileText = new StringBuilder (); wFileText.Append(Environment.NewLine); wFileText.Append("--------------------------------" + "[" + pSource + "]" + "------------------------------------------------------------------"); wFileText.Append(Environment.NewLine); wFileText.Append(DateTime.Now.ToString() + " Host: " + Environment.MachineName); wFileText.Append(Environment.NewLine); wFileText.Append(pMessage); wFileText.Append(Environment.NewLine); FileFunctions.SaveTextFile(pFileName, wFileText.ToString(), true); } }
/// <summary> /// Initialise an instance of the core logger /// </summary> /// <param name="logMode">The log mode to use</param> /// <param name="logFileLocationName">The log file location and name, i.e. logs/logFile.txt</param> public LiteLogger(LogMode logMode, string logFileLocationName) { _currentLogMode = logMode; LogFileLocationName = logFileLocationName; }
public void setLogMode(LogMode lm) { m_logMode = lm; }
private void OnDebug(LogMode mode, string msg) { OnDebug(mode, "DecMsgHelper", msg); }
private void OnDebug(LogMode mode, string msg) { OnDebug(mode, "Service03Helper", msg); }
/// <summary> /// Initializes a new instance of the <see cref="LogUtility"/> class. /// </summary> /// <param name="productName">Name of the product.</param> /// <param name="outputFolder">The output folder. Pass empty string or null to log to executable directory</param> /// <param name="extension">The extension for the log file - leading dot is optional (e.g 'log', '.errors' or '.trc'). /// Pass empty string or null for default extension</param> /// <param name="maxSize">The maximum size of the log file</param> /// <param name="level">The MINIMUM level of logging to be included in the output.</param> /// <param name="mode">The log writing mode.</param> /// <exception cref="ArgumentNullException">Thrown if the product name is null or empty</exception> /// <exception cref="PathTooLongException">Thrown if the log file path will exceed the maximum path length</exception> private LogUtility(string productName, string outputFolder, string extension, int maxSize, LogLevel level, LogMode mode) { _logLines = new Dictionary<MessageType, List<MessageLog>>(); Level = level; Mode = mode; MaxLogSize = maxSize; VetProductName(productName); VetOutputFolder(outputFolder); VetExtension(extension); EnsureUsablePath(); Reset(); }
public virtual void OnAddString(string person, string text, LogMode mode) { }
public static async Task FramesToGifConcat(string framesFile, string outPath, float fps, bool palette, int colors = 64, float resampleFps = -1, LogMode logMode = LogMode.OnlyLastLine) { if (logMode != LogMode.Hidden) { Logger.Log((resampleFps <= 0) ? $"Encoding GIF..." : $"Encoding GIF resampled to {resampleFps.ToString().Replace(",", ".")} FPS..."); } string vfrFilename = Path.GetFileName(framesFile); string paletteFilter = palette ? $"-vf \"split[s0][s1];[s0]palettegen={colors}[p];[s1][p]paletteuse=dither=floyd_steinberg\"" : ""; string fpsFilter = (resampleFps <= 0) ? "" : $"fps=fps={resampleFps.ToStringDot()}"; string vf = FormatUtils.ConcatStrings(new string[] { paletteFilter, fpsFilter }); string rate = fps.ToStringDot(); string args = $"-f concat -r {rate} -i {vfrFilename.Wrap()} -f gif {vf} {outPath.Wrap()}"; await RunFfmpeg(args, framesFile.GetParentDir(), LogMode.OnlyLastLine, "error", TaskType.Encode); }
static void UpdateMetaData(LogMode logMode) { SceneMetaDataBank dataAsset = AssetDatabaseX.LoadOrCreateScriptableObjectAsset <SceneMetaDataBank>(ASSET_PATH); if (dataAsset == null) { Debug.LogWarning($"Could not update SceneMetaDataBank. None found at [{ASSET_PATH}]"); return; } List <SceneMetaDataBank.SceneMetaData> oldData = dataAsset.SceneMetaDatasInternal; List <SceneMetaDataBank.SceneMetaData> newData = new List <SceneMetaDataBank.SceneMetaData>(); int buildIndex = 0; foreach (EditorBuildSettingsScene scene in EditorBuildSettings.scenes) { SceneMetaDataBank.SceneMetaData metaData = new SceneMetaDataBank.SceneMetaData(); metaData.AssetGuid = scene.guid.ToString(); metaData.Path = scene.path; metaData.Name = Path.GetFileNameWithoutExtension(scene.path); metaData.BuildIndex = buildIndex; newData.Add(metaData); buildIndex++; } dataAsset.SceneMetaDatasInternal = newData; // fbessette this diff algo could be optimized if (logMode == LogMode.Full || logMode == LogMode.ChangesOnly) { if (oldData != null) { for (int i = 0; i < oldData.Count; i++) { if (newData.FindIndex((x) => x.AssetGuid == oldData[i].AssetGuid) == -1) { DebugEditor.LogAssetIntegrity($"<color=red>Removed scene meta-data:</color> {oldData[i].Name}"); } } for (int i = 0; i < newData.Count; i++) { int oldDataIndex = oldData.FindIndex((x) => x.AssetGuid == newData[i].AssetGuid); if (oldDataIndex == -1) { DebugEditor.LogAssetIntegrity($"<color=green>Added scene meta-data:</color> {newData[i].Name}"); } else if (oldData[oldDataIndex].ContentEquals(newData[i]) == false) { DebugEditor.LogAssetIntegrity($"<color=green>Updated scene meta-data:</color> {newData[i].Name}"); } } } else { for (int i = 0; i < newData.Count; i++) { DebugEditor.LogAssetIntegrity($"<color=green>Added scene meta-data:</color> {newData[i].Name}"); } } } if (logMode == LogMode.Full) { DebugEditor.LogAssetIntegrity("Scene meta-data bank updated"); } EditorUtility.SetDirty(dataAsset); AssetDatabase.SaveAssets(); }
/// <summary> /// Creates a Log instance that logs All LogLevel messages to the memory. /// </summary> public Log() { mLogMode = Utils.LogMode.All; mLogDestination = LogDestination.Memory; }
public static void Log(LogMode mode, string message, Exception ex, string process = "", object data = null) { // Check for an active log channel if (LogChannel == null) { throw new ArgumentNullException("No active log channel! Please enter a valid channel name in to the system configuration table!"); } // Check the log level if (mode < Mode) { return; } // Create the log entry LogRecord logRecord = new LogRecord { LogID = GetNextId().ToString(), Process = process, Host = Environment.MachineName, Level = mode.ToString(), Message = message, Exception = ex, ExceptionString = ex == null ? string.Empty : ex.ToString(), Data = data, DataString = data == null ? string.Empty : JsonConvert.SerializeObject(data), Created = DateTime.UtcNow, TimeStamp = DateTime.UtcNow }; #if NET452 // Set the app key and environment logRecord.AppKey = ConfigurationManager.AppSettings["AppKey"]; logRecord.Environment = ConfigurationManager.AppSettings["Environment"]; // Try to get the host ip try { if (HttpContext.Current != null && HttpContext.Current.Request != null && !string.IsNullOrEmpty(HttpContext.Current.Request.UserHostAddress)) { // Set the host ip logRecord.HostIP = HttpContext.Current.Request.ServerVariables["LOCAL_ADDR"]; } } catch { } #elif NETCOREAPP2_2 // Set the app key and environment logRecord.AppKey = _configuration.GetValue <string>("AppKey"); logRecord.Environment = _configuration.GetValue <string>("Environment"); // Try to get the host ip try { if (_httpContextAccessor.HttpContext != null && _httpContextAccessor.HttpContext.Request != null && !string.IsNullOrEmpty(_httpContextAccessor.HttpContext.Connection.RemoteIpAddress.ToString())) { // Set the host ip logRecord.HostIP = _httpContextAccessor.HttpContext.Connection.LocalIpAddress.ToString(); } } catch { } #endif // Log with the default channel LogChannel.Log(logRecord); }
/// <summary> /// 写入日志 /// </summary> /// <param name="mode">日志模式</param> /// <param name="category">分类</param> /// <param name="msg">消息内容</param> /// <returns></returns> public OperationReturn WriteLog(LogMode mode, string category, string msg) { OperationReturn optReturn = new OperationReturn(); optReturn.Result = true; optReturn.Code = Defines.RET_SUCCESS; try { if ((mode & mLogMode) == 0) { return(optReturn); } DateTime now = DateTime.Now; FileInfo fileInfo = new FileInfo(mLogFile); if (mLastDate.Date != now.Date || mLogWriter == null || (File.Exists(mLogFile) && fileInfo.Length > mLogFileSize * 1024)) { optReturn = Start(); if (!optReturn.Result) { return(optReturn); } } int index = msg.IndexOf("\r\n", StringComparison.Ordinal); string strThis = msg; string strOther = string.Empty; if (index > 0) { strThis = msg.Substring(0, index); strOther = msg.Substring(index + 2); } string formatstr = string.Format("{0,-8} |{1,-15} |({2})| {3,-20} {4}" , mode , DateTime.Now.ToString("HH:mm:ss.fff") , Thread.CurrentThread.ManagedThreadId.ToString("00000") , category , strThis); lock (mLogWriterLocker) { if (mLogWriter != null) { mLogWriter.WriteLine(formatstr); mLogWriter.Flush(); } else { optReturn.Result = false; optReturn.Code = Defines.RET_OBJECT_NULL; optReturn.Message = "LogWriter is null"; return(optReturn); } } if (!string.IsNullOrEmpty(strOther)) { WriteLog(mode, category, strOther); } } catch (Exception ex) { optReturn.Code = Defines.RET_FAIL; optReturn.Message = ex.Message; optReturn.Exception = ex; } return(optReturn); }
public static void Setup(ILogChannel channel, LogMode mode) { _activeChannel = channel; _logMode = mode; }
static void ConfigurationChanged(Models.Events.ConfigurationEventArgs args) { // Empty the default values _activeChannel = null; _logMode = LogMode.Error; }
public static void WriteLog(LogMode mode, string text) { //LogWritter.CreateDirectory(); //string fileName; //switch (mode) //{ // case LogMode.Search: // fileName = $@"{DirectoryName}\{DateTime.Now.ToString("yyyy-MM-dd")}\{DateTime.Now.ToString("HH")}_search.log"; // using (StreamWriter writer = new StreamWriter(fileName, true)) // { // writer.WriteLine(DateTime.Now + " : " + text); // } // break; // case LogMode.Gps: // fileName = $@"{DirectoryName}\{DateTime.Now.ToString("yyyy-MM-dd")}\{DateTime.Now.ToString("HH")}_gps.log"; // using (StreamWriter writer = new StreamWriter(fileName, true)) // { // writer.WriteLine(DateTime.Now + " : " + text); // } // break; // case LogMode.Acc: // fileName = $@"{DirectoryName}\{DateTime.Now.ToString("yyyy-MM-dd")}\{DateTime.Now.ToString("HH")}_acc.log"; // using (StreamWriter writer = new StreamWriter(fileName, true)) // { // writer.WriteLine(DateTime.Now + " : " + text); // } // break; // case LogMode.Trip: // fileName = $@"{DirectoryName}\{DateTime.Now.ToString("yyyy-MM-dd")}\{DateTime.Now.ToString("HH")}_trip.log"; // using (StreamWriter writer = new StreamWriter(fileName, true)) // { // writer.WriteLine(DateTime.Now + " : " + text); // } // break; // case LogMode.Ecolog: // fileName = $@"{DirectoryName}\{DateTime.Now.ToString("yyyy-MM-dd")}\{DateTime.Now.ToString("HH")}_ecolog.log"; // using (StreamWriter writer = new StreamWriter(fileName, true)) // { // writer.WriteLine(DateTime.Now + " : " + text); // } // break; // case LogMode.Error: // fileName = $@"{DirectoryName}\{DateTime.Now.ToString("yyyy-MM-dd")}\{DateTime.Now.ToString("HH")}_error.log"; // using (StreamWriter writer = new StreamWriter(fileName, true)) // { // writer.WriteLine(DateTime.Now + " : " + text); // } // break; // case LogMode.Elapsedtime: // fileName = $@"{DirectoryName}\{DateTime.Now.ToString("yyyy-MM-dd")}\{DateTime.Now.ToString("HH")}_elapsedtime.log"; // using (StreamWriter writer = new StreamWriter(fileName, true)) // { // writer.WriteLine(DateTime.Now + " : " + text); // } // break; // default: // break; //} }
public void Write(LogMode logMode, string messageFormat, params object[] args) { string message = args == null || args.Count() < 1 ? messageFormat : string.Format(messageFormat, args); if ((LogMode.Fatal & logMode) == LogMode.Fatal && Instance.IsFatalEnabled) Instance.Fatal(message); if ((LogMode.Error & logMode) == LogMode.Error && Instance.IsErrorEnabled) Instance.Error(message); if ((LogMode.Warn & logMode) == LogMode.Warn && Instance.IsWarnEnabled) Instance.Warn(message); if ((LogMode.Info & logMode) == LogMode.Info && Instance.IsInfoEnabled) Instance.Info(message); if ((LogMode.Debug & logMode) == LogMode.Debug && Instance.IsDebugEnabled) Instance.Debug(message); }
/// <summary> /// Ändert den Logmodus /// </summary> /// <param name="logmode"></param> public static void ChangeLogMode(LogMode logmode) { if(LogMode==logmode) return; if(LogMode==LogMode.File) { logFileStream.Close(); } if(logmode==LogMode.File) { logFileStream=new StreamWriter(LogFile); } LogMode=logmode; }
private void WriteLog(LogMode mode, string msg) { WriteLog(mode, "SyncService", msg); }
public NiceLogger(LogMode mode) { Mode = mode; WType = WindowType.None; OpenLogFile(); }
/// <summary> /// Creates a Log instance that logs the wanted LogLevel messages immediately to a file. /// </summary> /// <param name="path">Full path to the file to write the log messages to.</param> /// <param name="logMode">The LogMode.</param> public Log(string path, LogMode logMode = LogMode.All) { if (string.IsNullOrEmpty(path)) throw new ArgumentNullException("path"); CreateLogFile(path); mPath = path; mLogMode = logMode; mLogDestination = LogDestination.File; }
void SyncServer_Debug(LogMode mode, string category, string msg) { WriteLog(mode, category, msg); }
private static ILog LogFactory(LogMode mode) { ILog logger = null; switch (mode) { case LogMode.Nlog: { logger = new JFramework.NLog(); } break; case LogMode.SILog: { logger = new JFramework.SILog(); } break; default: throw new Exception("unknown LogMode"); } return logger; }
public static void Write(string text, LogMode logMode) => Write(text, logMode, null);
private void OnDebug(LogMode mode, string msg) { OnDebug(mode, "ConfigChangeOpt", msg); }
public static async Task RunFfmpeg(string args, LogMode logMode, TaskType taskType = TaskType.Other, bool progressBar = false) { await RunFfmpeg(args, "", logMode, taskType, progressBar); }
/// <summary> /// Creates a Log instance that logs the wanted LogLevel messages to the memory. /// </summary> public Log(LogMode logMode) { mLogMode = logMode; mLogDestination = LogDestination.Memory; }
private void Stop(LogMode logMode, string endMsg, params object[] args) { JLog.Default.Write(logMode, endMsg, args); }
private string CreateLogMessageFromException(Exception exception, Document currentDocument, LogMode logMode, string reportedFrom) { StringBuilder messageBuilder = new StringBuilder(capacity: 256); if (logMode == LogMode.Error) { messageBuilder.AppendLine($"{AcuminatorVSPackage.PackageName.ToUpper()} CAUSED CRITICAL ERROR|"); } messageBuilder.AppendLine($"EXCEPTION TYPE: {exception.GetType().Name}") .AppendLine($"|FILE PATH: {currentDocument.FilePath}") .AppendLine($"|MESSAGE: {exception.Message}") .AppendLine($"|STACK TRACE: {exception.StackTrace}") .AppendLine($"|TARGET SITE: {exception.TargetSite}") .AppendLine($"|SOURCE: {exception.Source}") .AppendLine($"|REPORTED FROM: {reportedFrom}"); return(messageBuilder.ToString()); }
//action public void Log(Agent pAgent, string btMsg, EActionResult actionResult, LogMode mode) { #if !BEHAVIAC_RELEASE if (Config.IsLoggingOrSocketing) { //BEHAVIAC_PROFILE("LogManager.Instance.LogAction"); if (!System.Object.ReferenceEquals(pAgent, null) && pAgent.IsMasked()) { if (!string.IsNullOrEmpty(btMsg)) { string agentClassName = pAgent.GetClassTypeName(); agentClassName = agentClassName.Replace(".", "::"); string agentName = agentClassName; agentName += "#"; agentName += pAgent.GetName(); string actionResultStr = ""; if (actionResult == EActionResult.EAR_success) { actionResultStr = "success"; } else if (actionResult == EActionResult.EAR_failure) { actionResultStr = "failure"; } else if (actionResult == EActionResult.EAR_all) { actionResultStr = "all"; } else { //although actionResult can be EAR_none or EAR_all, but, as this is the real result of an action //it can only be success or failure //when it is EAR_none, it is for update if (actionResult == behaviac.EActionResult.EAR_none && mode == behaviac.LogMode.ELM_tick) { actionResultStr = "running"; } else { actionResultStr = "none"; } } if (mode == LogMode.ELM_continue) { //[continue]Ship.Ship_1 ships\suicide.xml.BehaviorTreeTask[0]:enter [all/success/failure] [1] int count = Workspace.Instance.GetActionCount(btMsg); Debug.Check(count > 0); string buffer = string.Format("[continue]{0} {1} [{2}] [{3}]\n", agentName, btMsg, actionResultStr, count); Output(pAgent, buffer); } else if (mode == LogMode.ELM_breaked) { //[breaked]Ship.Ship_1 ships\suicide.xml.BehaviorTreeTask[0]:enter [all/success/failure] [1] int count = Workspace.Instance.GetActionCount(btMsg); Debug.Check(count > 0); string buffer = string.Format("[breaked]{0} {1} [{2}] [{3}]\n", agentName, btMsg, actionResultStr, count); Output(pAgent, buffer); } else if (mode == LogMode.ELM_tick) { //[tick]Ship.Ship_1 ships\suicide.xml.BehaviorTreeTask[0]:enter [all/success/failure] [1] //[tick]Ship.Ship_1 ships\suicide.xml.BehaviorTreeTask[0]:update [1] //[tick]Ship.Ship_1 ships\suicide.xml.Selector[1]:enter [all/success/failure] [1] //[tick]Ship.Ship_1 ships\suicide.xml.Selector[1]:update [1] int count = Workspace.Instance.UpdateActionCount(btMsg); string buffer = string.Format("[tick]{0} {1} [{2}] [{3}]\n", agentName, btMsg, actionResultStr, count); Output(pAgent, buffer); } else if (mode == LogMode.ELM_jump) { string buffer = string.Format("[jump]{0} {1}\n", agentName, btMsg); Output(pAgent, buffer); } else if (mode == LogMode.ELM_return) { string buffer = string.Format("[return]{0} {1}\n", agentName, btMsg); Output(pAgent, buffer); } else { Debug.Check(false); } } } } #endif }
public void LogException(Exception exception, bool logOnlyFromAcuminatorAssemblies, LogMode logMode, [CallerMemberName] string reportedFrom = null) { if (exception == null || logMode == LogMode.None) { return; } else if (logOnlyFromAcuminatorAssemblies && exception.Source != AnalyzersDll && exception.Source != UtilitiesDll && exception.Source != VsixDll) { return; } IWpfTextView activeTextView = ThreadHelper.JoinableTaskFactory.Run(() => _package.GetWpfTextViewAsync()); if (activeTextView == null) { return; } Document currentDocument = activeTextView.TextSnapshot.GetOpenDocumentInCurrentContextWithChanges(); if (currentDocument == null) { return; } string logMessage = CreateLogMessageFromException(exception, currentDocument, logMode, reportedFrom); switch (logMode) { case LogMode.Information: ActivityLog.TryLogInformation(AcuminatorVSPackage.PackageName, logMessage); break; case LogMode.Warning: ActivityLog.TryLogWarning(AcuminatorVSPackage.PackageName, logMessage); break; case LogMode.Error: ActivityLog.TryLogError(AcuminatorVSPackage.PackageName, logMessage); break; } }
/// <summary> /// Initialise an instance of the core logger. If logging to a file also set LogFileLocationName. /// </summary> /// <param name="logMode">The log mode to use</param> public LiteLogger(LogMode logMode) { _currentLogMode = logMode; }
public override void OnAddString(string person, string text, LogMode mode) { StringAdding?.Invoke(person, text, mode); }
// transfered to MyDownloader.Core\Core\Log.cs //public enum LogMode //{ // Error, // Information //} public void Log(Downloader downloader, string msg, LogMode m) { try { this.BeginInvoke( (MethodInvoker) delegate() { int len = richLog.Text.Length; if (len > 0) { richLog.SelectionStart = len; } if (m == LogMode.Error) { richLog.SelectionColor = Color.Red; } else { richLog.SelectionColor = Color.Blue; } richLog.AppendText(DateTime.Now + " - " + msg + Environment.NewLine); } ); } catch { } }
public static MvcHtmlString GetLogModeDesc(this HtmlHelper helper, LogMode type) { return(new MvcHtmlString(Utils.Utils.GetEnumDescription(type))); }
public void Write(LogMode logMode, long elapsedMilliseconds, bool showSecondFormat, string messageFormat, params object[] args) { string message = args == null || args.Count() < 1 ? messageFormat : string.Format(messageFormat, args); if (showSecondFormat) { message += string.Format(" 耗时:{0}毫秒", elapsedMilliseconds); } else { message += string.Format(" 耗时:{0}秒", elapsedMilliseconds / 1000); } if ((LogMode.Fatal & logMode) == LogMode.Fatal && Instance.IsFatalEnabled) Instance.Fatal(message); if ((LogMode.Error & logMode) == LogMode.Error && Instance.IsErrorEnabled) Instance.Error(message); if ((LogMode.Warn & logMode) == LogMode.Warn && Instance.IsWarnEnabled) Instance.Warn(message); if ((LogMode.Info & logMode) == LogMode.Info && Instance.IsInfoEnabled) Instance.Info(message); if ((LogMode.Debug & logMode) == LogMode.Debug && Instance.IsDebugEnabled) Instance.Debug(message); }
private void LogWrite(string msg, LogMode mode) { downloadList1.Log(null, msg, mode); }
public void Write(LogMode logMode, Exception ex, string messageFormat, params object[] args) { string exMessage = ex.InnerException != null ? ex.InnerException.ToString() : ex.ToString(); string msg = args == null || args.Count() < 1 ? messageFormat : string.Format(messageFormat, args); Write(logMode, msg + string.Format("\r\n异常信息:{0}", exMessage)); }
public static async Task FramesToVideoConcat(string framesFile, string outPath, Interpolate.OutMode outMode, float fps, LogMode logMode = LogMode.OnlyLastLine, bool isChunk = false) { await FramesToVideoConcat(framesFile, outPath, outMode, fps, 0, logMode, isChunk); }
//mode public void Log(LogMode mode, string filterString, string format, params object[] args) { #if !BEHAVIAC_RELEASE if (Config.IsLoggingOrSocketing) { //BEHAVIAC_PROFILE("LogManager.Instance.LogMode"); // make result string string buffer = string.Format(format, args); string filterStr = filterString; if (string.IsNullOrEmpty(filterString)) { filterStr = "empty"; } string target = ""; if (mode == LogMode.ELM_tick) { target = string.Format("[applog]{0}:{1}\n", filterStr, buffer); } else if (mode == LogMode.ELM_continue) { target = string.Format("[continue][applog]{0}:{1}\n", filterStr, buffer); } else if (mode == LogMode.ELM_breaked) { //[applog]door opened target = string.Format("[breaked][applog]{0}:{1}\n", filterStr, buffer); } else if (mode == LogMode.ELM_log) { target = string.Format("[log]{0}:{1}\n", filterStr, buffer); } else { Debug.Check(false); } Output(null, target); } #endif }
public static void Log(LogMode mode, string message) { if (Enabled && Mode != LogMode.Disabled && mode <= Mode) Provider.Log(mode, message); }
/// <summary> /// Initializes a new instance of the <see cref="LogUtility"/> class. /// </summary> /// <param name="productName">Name of the product.</param> /// <param name="outputFolder">The output folder. Pass empty string or null to log to executable directory</param> /// <param name="extension">The extension for the log file - leading dot is optional (e.g 'log', '.errors' or '.trc'). /// Pass empty string or null for default extension</param> /// <param name="level">The MINIMUM level of logging to be included in the output.</param> /// <param name="mode">The log writing mode.</param> /// <exception cref="ArgumentNullException">Thrown if the product name is null or empty</exception> /// <exception cref="PathTooLongException">Thrown if the log file path will exceed the maximum path length</exception> public static LogUtility CreateLogger(string productName, string outputFolder, string extension, LogLevel level, LogMode mode) { #region Implementation LogUtility logger = null; lock (_settings) { // Get the location of the executable, set that to our output Directory if (String.IsNullOrEmpty(outputFolder)) { outputFolder = Application.StartupPath; } //default to the custom folder string tempRoot = string.IsNullOrEmpty(outputFolder) ? Environment.CurrentDirectory : outputFolder; tempRoot = Path.Combine(tempRoot, LOG_ROOT); string source = Path.Combine(tempRoot, CustomFolder); Exception settingsError = null; bool noCustomSetting = false; LoggingSettings settings = null; //if there is no folder, use the application folder if (!Directory.Exists(source)) { source = Application.StartupPath; noCustomSetting = true; } string settingsFile = (Path.Combine(source, SETTINGS_FILE)); //load existing settings if (File.Exists(settingsFile)) { try { //update the mode & level from the saved settings settings = LoggingSettings.DeserializeFromFile(settingsFile); if (noCustomSetting) { //if there is no customised setting, overwrite the application //default with the settings requested by the caller settings.LoggingLevel = level; settings.LoggingMode = mode; } else { //if there are customised settings, overwrite the caller's settings //with those from the customised settings file level = settings.LoggingLevel; mode = settings.LoggingMode; } } catch (System.Runtime.Serialization.SerializationException error) { settingsError = error; } } //read in the max log size from the settings file or use the default if not available //int maxSize = settings != null ? settings.MaxLogSize : _maxSize; //create the logger logger = new LogUtility(productName, outputFolder, extension, _maxSize, level, mode); //if settings was found but could not be loaded, inform user if (settingsError != null) { logger.AddException(string.Format("Error reading logging settings from {0}", source), settingsError); } //save the current settings for the user source = Path.Combine(tempRoot, CustomFolder); //only write the settings if the user had permissions to create a custom folder if (Directory.Exists(source) && (settings == null || noCustomSetting)) { settingsFile = (Path.Combine(source, SETTINGS_FILE)); settings = new LoggingSettings { LoggingLevel = level, LoggingMode = mode }; settings.SerializeToFile(settingsFile); } } return logger; #endregion }
public static void Log(Agent pAgent, string btMsg, EActionResult actionResult, LogMode mode) { }
public static async Task FramesToVideoConcat(string framesFile, string outPath, Interpolate.OutMode outMode, float fps, float resampleFps, LogMode logMode = LogMode.OnlyLastLine, bool isChunk = false) { if (logMode != LogMode.Hidden) { Logger.Log((resampleFps <= 0) ? $"Encoding video..." : $"Encoding video resampled to {resampleFps.ToString().Replace(",", ".")} FPS..."); } Directory.CreateDirectory(outPath.GetParentDir()); string encArgs = Utils.GetEncArgs(Utils.GetCodec(outMode)); if (!isChunk) { encArgs += $" -movflags +faststart"; } string vfrFilename = Path.GetFileName(framesFile); string rate = fps.ToString().Replace(",", "."); string vf = (resampleFps <= 0) ? "" : $"-vf fps=fps={resampleFps.ToStringDot()}"; string extraArgs = Config.Get("ffEncArgs"); string args = $"-vsync 0 -f concat -r {rate} -i {vfrFilename} {encArgs} {vf} {extraArgs} -threads {Config.GetInt("ffEncThreads")} {outPath.Wrap()}"; await RunFfmpeg(args, framesFile.GetParentDir(), logMode, "error", TaskType.Encode, !isChunk); }
public static void Write(string msg, LogMode mode, params object[] prm) { if (prm.Length > 0) msg = string.Format(msg, prm); OnLogWrite(msg, mode); }
public static void Log(LogMode mode, string filterString, string format, params object[] args) { }
private static void Log(string text, object[] args, LogMode severity) { LogCall?.Invoke(string.Format(Format(text, severity), args), severity); }