本文整理汇总了C#中LogType.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# LogType.ToString方法的具体用法?C# LogType.ToString怎么用?C# LogType.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LogType
的用法示例。
在下文中一共展示了LogType.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetMessage
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;
}
示例2: Write
public static bool Write(CSSDataContext db, LogType type, string message, bool submit)
{
try
{
db.Logs.InsertOnSubmit(new Log()
{
DateOccurred = DateTime.Now,
Message = message,
Type = (byte)type
});
if (submit)
db.SubmitChanges();
Console.WriteLine(String.Format("{0}: {1} {2}", DateTime.Now, type.ToString(), message));
return true;
}
catch(Exception error)
{
var errorMessage = new StringBuilder()
.AppendLine("Failed to write data to log:")
.Append("Type: ").AppendLine(type.ToString())
.Append("Message: ").AppendLine(message);
Debug.WriteLine(errorMessage);
Error.Write(db, new Exception(errorMessage.ToString(), error), submit);
return false;
}
}
示例3: Init
public void Init(LogType type)
{
MyType = type;
isInit = true;
FILENAME = LOG_FOLDER + "\\" + MyType.ToString() + "_" + BASE_FILENAME;
SPOOLED_FILENAME = MyType.ToString() + "_" + BASE_SPOOLED_FILENAME;
}
示例4: BroadcastLog
private void BroadcastLog(String condition, String stackTrace, LogType type)
{
Send("log", new JObject {
{ "type", type.ToString().ToLower() },
{ "message", condition }
});
}
示例5: Log
public static void Log( string text, string stackTrace, LogType type = LogType.Log )
{
if (!Config.RemoteLoggerEnabled) return;
string t_url = Config.RemoteLoggerURL + "?t=" + type.ToString() + "&p=" + Util.Storage.UrlEncode ( text ) + "&s=" + Util.Storage.UrlEncode ( stackTrace );
Util.Storage.WWWSend ( t_url );
}
示例6: handleLog
private void handleLog(string log, string stackTrace, LogType type)
{
_currentScrollPosition.y = Mathf.Infinity;
if(_currentLog.Count == MAX_LOG)
_currentLog.RemoveAt(0);
_currentLog.Add (new LogMessage(type, string.Format ("[{0}] {1}\n{2}", type.ToString(), log, stackTrace)));
}
示例7: addLog
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();
}
}
}
示例8: HandleLog
private void HandleLog(string log, string stack, LogType type)
{
Dictionary<string, string> dic = new Dictionary<string, string>();
//dic.Add("log", log);
//dic.Add("stack", stack);
dic.Add("type", type.ToString());
dic.Add("playTime", Time.realtimeSinceStartup.ToString());
dic.Add("time", System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fff"));
dic.Add("ProcessorType", SystemInfo.processorType);
dic.Add("ProcessorCount", SystemInfo.processorCount.ToString());
dic.Add("Device-Uid", SystemInfo.deviceUniqueIdentifier);
dic.Add("Device-Model", SystemInfo.deviceModel);
dic.Add("Device-Name", SystemInfo.deviceName);
dic.Add("OS", SystemInfo.operatingSystem);
dic.Add("MemorySize", SystemInfo.systemMemorySize.ToString());
dic.Add("GPU-Memory", SystemInfo.graphicsMemorySize.ToString());
dic.Add("GPU-Name", SystemInfo.graphicsDeviceName);
dic.Add("GPU-Vendor", SystemInfo.graphicsDeviceVendor);
dic.Add("GPU-VendorID", SystemInfo.graphicsDeviceVendorID.ToString());
dic.Add("GPU-id", SystemInfo.graphicsDeviceID.ToString());
dic.Add("GPU-Version", SystemInfo.graphicsDeviceVersion);
dic.Add("GPU-ShaderLevel", SystemInfo.graphicsShaderLevel.ToString());
dic.Add("GPU-PixelFillrate", SystemInfo.graphicsPixelFillrate.ToString());
//ravenClient.CaptureMessage(log, SharpRaven.Data.ErrorLevel.error, dic, null);
ravenClient.CaptureUntiyLog(log, stack, type, dic, null);
}
示例9: Write
/// <summary>
/// Write the message into log file.
/// </summary>
/// <param name="message">message.</param>
/// <param name="type">message's type.</param>
public void Write(string message, LogType type)
{
// check message
if (message == null || message.Equals(""))
throw new ArgumentNullException ("message");
// open file and formate message
StreamWriter writer = new StreamWriter (new FileStream (Name, FileMode.Append));
DateTime time = DateTime.Now;
string frmtMessage = time.ToString ("dd.MM.yy HH:mm:ss.fff") + "\t" + type.ToString () [0] + "\t" + message;
// add message to list and write it into file
Entries.Add (frmtMessage);
// filter debug messages
#if DEBUG
Console.WriteLine (frmtMessage);
writer.WriteLine (frmtMessage);
#else
if (type != LogType.Debug)
writer.WriteLine (frmtMessage);
#endif
// clean up
writer.Close ();
}
示例10: LogError
public static void LogError(string msg , LogType lt , Exception ex)
{
writeMutex.WaitOne();
System.IO.StreamWriter file = new System.IO.StreamWriter(Env.ErrorFolderPath, true);
file.WriteLine(lt.ToString() + ":");
string[] lines = msg.Split('\n');
foreach (var l in lines)
{
file.WriteLine(l);
}
file.WriteLine("_Time :"+ DateTime.Now.ToString(CultureInfo.InvariantCulture));
if(ex != null)
{
var st = new StackTrace(ex, true);
var stackFrames = st.GetFrames();
if (stackFrames != null)
foreach (var frame in stackFrames)
{
file.WriteLine("_Frame : " + frame.ToString());
// Get the line number from the stack frame
var line = frame.GetFileLineNumber();
file.WriteLine("_Line : " + line.ToString());
}
}
file.WriteLine("---------------------------------------------------------END----------------------------------------------------------");
file.Close();
writeMutex.ReleaseMutex();
}
示例11: Write
public static void Write(LogType logType, string message)
{
// Pluralizing main directory name depending on LogType
string logTypeDirectory =
logType.ToString().EndsWith("s")
? logType + "es"
: logType + "s";
string filePath = [email protected]"\"[email protected]"\";
string fileExtension = "log";
string fileName = logType+"_"+DateTime.Now.ToString("dd-MM-yyyy")+"."+fileExtension;
// Format is [yyyy/MM/dd HH:mm:ss]
string dateTime = "["+DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")+"] ";
string dataToAppend = dateTime + NewLine + message + NewLine;
if (!Directory.Exists(filePath))
{
Directory.CreateDirectory(filePath);
}
File.AppendAllText(filePath+"\\"+ fileName, dataToAppend);
}
示例12: LogHandler
void LogHandler(string condition, string stack, LogType type)
{
if (LogEvent != null)
LogEvent(condition, stack, type);
if (logLines == null)
logLines = new List<string>(maxLogLine);
if (logLines.Count >= maxLogLine)
logLines.RemoveAt(0);
string color = "#FFFFFF";
if (type == LogType.Warning)
{
color = "#CCCC00";
}
else if (type == LogType.Error || type == LogType.Exception)
{
color = "#CC0000";
condition += stack;
}
string logText = string.Format("{0} {1} {2}", type.ToString(), DateTime.Now.ToString("HH:mm:ss.ff"), condition);
logLines.Add(string.Format("<color={0}>{1}</color>", color, logText));
hasNewMessage = true;
}
示例13: Log
public static void Log(string message, LogType type = LogType.Message)
{
ConsoleColor color = ConsoleColor.White;
if (type == LogType.DebugVerbose)
if (!DEBUG_VERBOSE) return;
else type = LogType.Debug;
switch (type)
{
case LogType.Message:
color = ConsoleColor.White;
break;
case LogType.Warning:
color = ConsoleColor.Yellow;
break;
case LogType.Error:
color = ConsoleColor.Red;
break;
case LogType.Fatal:
color = ConsoleColor.DarkRed;
break;
case LogType.Debug:
color = ConsoleColor.Cyan;
break;
}
Console.ForegroundColor = color;
Console.Write("[" + type.ToString() + "] ");
Console.ForegroundColor = ConsoleColor.Gray;
Console.WriteLine(message);
}
示例14: log
private static void log(Type callerType, LogType logType, params object[] message)
{
var time = DateTime.Now;
var elapsed = lastLogTime != null ? DateTime.Now - (DateTime)lastLogTime : TimeSpan.Zero;
lastLogTime = time;
string strTime = time.ToString("HH:mm:ss.fff");
string prefix = "[" + logType.ToString().ToUpper() + "] " + elapsed.TotalMilliseconds + " ms ";
string strMessage = String.Join("\t", message);
ConsoleColor previousBackground = Console.BackgroundColor;
ConsoleColor previousForeground = Console.ForegroundColor;
ConsoleColor foregroundColor = colors[logType].Item1;
ConsoleColor backgroundColor = colors[logType].Item2;
if (Console.ForegroundColor != foregroundColor)
Console.ForegroundColor = foregroundColor;
if (Console.BackgroundColor != backgroundColor)
Console.BackgroundColor = backgroundColor;
Console.Write(prefix);
string rightAlignedText = callerType.Name;
Console.Write(" ".Repeat(Console.BufferWidth - Console.CursorLeft - rightAlignedText.Length));
Console.Write(rightAlignedText);
Console.BackgroundColor = previousBackground;
Console.ForegroundColor = previousForeground;
Console.WriteLine(strMessage + "\n");
}
示例15: MyCallBack
void MyCallBack(string logString, string stackTrace, LogType type)
{
output = logString;
stack = stackTrace;
logtype = type.ToString();
}