Exemplo n.º 1
0
 public HtmlRecorder()
 {
     pLogFileName = FileUtils.Relative2AbsolutePath(
         FileUtils.CombineWinPath(pLogFolder,
             FileUtils.MakeValidFileName(DateTime.Now.ToString()) + pLogExtension));
     pLog = new FileLogger(pLogFileName);
     pLog.Log(pLogHeader, false);
     pImagesFolder = pLogFileName + pImagesFolderExtension;
     Directory.CreateDirectory(pImagesFolder);
 }
Exemplo n.º 2
0
        public bool Connect(int port, string IP, short ID, string Logfile)
        {
            mLogFileName = Logfile;
            mID          = ID;
            mIP          = IP;
            mPort        = port;

            #region logger
            try
            {
                if (mLogger == null)
                {
                    // instantiate the logger
                    mLogger = Logger.Logger.Instance;

                    // instantiate the log observer that will write to disk
                    mFileLogger = new FileLogger(this.mLogFileName);
                    mFileLogger.Init();

                    // Add mFileLogger to the Logger.
                    mLogger.RegisterObserver(mFileLogger);
                    mLogger.AddLogMessage("******* NEW RUN OF THE AGENT! *******");
                }
            }
            catch (Exception)
            {
                Clean();
                return(false);
            }
            #endregion logger

            #region Communication
            try
            {
                IPAddress ipAddress = IPAddress.Parse(mIP);
                mComm.Init(mID, ipAddress, mPort);
                mComm.SendMessage(Command.Login, mID.ToString());
                mComm.Listen();
            }
            catch (Exception ex)
            {
                mLogger.AddLogMessage("Communication Init: " + ex.Message);
                if (mLogger != null)
                {
                    mFileLogger.Terminate();
                }
                return(false);
            }
            #endregion Communication

            // connection established successfully
            AHStateManager(GameState.Idle);

            return(true);
        }
Exemplo n.º 3
0
 public FileLoggerTests()
 {
     _settings = Substitute.For <IFileLoggerSettings>();
     _settings.LogLevel.Returns(LogLevel.Info);
     _settings.Directory.Returns("C:\\Test");
     _settings.FileName.Returns("Log_{0}.txt");
     _settings.MessageFormat.Returns("{0}\t{1:yyyy-MM-dd_HH:mm}:\t{2}");
     _fileSystem = Substitute.For <IFileSystem>();
     _fileSystem.AppendFileAsync(Arg.Any <string>(), Arg.Any <string>()).Returns(Task.CompletedTask);
     _logger = new Logger.FileLogger(_settings, _fileSystem);
 }
Exemplo n.º 4
0
		public CourierStateMachine(EveCourierState initialState, FileLogger logger, IMessageHandler messager, ISettingsProvider settings)
			: base(initialState)
		{
			pStateMachineId = Id;
			SleepUntil = null;
			pLogger = logger;
			pMessager = messager;
			pSettings = settings;
			pEve = new Eve(pMessager);
			pHeartBeat.AutoReset = true;
			pHeartBeat.Elapsed += PHeartBeatElapsed;
#if !TurnOffHeartBeat
			pHeartBeat.Start();
#endif
		}
Exemplo n.º 5
0
        private static void Main()
        {
            var port = int.Parse(ConfigurationManager.AppSettings["port"]);
            var logged = bool.Parse(ConfigurationManager.AppSettings["logged"]);
            ILogger logger;

            if (logged)
            {
                logger = new FileLogger("log.txt");
            }
            else
            {
                logger = new NullObjectLogger();
            }

            var server = new Server(port, logger);
            server.Start();
        }
Exemplo n.º 6
0
        public FileLoggerTests()
        {
            string expectedConfigurationPath = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None).FilePath;

            if (File.Exists(expectedConfigurationPath))
            {
                File.Delete(expectedConfigurationPath);
            }
            string actualConfigurationPath = Path.Combine(new FileInfo(expectedConfigurationPath).DirectoryName,
                                                          "FileLogger.Integration.Tests.dll.config");

            File.Copy(actualConfigurationPath, expectedConfigurationPath);

            _settings = new DefaultFileLoggerSettings();
            _logger   = new Logger.FileLogger(_settings, new FileSystemAdapter());
            if (Directory.Exists(_settings.Directory))
            {
                Directory.Delete(_settings.Directory, true);
            }
            Directory.CreateDirectory(_settings.Directory);
        }
Exemplo n.º 7
0
 public ILogger CreateLogger(LogLevel LOGLEV)
 {
     ILogger returnLog = new FileLogger(LOGLEV);
     return returnLog;
 }
Exemplo n.º 8
0
 public ILogger CreateLogger()
 {
     ILogger returnLog = new FileLogger();
     return returnLog;
 }
Exemplo n.º 9
0
		public CourierStateMachine(FileLogger logger, IMessageHandler messager, ISettingsProvider settings)
			: this(new IdleState(), logger, messager, settings)
		{}