private EmailSpoolerConfig CreateWithSettings(ISimpleLogger logger = null, NameValueCollection settings = null) { var result = new EmailSpoolerConfig(logger ?? Substitute.For <ISimpleLogger>(), settings); Assert.IsInstanceOf <EmailSpoolerConfig>(result); return(result); }
public TashAccessor(IDvinRepository dvinRepository, ISimpleLogger simpleLogger, ILogConfiguration logConfiguration, IMethodNamesFromStackFramesExtractor methodNamesFromStackFramesExtractor) { DvinRepository = dvinRepository; _SimpleLogger = simpleLogger; _DetailedLogging = logConfiguration.DetailedLogging; _MethodNamesFromStackFramesExtractor = methodNamesFromStackFramesExtractor; }
public LoggerWithWriterFactory( ISimpleLogger logger, IRecordWriterBuilder writerFactory) { _logger = logger; _writerFactory = writerFactory; }
static void Main() { FileLogDestination fileLogger = null; try { fileLogger = new FileLogDestination("persistentclipboard.log"); Logger = new SimpleLogger.SimpleLogger(true, Status.Error, new ILogDestination[] { fileLogger }); Application.ThreadException += new ThreadExceptionHandler().ApplicationThreadException; try { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); } catch (Exception e) { Logger.Error("App startup", e); // Probably want something a little more sophisticated than this MessageBox.Show(e.Message, "The application could not initialize.", MessageBoxButtons.OK, MessageBoxIcon.Error); Environment.Exit(0); } Application.Run(new HostForm(Logger)); } finally { if (fileLogger != null) fileLogger.Dispose(); } }
private static void createDirectory(IFileSystem system, ISimpleLogger logger, params string[] pathParts) { var directory = FileSystem.Combine(pathParts); logger.Log("Creating directory " + directory); system.CreateDirectory(directory); }
public static void Run(ISimpleLogger logger) { InitServer.logger = logger; BuildInitResponse(); ws = new WebServer(new[] { "http://*:" + ServerConfig.Instance.InitPort.ToString() + "/" }, HandleRequest); ws.Run(); }
public SimpleActiveMQTest( ISimpleLogger <TestConsumer> logger, IConfiguration configuration ) { _logger = logger; //ServiceManager.GetService<ISimpleLogger<SimpleActiveMQTest>>(); _configuration = configuration; //ServiceManager.GetService<IConfiguration>(); #region 消费者 _consumer = new SimpleConsumer(new ActiveMQOptions(_configuration).BrokerUri, MQType.Queue, "Test_PromotionRecharge", message => { _logger.LogInfo($"消费者接收到消息:{message.Text}"); //throw new Exception("异常测试。。。"); }, ex => { _logger.LogError("【消费者】接收消息异常", ex); return(true); }); _consumer.Start(); #endregion #region 生产者 _producer = new SimpleProducer(new ActiveMQOptions(_configuration).BrokerUri, MQType.Queue, "Test_PromotionRecharge", ex => { _logger.LogError("【生产者】发送消息异常", ex); }); #endregion }
public bool Initialize(InitializeInput input, IFileSystem fileSystem, ISimpleLogger logger) { var deploymentDirectory = input.Settings.DeploymentDirectory; logger.Log("Trying to initialize Bottles deployment folders at {0}", deploymentDirectory); if (fileSystem.DirectoryExists(deploymentDirectory)) { if (input.ForceFlag) { logger.Log(DELETING_EXISTING_DIRECTORY, deploymentDirectory); fileSystem.CleanDirectory(deploymentDirectory); fileSystem.DeleteDirectory(deploymentDirectory); Thread.Sleep(10); //file system is async } else { logger.Log(DIRECTORY_ALREADY_EXISTS, deploymentDirectory); return(false); } } createDirectory(fileSystem, logger, deploymentDirectory); Console.WriteLine("Writing blank file to " + input.Settings.BottleManifestFile); fileSystem.WriteStringToFile(input.Settings.BottleManifestFile, ""); createDirectory(fileSystem, logger, input.Settings.BottlesDirectory); createDirectory(fileSystem, logger, input.Settings.RecipesDirectory); createDirectory(fileSystem, logger, input.Settings.EnvironmentsDirectory); createDirectory(fileSystem, logger, input.Settings.ProfilesDirectory); return(true); }
public MyProcessManager(ISimpleLogger simpleLogger, IProcessWatcher processWatcher, IProcessAdapter processAdapter) { this.simpleLoger = simpleLogger; this.processWatcher = processWatcher; this.processAdapter = processAdapter; processList = new List <IProcessItem>(); }
public void Constructor_WithLogConfiguration_ProducesLoggerWithConfiguredLogId() { var logConfiguration = CreateLogConfiguration(nameof(Constructor_WithLogConfiguration_ProducesLoggerWithConfiguredLogId)); _Sut = new SimpleLogger(logConfiguration, _Flusher, _MethodNamesFromStackFramesExtractor); Assert.AreEqual(logConfiguration.LogId, _Sut.LogId); }
public void MigrateIfNeeded(SimpleLogger logger, Mediator mediator, string appVersion) { m_logger = logger; Cache = (FdoCache)mediator.PropertyTable.GetValue("cache"); var foundOne = string.Format("{0}: Configuration was found in need of migration. - {1}", appVersion, DateTime.Now.ToString("yyyy MMM d h:mm:ss")); var configSettingsDir = FdoFileHelper.GetConfigSettingsDir(Cache.ProjectId.ProjectFolder); var dictionaryConfigLoc = Path.Combine(configSettingsDir, DictionaryConfigurationListener.DictionaryConfigurationDirectoryName); var stemPath = Path.Combine(dictionaryConfigLoc, "Stem" + DictionaryConfigurationModel.FileExtension); var lexemePath = Path.Combine(dictionaryConfigLoc, "Lexeme" + DictionaryConfigurationModel.FileExtension); if (File.Exists(stemPath) && !File.Exists(lexemePath)) { File.Move(stemPath, lexemePath); } foreach (var config in DCM.GetConfigsNeedingMigration(Cache, DCM.VersionCurrent)) { m_logger.WriteLine(foundOne); if (config.Label.StartsWith("Stem-")) { config.Label = config.Label.Replace("Stem-", "Lexeme-"); } m_logger.WriteLine(string.Format("Migrating {0} configuration '{1}' from version {2} to {3}.", config.Type, config.Label, config.Version, DCM.VersionCurrent)); m_logger.IncreaseIndent(); MigrateFrom83Alpha(logger, config, LoadBetaDefaultForAlphaConfig(config)); config.Save(); m_logger.DecreaseIndent(); } }
public MediaClient(ISimpleLogger logger, string url) { string clientId = m_ClientID; lock (m_ClientID) { int cid = Convert.ToInt32(m_ClientID); cid++; m_ClientID = cid.ToString(); clientId = m_ClientID; } Info = new ClientInfo() { ClientID = clientId, Active = false, Channel = "", ReceivedBytes = 0 }; m_Logger = logger; ServerURL = url; string path = url.Substring(url.LastIndexOf('/') + 1).Trim(); Info.Channel = path; Socket = new WebSocket(ServerURL); Socket.AllowUnstrustedCertificate = true; Socket.Closed += new EventHandler(WhenClosed); Socket.Error += new EventHandler <SuperSocket.ClientEngine.ErrorEventArgs>(WhenError); Socket.DataReceived += new EventHandler <DataReceivedEventArgs>(WhenDataReceived); Socket.Opened += new EventHandler(WhenOpened); }
protected MappingToXmlTesterBase(ISimpleLogger logger, ILogAsserter logAsserter) { this.Logger = logger; this.LogAssert = logAsserter; this.xmlTester = new XmlTester(logAsserter); this.xmlTester.ActualXmlChangedEvent += this.XmlTester_ActualXmlChangedEvent; this.xmlTester.ExpectedXmlChangedEvent += this.XmlTester_ExpectedXmlChangedEvent; }
public EmailSpoolerConfig(ISimpleLogger logger) { this.Logger = logger; this.MaxSendAttempts = GetConfiguredIntVal("MaxSendAttempts", 5); this.BackoffIntervalInMinutes = GetConfiguredIntVal("BackoffIntervalInMinutes", 2); this.BackoffMultiplier = GetConfiguredIntVal("BackoffMultiplier", 2); this.PurgeMessageWithAgeInDays = GetConfiguredIntVal("PurgeMessageWithAgeInDays", 30); }
public PdfConverterController(Interfaces.Utilities.Converters.IPdfToImageBytesConverter converter, IResponseErrorModelFactory <Common.Models.Errors.ResponseErrorModel> responseError, ISimpleLogger logger) { _converter = converter; _responseError = responseError; _logger = logger; }
protected ImLoggingBase(TimeSpan logEvery, DateTime endOfWork, ISimpleLogger simpleLogger, IMethodNamesFromStackFramesExtractor methodNamesFromStackFramesExtractor) { LogEvery = logEvery; EndOfWork = endOfWork; SimpleLogger = simpleLogger; MethodNamesFromStackFramesExtractor = methodNamesFromStackFramesExtractor; WorkerId = Guid.NewGuid().ToString().Substring(0, 5); }
/// <summary> /// Creates a new instance with all options the same as for this instance, but with the given option changed. /// It is unusual to call this method directly. Instead use <see cref="DbContextOptionsBuilder" />. /// </summary> /// <param name="simpleLogger"> The option to change. </param> /// <returns> A new instance with the option changed. </returns> public virtual CoreOptionsExtension WithSimpleLogger([CanBeNull] ISimpleLogger simpleLogger) { var clone = Clone(); clone._simpleLogger = simpleLogger; return(clone); }
public EmailSpoolerDependencies(ISimpleLogger logger) { this._logger = logger; this.DbContext = new EmailContext(); this.EmailConfig = EmailConfiguration.CreateFromAppConfig(); this.EmailSpoolerConfig = new EmailSpoolerConfig(logger); this.EmailGenerator = () => new Email(this.EmailConfig); }
/// <summary> /// Initializes a new instance of the <see cref="PublicDbContext"/> class. /// </summary> public PublicDbContext() : base($"name={nameof(PublicDbContext)}") { Database.SetInitializer <PublicDbContext>(null); logger = SimpleFileLogging.SimpleFileLogger.Instance; logger.LogDateFormatType = SimpleLogDateFormats.None; this.Database.Log = LogQueries; }
public EmailSpoolerDependencies(ISimpleLogger logger) { Logger = logger; DbContext = new EmailContext(); EmailConfig = EmailConfiguration.CreateFromAppConfig(); EmailSpoolerConfig = new EmailSpoolerConfig(logger); EmailGenerator = () => new Email(EmailConfig); }
public UtilsWindowsService(UtilServer server, ISimpleLogger logger) { _server = server; _logger = logger; EventLog.Log = "Application"; ServiceName = "Example Service"; CanStop = true; }
public static void LogWarning(this ISimpleLogger logger, string message) { var defaultColor = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.Yellow; logger.Log(message, "Warning"); Console.ForegroundColor = defaultColor; }
public SettingsManager(ISimpleLogger logger, JsonFileManager jsonFileManager, ISettingsBindable settings) { this._logger = logger; this._jsonFileManager = jsonFileManager; this._settings = settings; LoadDefault(); }
public IRecordWriter CreateTsvRecordWriter(ISimpleLogger logger) { return(new RecordPerRowWriter( headerFieldSubNameSeparator: TsvConst.HeaderFieldSubNameSeparator, rowFieldSeparator: TsvConst.RowFieldSeparator, _serializersFactories, logger)); }
public static void LogError(this ISimpleLogger logger, string message) { var defaultColor = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.Red; logger.Log(message, "Error"); Console.ForegroundColor = defaultColor; }
public static void Run(ISimpleLogger logger) { CDKeyServer.logger = logger; var ipep = new IPEndPoint(IPAddress.Any, ServerConfig.Instance.CDKeyPort); udpClient = new UdpClient(ipep); udpClient.BeginReceive(HandlePacket, udpClient); }
public IValueRecordWriter <TRecord> CreateTsvValueRecordWriter <TRecord>( ISimpleLogger logger) where TRecord : struct { return(new RecordPerRowValueWriter <TRecord>( headerFieldSubNameSeparator: TsvConst.HeaderFieldSubNameSeparator, rowFieldSeparator: TsvConst.RowFieldSeparator, _serializersFactories, logger)); }
public IReferenceRecordWriter <TRecord> CreateTsvReferenceRecordWriter <TRecord>( ISimpleLogger logger) where TRecord : class { return(new RecordPerRowReferenceWriter <TRecord>( headerFieldSubNameSeparator: TsvConst.HeaderFieldSubNameSeparator, rowFieldSeparator: TsvConst.RowFieldSeparator, _serializersFactories, logger)); }
public TextTester(ISimpleLogger logger, ILogAsserter logAsserter, ITextDifferenceFormatter differenceFormatter) { this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); this.logAssert = logAsserter ?? throw new ArgumentNullException(nameof(logAsserter)); this.differenceFormatter = differenceFormatter ?? throw new ArgumentNullException(nameof(differenceFormatter)); this.actualText = string.Empty; this.expectedText = string.Empty; }
public async Task Log_WithinParallelDifferentTasks_IsWorking() { _Sut = new SimpleLogger(CreateLogConfiguration(nameof(Log_WithinParallelDifferentTasks_IsWorking)), _Flusher, _MethodNamesFromStackFramesExtractor); var tasks = new List <Task> { new ImLogging(TimeSpan.FromMilliseconds(77), DateTime.Now.AddSeconds(4), _Sut, _MethodNamesFromStackFramesExtractor).ImLoggingWorkAsync(), new ImLoggingToo(TimeSpan.FromMilliseconds(222), DateTime.Now.AddSeconds(7), _Sut, _MethodNamesFromStackFramesExtractor).ImLoggingWorkTooAsync() }; await Task.WhenAll(tasks); }
/// <summary> /// Log with <see cref="LogLevel.Error"/> alias of <see cref="ISimpleLogger.Log(LogLevel, object, string, int, string)"/> /// </summary> public static void LogError( this ISimpleLogger logger, object message, [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumber = 0, [CallerMemberName] string callerMemberName = "") { logger.Log(LogLevel.Error, message, callerFilePath, callerLineNumber, callerMemberName); }
/// <summary> /// Log with <see cref="LogLevel.Error"/> alias of <see cref="ISimpleLogger.LogException(LogLevel, System.Exception, string, int, string)"/> /// </summary> public static void LogException( this ISimpleLogger logger, System.Exception exception, [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumber = 0, [CallerMemberName] string callerMemberName = "") { logger.LogException(LogLevel.Error, exception); }
public ValuesRowWriter( ISimpleLogger writer, string valueSeparator) { _writer = writer; _valueSeparator = valueSeparator; _isEmptyRow = true; }
public CacheckApplication(IButtonNameToCommandMapper buttonNameToCommandMapper, IToggleButtonNameToHandlerMapper toggleButtonNameToHandlerMapper, IGuiAndApplicationSynchronizer <ICacheckApplicationModel> guiAndApplicationSynchronizer, ICacheckApplicationModel model, ITashAccessor tashAccessor, ISimpleLogger simpleLogger, ILogConfiguration logConfiguration ) : base(buttonNameToCommandMapper, toggleButtonNameToHandlerMapper, guiAndApplicationSynchronizer, model) { TashAccessor = tashAccessor; SimpleLogger = simpleLogger; LogConfiguration = logConfiguration; }
public BookDetailLookup(string projectId, Options options = null, ISimpleLogger logger = null) { options = options ?? new Options(); _logger = logger ?? new DebugLogger(); // [START pubsubpaths] _topicName = $"projects/{projectId}/topics/{options.TopicId}"; _subscriptionName = $"projects/{projectId}/subscriptions/{options.SubscriptionId}"; // [END pubsubpaths] _pub = PublisherClient.Create(); _sub = SubscriberClient.Create(); }
public HostForm(ISimpleLogger logger) { this.logger = logger; InitializeComponent(); Load += HostFormLoad; Activated += HostFormActivated; Deactivate += HostFormDeactivate; FormClosing += HostFormFormClosing; trayIcon.MouseClick += TrayIconClick; hotkey = new GlobalHotkey(KeyboardHookKeyDown, Keys.Insert, Keys.Control | Keys.Shift); trayIconContextMenu = new ContextMenuStrip(); trayIconContextMenu.ShowImageMargin = false; var exitItem = trayIconContextMenu.Items.Add("Exit"); exitItem.Click += ExitClick; trayIcon.ContextMenuStrip = trayIconContextMenu; }
static void Main(string[] args) { try { if (args.Length == 0) { WriteInfoMessage(); return; } var logLevel = args.Any(a => a == "-v") ? SimpleLogLevel.Verbose : SimpleLogLevel.Error; Log = new SimpleLogger(logLevel); var fileToAdd = Path.GetFullPath(args[0]); var projectFileIncluder = new ProjectFileIncluder {Log = Log}; projectFileIncluder.IncludeFile(fileToAdd); } catch (Exception e) { Log.Error("Fatal error: {0}\n{1}", e.Message, e.StackTrace); } }
public PhotoMiner(string path, bool scanSubfolders, ISimpleLogger logger) : base(path, scanSubfolders, logger) { }
public Toolkit(ISimpleLogger loggingDevice) { m_logger = loggingDevice; }
/// <summary> /// Initialize the new object of SimpleAccessSettings with default properties. /// </summary> /// <param name="defaultCommandType"> The default <see cref="CommandType"/> of this new object</param> /// <param name="defaultLogger"> The default <see cref="ISimpleLogger"/> implementaion for parent SimpleAccess object</param> public SimpleAccessSettings(CommandType defaultCommandType, ISimpleLogger defaultLogger) { DefaultCommandType = defaultCommandType; DefaultLogger = defaultLogger; }
public MediaMinerBase(string path, bool scanSubfolders, ISimpleLogger logger) { m_path = path; m_scanSubfolders = scanSubfolders; m_logger = logger; }
public UtilServer(ISimpleLogger logger, ManualResetEvent exitHandle) { _logger = logger; _exitHandle = exitHandle; }