public void TestSetLevelByLogger() { TestActivateLogging(); Logger logger = (Logger)_module.Logger; IModuleLogger child1 = logger.GetChild("MyChildLogger"); IModuleLogger child2 = logger.GetChild("MyChildLogger", typeof(Object)); IModuleLogger child3 = logger.GetChild("MyOtherChildLogger"); IModuleLogger child4 = logger.GetChild("MyOtherChildLogger", typeof(Object)); Assert.AreEqual(LogLevel.Info, child1.ActiveLevel, "Initial child1 log level"); Assert.AreEqual(LogLevel.Info, child2.ActiveLevel, "Initial child2 log level"); Assert.AreEqual(LogLevel.Info, child3.ActiveLevel, "Initial child3 log level"); Assert.AreEqual(LogLevel.Info, child4.ActiveLevel, "Initial child4 log level"); _loggerManagement.SetLevel(_module.Logger, LogLevel.Debug); Assert.AreEqual(LogLevel.Debug, _module.Logger.ActiveLevel, "New log level"); Assert.AreEqual(LogLevel.Debug, child1.ActiveLevel, "New child1 log level"); Assert.AreEqual(LogLevel.Debug, child2.ActiveLevel, "New child2 log level"); Assert.AreEqual(LogLevel.Debug, child3.ActiveLevel, "New child3 log level"); Assert.AreEqual(LogLevel.Debug, child4.ActiveLevel, "New child4 log level"); _loggerManagement.SetLevel(child3, LogLevel.Error); Assert.AreEqual(LogLevel.Debug, _module.Logger.ActiveLevel, "Third log level"); Assert.AreEqual(LogLevel.Debug, child1.ActiveLevel, "Third child1 log level"); Assert.AreEqual(LogLevel.Debug, child2.ActiveLevel, "Third child2 log level"); Assert.AreEqual(LogLevel.Error, child3.ActiveLevel, "Third child3 log level"); Assert.AreEqual(LogLevel.Error, child4.ActiveLevel, "Third child4 log level"); }
public BrowserApplicationInstance( AppConfig appConfig, BrowserSettings settings, int id, bool isMainInstance, IFileSystemDialog fileSystemDialog, IHashAlgorithm hashAlgorithm, IMessageBox messageBox, IModuleLogger logger, IText text, IUserInterfaceFactory uiFactory, string startUrl) { this.appConfig = appConfig; this.Id = id; this.httpClient = new HttpClient(); this.isMainInstance = isMainInstance; this.fileSystemDialog = fileSystemDialog; this.hashAlgorithm = hashAlgorithm; this.messageBox = messageBox; this.logger = logger; this.settings = settings; this.text = text; this.uiFactory = uiFactory; this.startUrl = startUrl; }
public ApplicationFactory( IApplicationMonitor applicationMonitor, IModuleLogger logger, INativeMethods nativeMethods, IProcessFactory processFactory) { this.applicationMonitor = applicationMonitor; this.logger = logger; this.nativeMethods = nativeMethods; this.processFactory = processFactory; }
public ConfiguredServiceHost(ITypedHostFactory factory, IModuleLogger parentLogger, EndpointCollector endpointCollector, PortConfig portConfig) { _factory = factory; _collector = endpointCollector; _portConfig = portConfig; if (parentLogger != null) { _logger = parentLogger.GetChild("WcfHosting", GetType()); } }
/// <summary> /// Initialize TcpTransmission /// </summary> /// <param name="client">The client.</param> /// <param name="interpreter">The interpreter.</param> /// <param name="logger">Logger used to write exceptions to log</param> public TcpTransmission(TcpClient client, IMessageInterpreter interpreter, IModuleLogger logger) { _interpreter = interpreter; _client = client; _stream = client.GetStream(); _logger = logger; // Assign callbacks to make sure the delegate does get collected by the GC ReadCallback = ReadComplete; SendCallback = SendComplete; }
private LoggerModel Convert(IModuleLogger logger, bool withChildren) { var loggerModel = new LoggerModel { Name = logger.Name, ActiveLevel = logger.ActiveLevel, ChildLogger = withChildren ? logger.Select(Convert).ToArray() : new LoggerModel[0], Parent = logger.Parent == null? null : Convert(logger.Parent, false) }; return loggerModel; }
public LogMessage(IModuleLogger logger, string className, LogLevel level, string message, object[] parameters) { _message = message; _parameters = parameters; // Set properties Logger = logger; Level = level; ClassName = className; Timestamp = DateTime.Now; }
public IConfiguredServiceHost CreateHost(Type contract, HostConfig config, ITypedHostFactory hostFactory, IModuleLogger logger) { var collector = _container.Resolve <EndpointCollector>(); // Create instance and fill using given container var host = new ConfiguredServiceHost(hostFactory, logger, collector, _portConfig); host.Setup(contract, config); return(host); }
/// <summary> /// Set log level of logger by its name /// </summary> public void SetLevel(string name, LogLevel level) { var loggerTree = name.Split('.'); IModuleLogger logger = _loggers[loggerTree[0]]; foreach (var partialName in loggerTree.Skip(1)) { logger = logger.First(l => l.Name.EndsWith(partialName)); } SetLevel(logger, level); }
internal MainWindow(AppSettings appSettings, BrowserSettings settings, IMessageBox messageBox, int id, bool mainInstance, int numWindows, string startUrl, IModuleLogger logger, IText text) { this.appSettings = appSettings; this.messageBox = messageBox; this.logger = logger; this.startUrl = startUrl; this.text = text; this.Id = id; this.mainInstance = mainInstance; this.numWindows = numWindows; this.settings = settings; InitializeComponent(); }
public void Setup() { _loggerManagement.ClearMessages(); _loggerManagement.ActivateLogging(_module); _loggerManagement.SetLevel(_module.Logger, LogLevel.Info); _loggerManagement.MessageReceivedEvent.Reset(); Assert.NotNull(_module.Logger); Assert.AreEqual(typeof(Logger), _module.Logger.GetType()); Assert.AreEqual(_module.Name, _module.Logger.Name); Assert.AreEqual(LogLevel.Info, _module.Logger.ActiveLevel); _logger = _module.Logger; }
public void SetLevelByNameTest(LogLevel initalLevel, LogLevel newLevel) { // get a logger IModuleLogger logger = _host.Logger; // change its loglevel _management.SetLevel(logger.Name, initalLevel); Assert.AreEqual(initalLevel, logger.ActiveLevel, "The logger is not in the inital LogLevel!"); // set the new loglevel _management.SetLevel(logger.Name, newLevel); Assert.True(logger.ActiveLevel == newLevel, "The LogLevel did not change!"); }
private void SetLevelRecursive(IModuleLogger logger, LogLevel level) { var casted = logger as Logger; if (casted == null) { return; } casted.ActiveLevel = level; // The childrens level must be at least the parents level foreach (var child in logger.Where(child => child.ActiveLevel > level)) { SetLevelRecursive(child, level); } }
internal ExternalApplication( IApplicationMonitor applicationMonitor, string executablePath, IModuleLogger logger, INativeMethods nativeMethods, IProcessFactory processFactory, WhitelistApplication settings) { this.applicationMonitor = applicationMonitor; this.executablePath = executablePath; this.logger = logger; this.nativeMethods = nativeMethods; this.instances = new List <ExternalApplicationInstance>(); this.processFactory = processFactory; this.settings = settings; }
public BrowserApplication( AppConfig appConfig, BrowserSettings settings, IMessageBox messageBox, IModuleLogger logger, IText text, IUserInterfaceFactory uiFactory) { this.appConfig = appConfig; this.instances = new List <BrowserApplicationInstance>(); this.logger = logger; this.messageBox = messageBox; this.settings = settings; this.text = text; this.uiFactory = uiFactory; }
internal static SerialPort FromConfig(SerialBinaryConfig config, IModuleLogger logger) { logger.Log(LogLevel.Debug, "ConfigComPort started"); // Create a new _serialPort object with default settings. var serialPort = new SerialPort(config.Port); try { // Allow the user to set the appropriate properties. serialPort.BaudRate = config.BaudRate; serialPort.Parity = config.Parity; serialPort.DataBits = (int)config.DataBits; serialPort.StopBits = config.StopBits; serialPort.Handshake = config.Handshake; // Set the read/write timeouts serialPort.ReadTimeout = config.ReadTimeout; serialPort.WriteTimeout = config.WriteTimeout; serialPort.ReadBufferSize = config.ReadBufferSize; serialPort.WriteBufferSize = config.WriteBufferSize; logger.Log(LogLevel.Debug, "ConfigPort: Opening"); serialPort.Open(); logger.Log(LogLevel.Debug, "ConfigPort: Opened"); return(serialPort); } catch (Exception e) { logger.LogException(LogLevel.Error, e, "Caught exception while trying to configure port '{0}'", config.Port); var msg = new StringBuilder("Known devices:"); foreach (string s in SerialPort.GetPortNames()) { msg.AppendLine().AppendFormat(" Device {0}", s); } logger.Log(LogLevel.Error, msg.ToString()); throw; } }
public void TestGetEnumerator() { TestActivateLogging(); Logger logger = (Logger)_module.Logger; IModuleLogger child1 = logger.GetChild("MyChildLogger"); IModuleLogger child2 = logger.GetChild("MyChildLogger", typeof(Object)); IModuleLogger child3 = logger.GetChild("MyOtherChildLogger"); IModuleLogger child4 = logger.GetChild("MyOtherChildLogger", typeof(Object)); IModuleLogger grandchild1 = child1.GetChild("MyGrandChildLogger", typeof(Object)); IModuleLogger grandchild2 = child1.GetChild("MyOtherGrandChildLogger", typeof(Object)); Assert.AreEqual(1, _loggerManagement.Count(), "Number of main loggers"); Assert.AreEqual(2, logger.Count(), "Number of children"); Assert.AreEqual(2, child1.Count(), "First number of grandchildren"); Assert.AreEqual(0, child3.Count(), "Second number of grandchildren"); }
/// public void Register(TcpListenerConnection listener) { lock (_listeners) { // Steal objects from the first listener if (_protocolInterpreter == null) { _protocolInterpreter = listener.Validator.Interpreter; } if (_logger == null) { _logger = listener.Logger.GetChild(string.Empty, typeof(TcpPortListener)); } _listeners.Add(listener); StartListening(); } }
internal BrowserApplication(AppSettings appSettings, IMessageBox messageBox, bool mainInstance, IModuleLogger logger, IText text) { this.appSettings = appSettings; this.messageBox = messageBox; this.logger = logger; this.text = text; this.instances = new List <BrowserApplicationInstance>(); this.sameWindowRxs = new List <Regex>(); Icon = new BrowserIconResource(); _dispatcher = Dispatcher.CurrentDispatcher; this.WindowsChanged += Instance_WindowsChanged; foreach (var item in appSettings.AllowedUrlRegexps) { Regex rx = new Regex(item, RegexOptions.Compiled | RegexOptions.IgnoreCase); this.sameWindowRxs.Add(rx); } }
public ProctoringController( AppConfig appConfig, IFileSystem fileSystem, IModuleLogger logger, IServerProxy server, IText text, IUserInterfaceFactory uiFactory) { this.appConfig = appConfig; this.fileSystem = fileSystem; this.logger = logger; this.server = server; this.text = text; this.uiFactory = uiFactory; IconResource = new XamlIconResource { Uri = new Uri("pack://application:,,,/SafeExamBrowser.UserInterface.Desktop;component/Images/ProctoringNotification_Inactive.xaml") }; Tooltip = text.Get(TextKey.Notification_ProctoringInactiveTooltip); }
public ConfigurationRepository( ICertificateStore certificateStore, IHashAlgorithm hashAlgorithm, IModuleLogger logger, string executablePath, string programCopyright, string programTitle, string programVersion) { this.certificateStore = certificateStore; this.hashAlgorithm = hashAlgorithm; this.logger = logger; dataParsers = new List <IDataParser>(); dataSerializers = new List <IDataSerializer>(); dataMapper = new DataMapper(); dataValues = new DataValues(executablePath, programCopyright, programTitle, programVersion); resourceLoaders = new List <IResourceLoader>(); resourceSavers = new List <IResourceSaver>(); }
public void TestGetChild() { TestActivateLogging(); Logger logger = (Logger)_module.Logger; IModuleLogger clone = logger.GetChild(null, _module.GetType()); IModuleLogger childA = logger.GetChild(null); IModuleLogger childB = logger.GetChild(null, GetType()); IModuleLogger childC = logger.GetChild(null, typeof(Object)); IModuleLogger childD = logger.GetChild(null, typeof(Object)); Assert.IsTrue(Object.ReferenceEquals(logger, clone), "logger, clone"); Assert.IsFalse(Object.ReferenceEquals(logger, childA), "logger, childA"); Assert.IsTrue(Object.ReferenceEquals(childA, childB), "childA, childB"); Assert.IsFalse(Object.ReferenceEquals(logger, childC), "logger, childC"); Assert.IsFalse(Object.ReferenceEquals(childA, childC), "childA, childC"); Assert.IsTrue(Object.ReferenceEquals(childC, childD), "childC, childD"); IModuleLogger child1 = logger.GetChild("MyChildLogger"); IModuleLogger child2 = logger.GetChild("MyChildLogger", GetType()); IModuleLogger child3 = logger.GetChild("MyChildLogger", typeof(Object)); IModuleLogger child4 = logger.GetChild("MyChildLogger", typeof(Object)); IModuleLogger child5 = logger.GetChild("MyOtherChildLogger"); IModuleLogger child6 = logger.GetChild("MyOtherChildLogger", GetType()); IModuleLogger child7 = logger.GetChild("MyOtherChildLogger", typeof(Object)); IModuleLogger child8 = logger.GetChild("MyOtherChildLogger", typeof(Object)); Assert.IsTrue(Object.ReferenceEquals(child1, child2), "child1, child2"); Assert.IsFalse(Object.ReferenceEquals(child2, child3), "child2, child3"); Assert.IsTrue(Object.ReferenceEquals(child3, child4), "child3, child4"); Assert.IsTrue(Object.ReferenceEquals(child5, child6), "child5, child6"); Assert.IsFalse(Object.ReferenceEquals(child6, child7), "child6, child7"); Assert.IsTrue(Object.ReferenceEquals(child7, child8), "child7, child8"); Assert.IsFalse(Object.ReferenceEquals(child1, child5), "child1, child5"); }
public BrowserApplication( AppConfig appConfig, BrowserSettings settings, IFileSystemDialog fileSystemDialog, IHashAlgorithm hashAlgorithm, INativeMethods nativeMethods, IMessageBox messageBox, IModuleLogger logger, IText text, IUserInterfaceFactory uiFactory) { this.appConfig = appConfig; this.fileSystemDialog = fileSystemDialog; this.hashAlgorithm = hashAlgorithm; this.nativeMethods = nativeMethods; this.instances = new List <BrowserApplicationInstance>(); this.logger = logger; this.messageBox = messageBox; this.settings = settings; this.text = text; this.uiFactory = uiFactory; }
public BrowserApplicationInstance( AppConfig appConfig, BrowserSettings settings, InstanceIdentifier id, bool isMainInstance, IMessageBox messageBox, IModuleLogger logger, IText text, IUserInterfaceFactory uiFactory, string url) { this.appConfig = appConfig; this.Id = id; this.httpClient = new HttpClient(); this.isMainInstance = isMainInstance; this.messageBox = messageBox; this.logger = logger; this.settings = settings; this.text = text; this.uiFactory = uiFactory; this.url = url; }
public BrowserApplicationInstance( AppSettings appSettings, IMessageBox messageBox, int id, bool isMainInstance, int numWindows, string startUrl, IModuleLogger logger, IText text) { this.appSettings = appSettings; this.messageBox = messageBox; this.Id = id; this.isMainInstance = isMainInstance; this.logger = logger; this.text = text; this.startUrl = startUrl; this.settings = new BrowserSettings(); settings.QuitUrl = appSettings.QuitUrl; settings.DownloadDirectory = appSettings.DownloadDirectory; settings.AllowDownloads = true; settings.MainWindow.AllowReloading = appSettings.AllowReload; settings.AdditionalWindow.AllowReloading = appSettings.AllowReload; var instanceLogger = new ModuleLogger(logger, nameof(MainWindow)); window = new MainWindow(appSettings, settings, messageBox, id, isMainInstance, numWindows, startUrl, instanceLogger, text); window.TerminationRequested += () => TerminationRequested?.Invoke(); window.IconChanged += (i) => IconChanged?.Invoke(i); Handle = window.Handle; Icon = new BrowserIconResource(); window.Closing += Control_Closing; window.TitleChanged += Control_TitleChanged; window.PopupRequested += Control_PopupRequested; }
/// <inheritdoc /> public void Initialize(Type contextType, IConfigManager configManager, IModuleLogger logger) { _contextType = contextType; _configManager = configManager; // Add logger Logger = logger; // Load Config _configName = contextType.FullName + ".DbConfig"; Config = _configManager.GetConfiguration <TConfig>(_configName); // If database is empty, fill with TargetModel name if (string.IsNullOrWhiteSpace(Config.Database)) { Config.Database = contextType.Name; } // Create migrations configuration _migrationsConfiguration = CreateDbMigrationsConfiguration(); // Load local migrations _migrations = GetAvailableMigrations(); }
public LogMessage(IModuleLogger logger, string className, LogLevel level, Exception exception, string message, object[] formatParameters) : this(logger, className, level, message, formatParameters) { Exception = exception; }
public ConfigurationRepository(ICertificateStore certificateStore, IHashAlgorithm hashAlgorithm, IModuleLogger logger) { this.certificateStore = certificateStore; this.hashAlgorithm = hashAlgorithm; this.logger = logger; dataParsers = new List <IDataParser>(); dataSerializers = new List <IDataSerializer>(); dataMapper = new DataMapper(); dataProcessor = new DataProcessor(); dataValues = new DataValues(); resourceLoaders = new List <IResourceLoader>(); resourceSavers = new List <IResourceSaver>(); }
/// <inheritdoc /> public void Initialize(Type contextType, IConfigManager configManager, IModuleLogger logger) { ContextType = contextType; }
/// <summary> /// Creates a service model instance /// </summary> /// <param name="clientFactory">ClientFactory to initialize connections</param> /// <param name="logger">Logger for the service model</param> /// <returns>A service model instance</returns> public static IProductServiceModel CreateServiceModel(IWcfClientFactory clientFactory, IModuleLogger logger) { return(new ProductServiceModel(clientFactory, logger)); }