Ejemplo n.º 1
0
        protected override void OnUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
        {
            base.OnUnhandledException(sender, e);
            var logger = LogManager.GetLogger("DLab");

            logger.Error(e.Exception);
        }
        public object CreateLog4NetLogger()
        {
            return(new []
            {
                LogManager.GetLogger(typeof(BaseTest)),
                LogManager.GetLogger(typeof(BaseTest)),
                LogManager.GetLogger(typeof(BaseTest)),
                LogManager.GetLogger(typeof(BaseTest)),

                LogManager.GetLogger(typeof(BaseTest)),
                LogManager.GetLogger(typeof(BaseTest)),
                LogManager.GetLogger(typeof(BaseTest)),
                LogManager.GetLogger(typeof(BaseTest)),

                LogManager.GetLogger(typeof(BaseTest)),
                LogManager.GetLogger(typeof(BaseTest)),
                LogManager.GetLogger(typeof(BaseTest)),
                LogManager.GetLogger(typeof(BaseTest)),

                LogManager.GetLogger(typeof(BaseTest)),
                LogManager.GetLogger(typeof(BaseTest)),
                LogManager.GetLogger(typeof(BaseTest)),
                LogManager.GetLogger(typeof(BaseTest)),
            });
        }
Ejemplo n.º 3
0
        protected RemoteCommand()
        {
            Log = LogManager.GetLogger(GetType());
            Disposable.Add(Cleaner);

            Formatter = new JsonMediaTypeFormatter {
                SerializerSettings = JsonHelper.SerializerSettings()
            };
        }
Ejemplo n.º 4
0
        public ProcessViewModel()
        {
            _logger      = LogManager.GetLogger("ShellView");
            ProcessNames = new BindableCollection <ProcessItem>();
            _pid         = Process.GetCurrentProcess().Id;

            _chromeTabs  = new List <ProcessItem>();
            _processList = new List <ProcessItem>();

            _mainCancellationTokenSource = new CancellationTokenSource();
            Task.Run(() => StartChromeTabListenerAsync(_mainCancellationTokenSource.Token));
        }
Ejemplo n.º 5
0
        public static IEnumerable <T> WithCancellation <T>(this IEnumerable <T> en, CancellationToken token)
        {
            var logger = LogManager.GetLogger("Default");

            foreach (var item in en)
            {
//                logger.Debug("[WithCancellation]");

                token.ThrowIfCancellationRequested();
                yield return(item);
            }
        }
Ejemplo n.º 6
0
        public override void Load()
        {
            // log4Net
            Bind <ILog>().ToConstant(LogManager.GetLogger(Assembly.GetEntryAssembly().GetName().Name));

            // Caliburn.Micro
            Bind <IWindowManager>().To <WindowManager>().InSingletonScope();
            Bind <IEventAggregator>().To <EventAggregator>().InSingletonScope();

            // RatTracker
            Bind <WebsocketHandler>().ToSelf().InSingletonScope();
            Bind <Cache>().ToSelf().InSingletonScope();
            Bind <EventBus>().ToSelf().InSingletonScope();
        }
Ejemplo n.º 7
0
        protected override void OnStartup(object sender, StartupEventArgs e)
        {
            base.OnStartup(sender, e);

            var fi = new FileInfo("log4net.config");

            XmlConfigurator.Configure(fi);

            _container = new Container(x =>
            {
                x.For <IWindowManager>().Use <WindowManager>();
                x.For <IEventAggregator>().Singleton().Use <EventAggregator>();
                x.For <IViewModelFactory>().Use <ViewModelFactory>();
                x.For <SettingsViewModel>().Use <SettingsViewModel>();
                x.For <CommandViewModel>().Use <CommandViewModel>().Singleton();
                x.For <ProcessViewModel>().Use <ProcessViewModel>().Singleton();
                x.For <TabViewModel>().Use <TabViewModel>();
                x.For <ClipboardViewModel>().Use <ClipboardViewModel>().Singleton();
                x.For <HyperspaceViewModel>().Use <HyperspaceViewModel>().Singleton();
                x.For <TestViewModel>().Use <TestViewModel>().Singleton();
                x.For <SettingsFolderViewModel>().Use <SettingsFolderViewModel>();
                x.For <SettingsWebViewModel>().Use <SettingsWebViewModel>();
                x.For <SettingsDirViewModel>().Use <SettingsDirViewModel>();
                x.For <SettingsRunnerViewModel>().Use <SettingsRunnerViewModel>();
                x.For <SettingsHyperViewModel>().Use <SettingsHyperViewModel>();
                x.For <FileCommandsRepo>().Use <FileCommandsRepo>().Singleton();
                x.For <FolderSpecRepo>().Use <FolderSpecRepo>().Singleton();
                x.For <WebSpecRepo>().Use <WebSpecRepo>().Singleton();
                x.For <RunnerSpecRepo>().Use <RunnerSpecRepo>().Singleton();
                x.For <HyperjumpRepo>().Use <HyperjumpRepo>().Singleton();
                x.For <CommandResolver>().Use <CommandResolver>().Singleton();
                x.For <ILog>().Use(ctx => LogManager.GetLogger("DLab"));

                x.Scan(s =>
                {
                    s.TheCallingAssembly();
                    s.WithDefaultConventions();
                    s.SingleImplementationsOfInterface();
                    s.RegisterConcreteTypesAgainstTheFirstInterface();
                    s.AddAllTypesOf <ITabViewModel>();
                });
            });

            _container.Configure(x => x.For <IContainer>().Use(_container));

            EnsureDefaultScanFolders();
            DisplayRootViewFor <ShellViewModel>();

//            Debug.WriteLine(_container.WhatDoIHave());
        }
        public void SetUp()
        {
            EventLogAppender eventLogAppender = new EventLogAppender();

            eventLogAppender.LogName         = s_eventLogName;
            eventLogAppender.ApplicationName = s_eventLogSource;
            eventLogAppender.SecurityContext = NullSecurityContext.Instance;
            eventLogAppender.Layout          = new PatternLayout("%m\r\n\r\n");
            BasicConfigurator.Configure(eventLogAppender);

            _logger = LogManager.GetLogger("The Name").Logger;
            _log    = new Log4NetLog(_logger);
            _testEventLog.Clear();
        }
        public void TearDown()
        {
            if (ShowLogOutput)
            {
                var logEvents = MemoryAppender.GetEvents().Reverse().ToArray();
                Console.WriteLine(logEvents.Skip(1).First().RenderedMessage);
                Console.WriteLine(logEvents.First().RenderedMessage);
            }

            MemoryAppender.Clear();
            LogManager.ResetConfiguration();

            Assert.That(LogManager.GetLogger(typeof(DiagnosticOutputRuleMergeDecorator)).IsDebugEnabled, Is.False);
            _serviceLocatorScope.Dispose();
        }
Ejemplo n.º 10
0
 public ILogger GetLogger(string name)
 {
     if (!loggerCache.ContainsKey(name))
     {
         lock (loggerCacheLock)
         {
             if (!loggerCache.ContainsKey(name))
             {
                 var logger = new Log4NetLogger(LogManager.GetLogger(name));
                 loggerCache[name] = logger;
             }
         }
     }
     return(loggerCache[name]);
 }
Ejemplo n.º 11
0
//        public Screen ActiveViewModel => ActiveItem as Screen;

        public ShellViewModel(IWindowManager windowManager, IEventAggregator eventAggregator, IViewModelFactory viewModelFactory)
        {
            _windowManager    = windowManager;
            _eventAggregator  = eventAggregator;
            _viewModelFactory = viewModelFactory;
            _eventAggregator.Subscribe(this);
            _logger = LogManager.GetLogger("ShellView");

            Items.AddRange(new []
            {
                _viewModelFactory.GetViewModel <CommandViewModel>(),
                _viewModelFactory.GetViewModel <ClipboardViewModel>(),
                _viewModelFactory.GetViewModel <ProcessViewModel>(),
                _viewModelFactory.GetViewModel <TestViewModel>() as ITabViewModel
//                _viewModelFactory.GetViewModel<HyperspaceViewModel>() as ITabViewModel
            });
            ActivateCommandModel();
        }
Ejemplo n.º 12
0
        private async Task LoadSelectedPaths()
        {
            var selectedFolders = new ObservableCollection <SelectedFile>();
            await Task.Run(() =>
            {
                try
                {
                    IsBusy = true;

                    if (String.IsNullOrEmpty(this.SourcePath))
                    {
                        LogManager.GetLogger(typeof(MainViewModel)).Warn("couldn't load subfolders because the source path was null or empty");
                    }

                    IEnumerable <string> subfolders = this._logic.GetSubfolders(this.SourcePath);
                    int id = 1;
                    foreach (var folder in subfolders)
                    {
                        selectedFolders.Add(new SelectedFile()
                        {
                            ID          = id,
                            FilePath    = folder,
                            ZipProgress = 0
                        });

                        id++;
                    }
                }
                finally
                {
                    IsBusy = false;
                }
            });

            if (this.SelectedFolders == null)
            {
                this.SelectedFolders = new ObservableCollection <SelectedFile>(selectedFolders);
            }
            else
            {
                this.SelectedFolders.Clear();
                this.SelectedFolders.AddRange(selectedFolders);
            }
        }
Ejemplo n.º 13
0
        public void ActivateProcessModel()
        {
            var processViewModel = (ProcessViewModel)Items.Single(x => x is ProcessViewModel);

            ActivateItem(processViewModel);
#pragma warning disable 4014
            try
            {
                processViewModel.InitialiseProcessListAsync();
            }
            catch (Exception e)
            {
                var logger = LogManager.GetLogger("ShellView");
                logger.Error(e);
//                throw;
            }
#pragma warning restore 4014
            _logger.Debug("ActivateProcessModel: Finished");
        }
Ejemplo n.º 14
0
 /// <summary>
 ///     创建<see cref="ILogger" />。
 /// </summary>
 /// <param name="name"></param>
 /// <returns></returns>
 public ILogger Create(string name)
 {
     return(new Log4NetLogger(LogManager.GetLogger(name)));
 }
Ejemplo n.º 15
0
 /// <summary>
 ///     创建<see cref="ILogger" />。
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 public ILogger Create(Type type)
 {
     return(new Log4NetLogger(LogManager.GetLogger(type)));
 }
Ejemplo n.º 16
0
 /// <summary>
 ///     创建<see cref="ILogger" />。
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <returns></returns>
 public ILogger Create <T>()
 {
     return(new Log4NetLogger(LogManager.GetLogger(typeof(T))));
 }
 public ILogger GetLogger(Type type)
 {
     return(new LogAdapter(LogManager.GetLogger(type)));
 }
Ejemplo n.º 18
0
 public static ILog GetLogger(string name) => new Log(LogManagerLog4Net.GetLogger(name));
Ejemplo n.º 19
0
 public CaliburnLogger(Type t)
 {
     _logger = LogManager.GetLogger(t);
 }
Ejemplo n.º 20
0
        public ILogger CreateLogger(string name)
        {
            StackFrame frame = new StackFrame(3, false);

            return(new Log4NetLogger(LogManager.GetLogger(frame.GetMethod().DeclaringType.Assembly, name)));
        }
Ejemplo n.º 21
0
 public object CreateLog4NetFromString()
 {
     return(LogManager.GetLogger("my-logger_" + (Interlocked.Increment(ref _log4NetStringLogIndex) % 1000)));
 }
Ejemplo n.º 22
0
        public void MethodContainingLog4NetNode()
        {
            var log = Log4NetLogManager.GetLogger(GetType());

            log.Debug("Test");
        }
Ejemplo n.º 23
0
 /// <summary>
 /// 创建指定名称的缓存实例
 /// </summary>
 /// <param name="name">指定名称</param>
 /// <returns></returns>
 protected override ILog CreateLogger(string name)
 {
     log4net.ILog log = LogManager.GetLogger(name);
     return(new Log4NetLog(log));
 }
Ejemplo n.º 24
0
 /// <summary>
 /// Gets the Logger and overgive a filename
 /// </summary>
 /// <param name="filename"></param>
 /// <returns></returns>
 public static ILog GetLogger([CallerFilePath] string filename = "")
 {
     return(LogManager.GetLogger(filename));
 }