static void Main(string[] args) { System.Console.WriteLine("Application started - Esc to quit"); var sessionFactory = NHibernateFactory.AssembleSessionFactory(DATABASE_FILE); ILog consoleLogger = new ConsoleLogger {VerbosityLevel = 2}; ILog databaseLogger = new Logger(new LogEntryDatabaseRepository(sessionFactory)) {VerbosityLevel = 1}; ILog log = new CompositeLogger(consoleLogger, databaseLogger); var iocContainer = new IocContainerForScheduler(); iocContainer.BindToConstant(sessionFactory); var taskDirectory = new DirectoryInfo(Assembly.GetExecutingAssembly().Location).Parent.FullName; var taskScheduler = new Scheduler(iocContainer, taskDirectory, new FileUtilities(), new TimerWithTimestamp(0, 10000), new TimerWithTimestamp(0, 2000), log); taskScheduler.Start(); try { while (System.Console.ReadKey().Key != ConsoleKey.Escape) { } } catch (Exception e) { log.WriteEntry(new LogEntry(e.Source, e.Message, DateTime.Now)); } }
private static void DemoConsoleLogger() { // Use the ConsoleLogger and set minimum logging level var logger = new ConsoleLogger {LogLevel = LogLevel.Information}; logger.Log("this won't show up..."); logger.Log("using standard ConsoleLogger", LogLevel.Information); }
public static void Configure() { ILog logger = new ConsoleLogger(); ILog errorLogger = new ErrorLogger(); LogManager.GetLog = type => type == typeof(ActionMessage) ? logger : errorLogger; }
public void Test_End_To_End() { string input = "9\r\n" + "8\r\n" + "nothing\r\n" + "13\r\n" + "-87\r\n" + "2"; string expected = "9:3,3\r\n" + "8:2,2,2\r\n" + "13:13\r\n" + "-87:1\r\n" + "2:2\r\n"; var standardOut = new StringWriter(); var errorOut = new StringWriter(); var logger = new ConsoleLogger(standardOut, errorOut); IPrimeFactorCalculator calculator = new PrimeFactorCalculator(); // The main calculator. calculator = new PrimeFactorOutputWriter(calculator, logger); // Our formatter for dumping to the console calculator = new PrimeFactorExceptionLogger(calculator, logger); // An exception handler that can log errors for us. var path = TempFileHelpers.CreateTestFile(input); IIntegerReader reader = new IntegerFileReader(path); int? number; while ((number = reader.ReadNext()) != null) { calculator.Execute(number.Value); } Assert.AreEqual(expected, standardOut.ToString()); Assert.AreEqual(string.Empty, errorOut.ToString()); }
public Tesbernch_Multiplier() { _m_clk = new Clock(ClockPeriod) { Clk = _clk }; _m_signal = new XilinxMultiplier() { CLK = _clk, A = _A, B = _B, P = _P, }; _m_logger1 = new ConsoleLogger<StdLogicVector>() { DataIn = _A }; _m_logger2 = new ConsoleLogger<StdLogicVector>() { DataIn = _B }; _m_logger3 = new ConsoleLogger<StdLogicVector>() { DataIn = _P }; }
static void Main(string[] args) { var logger = new ConsoleLogger(); var serverConfig = new WebServerConfig(logger); if (!serverConfig.IsIis7OrAbove) { logger.LogHeading("IIS7 is not installed on this machine. IIS configuration setup terminated."); return; } var envConfig = new Config(); try { serverConfig .AddAppPool(envConfig.SiteName, "v4.0", ManagedPipelineMode.Integrated, ProcessModelIdentityType.LocalService) .WithProcessModel(envConfig.IdleTimeout, envConfig.PingingEnabled) .Commit(); serverConfig .AddSite(envConfig.SiteName, envConfig.PortNumber, envConfig.PortNumber) .AddApplication("/", envConfig.WebRoot, envConfig.SiteName) .WithLogging(false) .Commit(); } catch (Exception e) { logger.LogError(e); } }
public void ConfirmLoggingTest() { var myLogger = new ConsoleLogger(); // Create mock TextWriters which confirm the output var stringOutput = new Mock<TextWriter>(); stringOutput.Setup(w => w.WriteLine(It.IsRegex("\\([^)]+\\) \\.NET Client API \\[(\\w+)\\]: FooBar"))); var nullOutput = new Mock<TextWriter>(); nullOutput .Setup(w => w.WriteLine(It.IsAny<string>())) .Callback<string>(str => Assert.Fail("Unexpected WriteLine(): " + str)); // Test non-error methods: Console.SetOut(stringOutput.Object); Console.SetError(nullOutput.Object); myLogger.Info("FooBar"); myLogger.Debug("FooBar"); myLogger.Warning("FooBar"); stringOutput.Verify(); nullOutput.Verify(); // Test error-methods: Console.SetOut(nullOutput.Object); Console.SetError(stringOutput.Object); myLogger.Error("FooBar"); stringOutput.Verify(); nullOutput.Verify(); }
public testbench_XilinxDivider() { _m_clk = new Clock(ClockPeriod) { Clk = _clk }; _m_signal = new XilinxDivider() { CLK = _clk, DIVIDEND = _DIVIDEND, DIVISOR = _DIVISOR, QUOTIENT = _QUOTIENT, FRACTIONAL = _FRACTION }; _m_logger1 = new ConsoleLogger<StdLogicVector>() { DataIn = _DIVIDEND }; _m_logger2 = new ConsoleLogger<StdLogicVector>() { DataIn = _DIVISOR }; _m_logger3 = new ConsoleLogger<StdLogicVector>() { DataIn = _QUOTIENT }; }
private static void Main(string[] args) { Console.SetWindowSize(200, 50); var logger = new ConsoleLogger(); var testRunner = new TestRunner(MainDirectory, customLanguageFileExtension, logger); testRunner.RunTests(); }
static void Main(string[] args) { var logger = new ConsoleLogger(); logger.Execute(); logger.Trace(); Console.ReadLine(); }
public ILog GetLogger(Type type) { ILog logger; if (!Loggers.TryGetValue(type, out logger)) { logger = new ConsoleLogger(type, colored, colors, minLevel); Loggers.TryAdd(type, logger); } return logger; }
protected override ILog GetLogger(Type type) { ILog logger; if (!Loggers.TryGetValue(type, out logger)) { logger = new ConsoleLogger(type, colors, this); Loggers.TryAdd(type, logger); } return logger; }
public void SimpleLogTest() { var myLogger = new ConsoleLogger(); myLogger.Debug("FooBar"); myLogger.Warning("FooBar"); myLogger.Error("FooBar"); myLogger.Error(new Exception(), "FooBar"); myLogger.Info("FooBar"); myLogger.Info("FooBar", "Bar"); Assert.AreEqual(myLogger.IsDebugEnabled, myLogger.IsDebugEnabled); // We don't care about the actual value. }
public void Test_Standard_Error_With_Message() { var standardOut = new StringWriter(); var errorOut = new StringWriter(); var logger = new ConsoleLogger(standardOut, errorOut); logger.LogError(new Exception("Test"), "Test Message"); Assert.AreEqual(string.Empty, standardOut.ToString()); Assert.AreEqual("Test Message\r\nSystem.Exception: Test\r\n", errorOut.ToString()); }
public void Test_Standard_Out() { var standardOut = new StringWriter(); var errorOut = new StringWriter(); var logger = new ConsoleLogger(standardOut, errorOut); logger.Log("Test Message"); Assert.AreEqual("Test Message\r\n", standardOut.ToString()); Assert.AreEqual(string.Empty, errorOut.ToString()); }
public void Test_Standard_Out_Formatted() { var standardOut = new StringWriter(); var errorOut = new StringWriter(); var logger = new ConsoleLogger(standardOut, errorOut); logger.Log("{0}:{1}", 1, 2); Assert.AreEqual("1:2\r\n", standardOut.ToString()); Assert.AreEqual(string.Empty, errorOut.ToString()); }
private static void Main() { //客户端基本服务。 ISerializer<string> serializer = new JsonSerializer(); ISerializer<byte[]> byteArraySerializer = new StringByteArraySerializer(serializer); ISerializer<object> objectSerializer = new StringObjectSerializer(serializer); IServiceIdGenerator serviceIdGenerator = new DefaultServiceIdGenerator(new ConsoleLogger<DefaultServiceIdGenerator>()); var typeConvertibleService = new DefaultTypeConvertibleService(new[] { new DefaultTypeConvertibleProvider(objectSerializer) }, new ConsoleLogger<DefaultTypeConvertibleService>()); var serviceRouteManager = new SharedFileServiceRouteManager("d:\\routes.txt", serializer, new ConsoleLogger<SharedFileServiceRouteManager>()); //zookeeper服务路由管理者。 // var serviceRouteManager = new ZooKeeperServiceRouteManager(new ZooKeeperServiceRouteManager.ZookeeperConfigInfo("172.18.20.132:2181"), serializer, new ConsoleLogger<ZooKeeperServiceRouteManager>()); // IAddressSelector addressSelector = new RandomAddressSelector(); IAddressSelector addressSelector = new PollingAddressSelector(); IAddressResolver addressResolver = new DefaultAddressResolver(serviceRouteManager, new ConsoleLogger<DefaultAddressResolver>(), addressSelector); ITransportClientFactory transportClientFactory = new DotNettyTransportClientFactory(byteArraySerializer,objectSerializer, new ConsoleLogger<DotNettyTransportClientFactory>()); var remoteInvokeService = new RemoteInvokeService(addressResolver, transportClientFactory, new ConsoleLogger<RemoteInvokeService>()); //服务代理相关。 IServiceProxyGenerater serviceProxyGenerater = new ServiceProxyGenerater(serviceIdGenerator); var services = serviceProxyGenerater.GenerateProxys(new[] { typeof(IUserService) }).ToArray(); IServiceProxyFactory serviceProxyFactory = new ServiceProxyFactory(remoteInvokeService, typeConvertibleService); //创建IUserService的代理。 var userService = serviceProxyFactory.CreateProxy<IUserService>(services.Single(typeof(IUserService).IsAssignableFrom)); var logger = new ConsoleLogger(); while (true) { Task.Run(async () => { try { Console.WriteLine($"userService.GetUserName:{await userService.GetUserName(1)}"); Console.WriteLine($"userService.GetUserId:{await userService.GetUserId("rabbit")}"); Console.WriteLine($"userService.GetUserLastSignInTime:{await userService.GetUserLastSignInTime(1)}"); Console.WriteLine($"userService.Exists:{await userService.Exists(1)}"); var user = await userService.GetUser(1); Console.WriteLine($"userService.GetUser:name={user.Name},age={user.Age}"); Console.WriteLine($"userService.Update:{await userService.Update(1, user)}"); Console.WriteLine($"userService.GetDictionary:{(await userService.GetDictionary())["key"]}"); await userService.TryThrowException(); } catch (RpcRemoteException remoteException) { logger.Error(remoteException.Message); } }).Wait(); Console.ReadLine(); } }
static void Main(string[] args) { var logger = new ConsoleLogger(LoggingType.All); var transpiler = new Transpiler.Transpiler(logger); transpiler.OptimizationLevel = Transpiler.OptimizationLevel.Level1; var prompter = new ConsolePrompt(logger); transpiler.AcquireInput(prompter); transpiler.Transpile(); Process.Start(transpiler.ExecutableFile); Console.WriteLine("Press enter key to exit..."); Console.ReadLine(); }
private static int Main(string[] args) { ConsoleColor original = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.White; string originalTitle = Console.Title; Console.Title = "ConfuserEx"; try { if (args.Length < 1) { PrintUsage(); return 0; } var proj = new ConfuserProject(); try { var xmlDoc = new XmlDocument(); xmlDoc.Load(args[0]); proj.Load(xmlDoc); proj.BaseDirectory = Path.Combine(Path.GetDirectoryName(args[0]), proj.BaseDirectory); } catch (Exception ex) { WriteLineWithColor(ConsoleColor.Red, "Failed to load project:"); WriteLineWithColor(ConsoleColor.Red, ex.ToString()); return -1; } var parameters = new ConfuserParameters(); parameters.Project = proj; var logger = new ConsoleLogger(); parameters.Logger = new ConsoleLogger(); Console.Title = "ConfuserEx - Running..."; ConfuserEngine.Run(parameters).Wait(); if (NeedPause()) { Console.WriteLine("Press any key to continue..."); Console.ReadKey(true); } return logger.ReturnValue; } finally { Console.ForegroundColor = original; Console.Title = originalTitle; } }
private static async Task Run(OsmDataServiceOperations operations) { var logger = new ConsoleLogger(); try { var container = new UnityContainer(); UnityRegisterDataAccess.RegisterUnityTypes(container, logger); UnityRegisterApi.RegisterUnityTypes(container); var osmDataService = container.Resolve<IOsmDataService>(); var fileSystemHelper = container.Resolve<IFileSystemHelper>(); var directory = fileSystemHelper.GetCurrentDirectory(); await osmDataService.Initialize(directory); await osmDataService.UpdateData(operations); } catch (Exception ex) { logger.Error("Failed updating OSM data with exception: " + ex); } }
public Testbench_XilinxAdderSubtracter() { _m_clk = new Clock(ClockPeriod) { Clk = _clk }; _m_signal = new XilinxAdderSubtracter() { CLK = _clk, A = _A, B = _B, S = _S, // CE = _CE, //C_out = _C_out, }; _m_logger4 = new ConsoleLogger<StdLogicVector>() { DataIn = _S }; _m_logger1 = new ConsoleLogger<StdLogicVector>() { DataIn = _A }; _m_logger2 = new ConsoleLogger<StdLogicVector>() { DataIn = _B }; _m_logger3 = new ConsoleLogger<StdLogic>() { DataIn = _C_out }; _m_logger5 = new ConsoleLogger<StdLogic>() { DataIn = _CE }; }
/// <summary> /// Process the game. /// </summary> /// <param name="playBoard">Current play board value.</param> /// <param name="playerMoves">Current player moves.</param> public void ProcessGame(ref char[,] playBoard, ref int playerMoves) { byte rowLenght = (byte)playBoard.GetLength(0); byte columnLenght = (byte)playBoard.GetLength(1); Board boardGenerator = new Board(rowLenght, columnLenght); ScoreBoardFormatter formatter = new ScoreBoardFormatter(); // ILogger fileLogger = new FileLogger("scorebord.txt", formatter); ILogger consoleLogger = new ConsoleLogger(formatter); ScoreBoard scoreBoard = new ScoreBoard(consoleLogger); var printer = PrintingManager.Instance; switch (this.currentCommand) { case "RESTART": IInputCommand restart = new RestartCommand(boardGenerator, printer); restart.Execute(ref playBoard, ref playerMoves); break; case "TOP": IInputCommand topscoreBoard = new TopCommand(scoreBoard, this.topPlayers); topscoreBoard.Execute(ref playBoard, ref playerMoves); break; case "EXIT": break; default: InputCommandValidator validator = new InputCommandValidator(); if (validator.IsValidInputCommand(this.currentCommand)) { IInputCommand play = new PlayCommand(this.currentCommand, this.topPlayers, scoreBoard, boardGenerator, printer); play.Execute(ref playBoard, ref playerMoves); break; } Console.WriteLine("Wrong input ! Try Again ! "); break; } }
static void Main(string[] args) { var fs = new FileSystem(); var logger = new ConsoleLogger(); if (args.Length == 0) { var xlator = new Translator("", "module_name", fs, logger); xlator.Translate("-", Console.In, Console.Out); Console.Out.Flush(); return; } if (args[0].ToLower() == "-d") { // org.yinwang.pysonar.demos.Demo.DemoMain(args); return; } if (args[0].ToLower() == "-r") { #if READY_FOR_TYPES var typeAnalysis = new Pytocs.TypeInference.AnalyzerImpl(fs, logger, new Dictionary<string, object>(), DateTime.Now); typeAnalysis.Analyze("."); TranslateModules(typeAnalysis); #else var walker = new DirectoryWalker("*.py"); walker.Enumerate(); #endif } else { foreach (var fileName in args) { var xlator = new Translator( "", Path.GetFileNameWithoutExtension(fileName), new FileSystem(), new ConsoleLogger()); xlator.TranslateFile(fileName, fileName + ".cs"); } } }
public void Start() { var logger = new ConsoleLogger(); var serverConfig = new WebServerConfig(logger); // Current directory: src\Roadkill.Tests\bin\Debug string webRoot = Environment.CurrentDirectory + @"..\..\..\..\Roadkill.Web"; var dirInfo = new DirectoryInfo(webRoot); serverConfig .AddAppPool(_siteName, "v4.0", ManagedPipelineMode.Integrated, ProcessModelIdentityType.LocalService) .WithProcessModel(TimeSpan.FromMinutes(60), false) .Commit(); serverConfig .AddSite(_siteName, _webPort, _webPort) .AddApplication("/", dirInfo.FullName, _siteName) .WithLogging(false) .Commit(); }
public void Hello() { var logger = new ConsoleLogger() + new TextFileLogger( @"C:\Temp\Logs\1.log" ) + new TextFileLogger( new DirectoryInfo( @"C:\Temp\Logs\Test" ) ); logger.LogInfo( "Hello World!" ); logger.LogInfo( "Hello World!" ); logger.LogWarning( "Multiline\r\nLogs\r\n" ); logger.LogError( "This has an error!" ); logger.LogError( "This has an error!" ); logger.LogError( "This has an error!" ); try { throw new Exception( "Test exception!" ); } catch ( Exception e ) { logger.LogException( e ); } }
public void Hello() { var logs = new LogCollection(); var logger = new ConsoleLogger() + new TextFileLogger( @"C:\Temp\Logs\1.log" ) + new TextFileLogger( new DirectoryInfo( @"C:\Temp\Logs\Test" ) ) + logs; logger.LogInfo( "Hello World!" ); using ( LogScope.EnterScope( "Test" ) ) { logger.LogInfo( "Hello World!" ); } logger.LogWarning( "Multiline\r\nLogs\r\n" ); logger.LogError( "This has an error!" ); logger.LogError( "This has an error!" ); logger.LogError( "This has an error!" ); try { throw new Exception( "Test exception!" ); } catch ( Exception e ) { logger.LogException( e ); } Assert.AreEqual( logs.Count(), 7 ); Assert.AreEqual( logs.ElementAt( 0 ).LogType(), LogType.Info ); Assert.AreEqual( logs.ElementAt( 1 ).LogType(), LogType.Info ); Assert.AreEqual( logs.ElementAt( 2 ).LogType(), LogType.Warning ); Assert.AreEqual( logs.ElementAt( 3 ).LogType(), LogType.Error ); Assert.AreEqual( logs.ElementAt( 4 ).LogType(), LogType.Error ); Assert.AreEqual( logs.ElementAt( 5 ).LogType(), LogType.Error ); Assert.AreEqual( logs.ElementAt( 6 ).LogType(), LogType.Exception ); Assert.AreEqual( logs.ElementAt( 0 ).MetaData.GetMetaData<LogScope>(), LogScope.RootScope ); Assert.AreEqual( logs.ElementAt( 1 ).MetaData.GetMetaData<LogScope>().Name, "Test" ); Assert.AreEqual( logs.ElementAt( 2 ).MetaData.GetMetaData<LogScope>(), LogScope.RootScope ); //TextLogFileManager.Flush(); }
public void SimpleStartStopOneNode() { var node1Writer = new ConsoleLogger("node1"); using (var node1 = new Zyre("node1", false, node1Writer.ConsoleWrite)) { node1.Start(); node1.Should().NotBeNull(); node1.Name().Should().Be("node1"); node1.SetHeader("X-HELLO", "World"); var uuid1 = node1.Uuid(); uuid1.Should().NotBeEmpty(); Thread.Sleep(100); node1Writer.ConsoleWrite("After starting node1, Dump():"); node1.Dump(); Thread.Sleep(100); Console.WriteLine("Stopping node1"); node1.Stop(); Thread.Sleep(100); node1.Dump(); } }
static void Main(string[] args) { string solutionPath, solutionName; ConsoleLogger logger = new ConsoleLogger(); if (!PrintDisclaimer()) { return; } Console.WriteLine("\n"); if (args.Length == 2) //pass path and solution name via command args { solutionPath = args[0]; solutionName = args[1]; } else { Console.Write("\nEnter path to solution: "); solutionPath = Console.ReadLine(); Console.Write("\nEnter solution name (.sln): "); solutionName = Console.ReadLine(); } ReTarget reTarget = new ReTarget(solutionPath, solutionName, logger); reTarget.ConvertSolution(); logger.Log("Next steps:"); logger.Log("\tOpen Solution"); logger.Log("\tBuild Solution (NuGet packages will get restored)"); logger.Log("\tClose Solution"); logger.Log("\tOpen Solution"); logger.Log("\tManually add missing NuGet packages (see list, if any)"); Console.ReadKey(); }
static void Main(string[] args) { var account = Radio7.ConfigReader.ConfigFactory.Instance.Resolve<AccountRepository>(); var setttings = Radio7.ConfigReader.ConfigFactory.Instance.Resolve<Settings>(); var logger = new ConsoleLogger(); var branchRepository = new BranchRepository(account, logger); var branches = branchRepository.Get(); var commitRepository = new CommitRepository(account, logger); var commits = commitRepository.Get(setttings.BranchName); var prRepository = new PullRequestRepository(account, logger); var pullRequests = prRepository.Get(); var sql = new SqlRepository(setttings.ConnectionString); sql.LoadTable(branches); sql.LoadTable(commits); sql.LoadTable(pullRequests); }
/// <summary> /// Gets a logger for logging stuff from within the specified type /// </summary> protected override ILog GetLogger(Type type) { ILog logger; if (Loggers.TryGetValue(type, out logger)) return logger; logger = new ConsoleLogger(type, _colors, this, _showTimestamps); Loggers.TryAdd(type, logger); return logger; }