本文整理汇总了C#中Logger.WriteLine方法的典型用法代码示例。如果您正苦于以下问题:C# Logger.WriteLine方法的具体用法?C# Logger.WriteLine怎么用?C# Logger.WriteLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Logger
的用法示例。
在下文中一共展示了Logger.WriteLine方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Job
public Job(Logger logger, string name)
{
_logger = logger;
_handle = UnsafeNativeMethods.CreateJobObject(IntPtr.Zero, name);
if (_handle == IntPtr.Zero)
{
_logger.WriteLine("Cannot create job ({0})", Logger.LastWin32ErrorMessage());
}
else
{
_logger.WriteLine("Job created");
JobObjectBasicLimitInformation info = new JobObjectBasicLimitInformation();
info.LimitFlags = 0x2000; // JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE
JobObjectExtendedLimitInformation extendedInfo = new JobObjectExtendedLimitInformation();
extendedInfo.BasicLimitInformation = info;
int length = Marshal.SizeOf(typeof(JobObjectExtendedLimitInformation));
IntPtr extendedInfoPtr = Marshal.AllocHGlobal(length);
Marshal.StructureToPtr(extendedInfo, extendedInfoPtr, false);
if (UnsafeNativeMethods.SetInformationJobObject(_handle, JobObjectInfoType.ExtendedLimitInformation, extendedInfoPtr, (uint)length))
{
_logger.WriteLine("Job set to kill all processes");
}
else
{
_logger.WriteLine("Cannot set job to kill all processes ({0})", Logger.LastWin32ErrorMessage());
}
}
}
示例2: Main
static int Main(string[] args)
{
var logger = new Logger(Console.Out);
var parser = new PencilOptionsParser();
IPencilOptions options;
try
{
options = parser.Parse(args);
}
catch (OptionException e)
{
logger.WriteLine(e.Message);
parser.Display(logger);
return Program.Failure;
}
var compiler = new CSharpProjectCompiler(logger, options.Assemblies, options.CompilerVersion);
var program = new Program(logger, compiler);
var stopwatch = Stopwatch.StartNew();
try
{
return program.Run(options);
}
finally
{
stopwatch.Stop();
logger.WriteLine("Total time: {0} seconds.", stopwatch.Elapsed.Seconds);
}
}
示例3: Should_support_using_for_Indent
public void Should_support_using_for_Indent()
{
var output = new StringWriter();
var logger = new Logger(output);
logger.WriteLine("1");
using(logger.Indent())
logger.WriteLine("2");
logger.WriteLine("3");
Assert.AreEqual(string.Format("1{0} 2{0}3{0}", output.NewLine), output.ToString());
}
示例4: Log
public Log(Logger logger, string title, params object[] args)
{
_logger = logger;
_title = string.Format(title, args);
_logger.WriteLine(title, args);
_logger.WriteLine();
_logger.Indent(2);
_start = DateTime.Now;
}
示例5: Callstack
public Callstack(Logger logger)
{
_logger = logger;
if (_logger.Logging)
{
Type type = GetType();
StackTrace stackTrace = new StackTrace();
int i = 0;
MethodBase method;
do
{
StackFrame frame = stackTrace.GetFrame(i);
method = frame.GetMethod();
if ((method.IsConstructor && method.DeclaringType.IsAssignableFrom(type)) ||
((method.MemberType == MemberTypes.Method) && ((MethodInfo)method).ReturnType.IsAssignableFrom(type)))
{
method = null;
}
else
{
break;
}
i++;
}
while (i < stackTrace.FrameCount);
if (method != null)
{
_name = string.Format(CultureInfo.InvariantCulture, "{0}.{1}", method.DeclaringType.Name, method.Name);
_logger.WriteLine("{0} entering", _name);
_logger.Indent();
}
}
}
示例6: Write_should_support_formatting
public void Write_should_support_formatting()
{
var output = new StringWriter();
var logger = new Logger(output);
logger.WriteLine("{0}+{1}", 1, 2);
Assert.AreEqual("1+2" + output.NewLine, output.ToString());
}
示例7: Main
private static void Main(string[] args)
{
Logger logger = new Logger();
MemoryChannel channel = new MemoryChannel();
Delay delay = new Delay(3, 100);
Receiver receiver = new Receiver(channel, logger, 16);
receiver.DataReceived += ReceiverOnDataReceived;
Sender sender = new Sender(channel, logger, 16, 1, delay);
Task receiverTask = receiver.RunAsync();
Task senderTask = sender.RunAsync(CancellationToken.None);
try
{
Task.WaitAll(receiverTask, senderTask);
}
catch (AggregateException e)
{
Console.WriteLine(e.ToString());
}
channel.Dispose();
logger.WriteLine("Done.");
}
示例8: VerifyTrainingData
/// <summary>
/// Verify training data by splitting it into random training and testing group
/// </summary>
/// <returns>accuracy rate</returns>
internal double VerifyTrainingData()
{
var allTrainingData = _trainingService.GetAllTrainingItems();
var trainingGroup = new List<TrainingItem>();
var testGroup = new List<TrainingItem>();
var rand = new Random(DateTime.Now.Millisecond);
foreach (var item in allTrainingData)
{
if (rand.Next(0,10) < 5)
trainingGroup.Add(item);
else
testGroup.Add(item);
}
var bayesEngine = DependencyManager.Current.GetInstance<BayesEngine>();
bayesEngine.Initialize(trainingGroup);
var accurateCount = 0;
foreach (var item in testGroup)
{
var message = _parsedMessageService.GetById(item.MessageId);
var thread = _parsedMessageService.GetByThreadId(message.ThreadId);
var classifyProbs = bayesEngine.Classify(message.BodyPlain);
var topic = classifyProbs.OrderByDescending(p => p.Value).First().Key;
if (topic == item.Topic)
accurateCount++;
#if DEBUG
else
{
using (var logger = new Logger("VerifyTrainingData.log", false))
{
logger.WriteLine(message.BodyPlain);
logger.WriteLine(string.Format("Expected {0}, Actual {1}", item.Topic, topic));
foreach (var d in classifyProbs)
{
logger.WriteLine(string.Format("{0,10}: {1,5:P1}", d.Key, d.Value));
}
logger.WriteLine("==============================");
}
}
#endif
}
return accurateCount*1.0/testGroup.Count;
}
示例9: QuickLog
public static void QuickLog(String fileNameOverride, String lineOne, String lineTwo, String lineThree)
{
try
{
Logger quickLog = new Logger(fileNameOverride);
quickLog.WriteLine(lineOne);
if(! lineTwo.Equals("")) quickLog.WriteLine(lineTwo);
if(! lineThree.Equals("")) quickLog.WriteLine(lineThree);
quickLog.Close();
}
catch (IOException e)
{
Console.WriteLine(e.Message);
Console.WriteLine(e.StackTrace);
}
}
示例10: TestBehaviorMock
public void TestBehaviorMock()
{
var mock = new Mock<ILogSaver>();
var logger = new Logger(mock.Object);
logger.WriteLine("Greeting by logger!");
// Check that method Write was called of our Mock with any argument
mock.Verify(lw => lw.Write(It.IsAny<string>()));
}
示例11: CaptionBlock
public CaptionBlock( Logger logger, string caption, char symbol = '#', int maxLength = 80)
{
Logger = logger;
c = caption;
s = symbol;
m = maxLength;
Logger.NewLine();
Logger.WriteLine( LogHelper.Header( "BEGIN: " + c, s, m) );
Logger.NewLine();
Logger.Indent();
}
示例12: TestWriteLine
public void TestWriteLine()
{
string[] lines = new string[] { "first line", "second line", "third line", "fourth line" };
string dir = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
Logger log = new Logger(dir, "testLogWriteLine");
foreach (string line in lines)
{
log.WriteLine(line);
}
}
示例13: TestExecuter
public TestExecuter(string configFile)
{
Logger logger = new Logger();
this.context = new Context(this, logger);
XmlDocument testConfig = new XmlDocument();
testConfig.Load(configFile);
// Get test name...
XmlNode nameNode = testConfig.SelectSingleNode("/TestCase/@testName");
if ( null != nameNode )
{
this.testName = nameNode.Value;
}
logger.WriteLine(" ");
logger.WriteLine(new string('-', 79));
logger.WriteLine(" S T A R T" );
logger.WriteLine( " " );
string userName = GetUserName();
logger.WriteLine(string.Format("Test: {0} started @ {1} by {2}", this.testName, GetNow(), userName));
logger.WriteLine(new string('-', 79));
// Get test setup / execution / teardown steps
this.setupSteps = testConfig.SelectNodes("/TestCase/TestSetup/*");
this.executeSteps = testConfig.SelectNodes("/TestCase/TestExecution/*");
this.teardownSteps = testConfig.SelectNodes("/TestCase/TestCleanup/*");
this.logger = logger;
}
示例14: Analyze
public void Analyze(string responseString, Logger logger)
{
if (responseString.Contains("error"))
{
_lastMessageWereSucceeded = false;
var mlsForSleep = _howManyMlsSleepWhenAnyErrorHappened * (++_countOfErrorsSinceLastSuccess);
logger.WriteLine("Error occured : sleeping for " + mlsForSleep);
SmartThreadSleep.Sleep(mlsForSleep);
}
else
{
_lastMessageWereSucceeded = true;
_countOfErrorsSinceLastSuccess = 0;
}
}
示例15: OnStart
protected override void OnStart(string[] args)
{
diContainer = new UnityContainer();
diContainer.RegisterType<IInterestPaymentHandler, InterestPaymentHandler>(new InjectionConstructor());
logger = new Logger(AppDomain.CurrentDomain.BaseDirectory + "log.txt");
scheduledDateTime = DateTime.Parse(ConfigurationManager.AppSettings["ScheduledDateTime"]);
intervalMinutes = Int32.Parse(ConfigurationManager.AppSettings["IntervalMinutes"]);
timer = new Timer(TimerInterval);
timer.Elapsed += TimerOnElapsed;
timer.Start();
logger.WriteLine("Interest Payment Service starts.");
}