本文整理汇总了C#中Verbosity.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Verbosity.ToString方法的具体用法?C# Verbosity.ToString怎么用?C# Verbosity.ToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Verbosity
的用法示例。
在下文中一共展示了Verbosity.ToString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Log
public static void Log(Verbosity verbosity,string format, params object[] arg0)
{
if ((int)verbosity >= (int)CurrentVerbosity)
{
Console.WriteLine(String.Format("{0}: ", verbosity.ToString()) + format, arg0);
}
}
示例2: Log
public static void Log(string message, Verbosity verbosity)
{
if (!_inUse)
{
var directory = AppDomain.CurrentDomain.BaseDirectory + @"\Logs";
if (!Directory.Exists(directory))
{
Directory.CreateDirectory(directory);
}
else
{
var files = Directory.GetFileSystemEntries(directory).ToList();
if (files.Count != 0)
{
var obtainedfile = files.LastOrDefault(
x => x.Contains("Log_" + DateTime.Now.Year + "_" + DateTime.Now.Month + "_" + DateTime.Now.Day + "_"));
if (!(String.IsNullOrEmpty(obtainedfile) || String.IsNullOrWhiteSpace(obtainedfile)))
{
_logFileNumber =
Convert.ToInt32(obtainedfile.Substring(obtainedfile.LastIndexOf("_", StringComparison.Ordinal) + 1,
obtainedfile.IndexOf(".txt", StringComparison.Ordinal) - (obtainedfile.LastIndexOf("_", StringComparison.Ordinal) + 1)));
_logFileNumber++;
}
}
}
_inUse = true;
using (var file = new StreamWriter(@".\Logs\Log_" + DateTime.Now.Year + "_" + DateTime.Now.Month + "_" + DateTime.Now.Day + "_" + _logFileNumber + ".txt"))
{
Console.WriteLine(verbosity.ToString("G").ToUpperInvariant() + ": " + DateTime.Now + ": "+ message);
file.WriteLine(verbosity.ToString("G").ToUpperInvariant() + ": " + DateTime.Now + ": " + message);
}
}
else
{
using (var file = File.AppendText(@".\Logs\Log_" + DateTime.Now.Year + "_" + DateTime.Now.Month + "_" + DateTime.Now.Day + "_" + _logFileNumber + ".txt"))
{
Console.WriteLine(verbosity.ToString("G").ToUpperInvariant() + ": " + DateTime.Now + ": " + message);
file.WriteLine(verbosity.ToString("G").ToUpperInvariant() + ": " + DateTime.Now + ": " + message);
}
}
}
示例3: ToString
/** ****************************************************************************************
* Writes a string representation of the \e Verbosity and priority into the given
* AString.
*
* @param verbosity The enum value to retrieve a string representation for.
* @param priority The priority of the \p verbosity setting.
* @param target The target to write into.
* @returns \p target to allow concatenated calls.
******************************************************************************************/
public static AString ToString( Verbosity verbosity, int priority, AString target )
{
target.Field()._( verbosity.ToString() ).Field( 8, Alignment.Left)
._( '(' );
return ToStringPriority( priority, target )
.InsertAt( ")", target.LastIndexOfAny( CString.DefaultWhitespaces, Inclusion.Exclude ) + 1 );
}
示例4: Write
private static void Write(Verbosity level, string format, params object[] args)
{
if (level > Verbosity)
return;
string msg = string.Format("{0}, {1,-8}:", DateTime.Now.ToLongTimeString(), level.ToString());
if (args != null && args.Length > 0)
msg += string.Format(format, args);
else
msg += format;
foreach (ILogger i in subscribers)
i.Write(msg);
}
示例5: Write
public void Write(LogScope scope, Verbosity verbosity, string source, string text)
{
DateTime dt = DateTime.Now;
string span = "";
if(scope != null)
span = (dt - scope.CreateDateTime).ToString();
TreeIter iter = AppendValues(FindParentIter(scope), dt, (int)verbosity, verbosity.ToString(), text, source, span);
TreePath path = store.GetPath(iter);
view.ExpandToPath(path);
view.ScrollToCell(path, view.Columns[1], false, 0.0f, 0.0f);
}