コード例 #1
0
		public async Task ConfigureAsync(LogConfig logConfig)
		{
			if (logConfig == null) throw new ArgumentNullException("logConfig");

			var category = logConfig.Category;

			LogMethod method;
			switch (category)
			{
				case LogCategory.Logs:
					method = LogMethod.ConfigureLogs;
					break;
				case LogCategory.Database:
					method = LogMethod.ConfigureDatabase;
					break;
				case LogCategory.Files:
					method = LogMethod.ConfigureFiles;
					break;
				default:
					throw new ArgumentOutOfRangeException();
			}

			var context = category.ToString();
			this.LogRequest(context);
			await this.TransferHandler.WriteAsync(this.Id, (byte)method);

			var data = logConfig.NetworkBuffer;
			this.LogRequest(data, context);
			await this.TransferHandler.WriteAsync(data);
		}
コード例 #2
0
ファイル: MainActivity.cs プロジェクト: Belorus/XLog
 private void InitLogging()
 {
     var formatter = new LineFormatter();
     var logConfig = new LogConfig(formatter);
     var target = new SyncFileTarget(Path.Combine(global::Android.OS.Environment.ExternalStorageDirectory.AbsolutePath, "Log.log"));
     logConfig.AddTarget(LogLevel.Trace, LogLevel.Fatal, target);
     LogManager.Init(logConfig);
 }
コード例 #3
0
ファイル: App.xaml.cs プロジェクト: Belorus/XLog
        private static void InitLogger()
        {
            var formatter = new LineFormatter();
            var logConfig = new LogConfig(formatter);

            logConfig.AddTarget(LogLevel.Trace, LogLevel.Fatal, new SyncFileTarget(Path.Combine(ApplicationData.Current.LocalFolder.Path, @"Log.log")));

            LogManager.Init(logConfig);
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: pifarik/XLog
        private static void InitLogger()
        {
            var formatter = new LineFormatter();
            var logConfig = new LogConfig(formatter);

            logConfig.AddTarget(LogLevel.Trace, LogLevel.Fatal, new SyncFileTarget(@"D:\Log.log"));

            LogManager.Init(logConfig);
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: Belorus/XLog
        private static void InitLogger()
        {
            var categoryRegistry = new LogCategoryRegistrar();
            var formatter = new LineFormatter(new DefaultCategoryFormatter(categoryRegistry));
            var logConfig = new LogConfig(formatter, categoryRegistry);

            logConfig.AddTarget(LogLevel.Trace, LogLevel.Fatal, new ConsoleTarget());

            LogManager.Init(logConfig);
        }
コード例 #6
0
ファイル: Logger.cs プロジェクト: DivinityArcane/lulzBot
        public Logger()
        {
            var info = new ExtensionInfo("Logger", "DivinityArcane; OrrinFox", "1.0");

            Events.AddEvent("log_msg", new Event(this, "handle_log_msg", "Handles logging messages.", ext: info));
            Events.AddCommand("logs", new Command(this, "cmd_logs", "DivinityArcane", 100, "Manages logging.", "[trig]logs enable/disable<br/>[trig]logs blacklist<br/>[trig]logs blacklist add/del #chan", ext: info));

            // Load saved data, if we can.
            Config = Storage.Load<LogConfig>("logging");

            if (Config.BlackList == null)
            {
                Config.Enabled = true;
                Config.BlackList = new List<String>();
                Save();
            }
        }
コード例 #7
0
        internal override int Init(string appId, string channelId)
        {
            int ret = -1;

            app_id_     = appId;
            channel_id_ = channelId.Split(';').GetValue(0).ToString();

            if (null == rtc_engine_)
            {
                rtc_engine_ = AgoraRtcEngine.CreateAgoraRtcEngine();
            }
            LogConfig        log_config     = new LogConfig(agora_sdk_log_file_path_);
            RtcEngineContext rtc_engine_ctx = new RtcEngineContext(app_id_, AREA_CODE.AREA_CODE_GLOB, log_config);

            ret = rtc_engine_.Initialize(rtc_engine_ctx);
            CSharpForm.dump_handler_(VirtualBackground_TAG + "Initialize", ret);

            event_handler_ = new VirtualBackgroundEventHandler(this);
            rtc_engine_.InitEventHandler(event_handler_);

            return(ret);
        }
コード例 #8
0
        private void HandleStartLoggingCommand(byte id, LogConfig config, byte errorStatus)
        {
            if (errorStatus == 0x00)
            {
                _log.Info($"Have successfully started logging for id={id}");
                if (config != null)
                {
                    config.Started = true;
                }
            }
            else
            {
                LogErrorStatus(id, errorStatus, "starting");

                if (config != null)
                {
                    config.ErrorNumber = errorStatus;
                    // TODO:
                    //block.started_cb.call(self, False)
                }
            }
        }
コード例 #9
0
 public bool ProcessRequest(SimpleHttpRequest request, SimpleHttpResponse response)
 {
     LogConfig.Configure();
     try
     {
         return PerformRequest(request, response);
     }
     catch (CorruptApplicationDomainException ae)
     {
         try
         {
             Log.Error(ae);
         }
         finally { Environment.Exit(1); }
         throw;
     }
     catch (Exception error)
     {
         Log.Error(error);
         throw;
     }
 }
コード例 #10
0
ファイル: Program.cs プロジェクト: bloodycoder/ServerCode
 static void Main(string[] args)
 {
     #region Log初始化
     LogConfig config = new LogConfig();
     config.logLevel  = 1;
     config.isConsole = true;
     config.isFile    = false;
     config.filePath  = "./pig.log";
     Log.init(config);
     #endregion
     #region server初始化
     TcpServer tcpServer = new TcpServer();
     tcpServer.Start();
     #endregion
     string key = Console.ReadLine();
     while (key != "q")
     {
         key = Console.ReadLine();
     }
     tcpServer.Stop();
     Console.ReadKey();
 }
コード例 #11
0
ファイル: LogConfigTest.cs プロジェクト: DongDongJu/kmucse
        public static void Config(XmlElement
                                  xmlElement, ref LogConfig logConfig, bool compulsory)
        {
            uint uintValue = new uint();
            int  intValue  = new int();

            Configuration.ConfigBool(xmlElement, "AutoRemove",
                                     ref logConfig.AutoRemove, compulsory);
            if (Configuration.ConfigUint(xmlElement, "BufferSize",
                                         ref uintValue, compulsory))
            {
                logConfig.BufferSize = uintValue;
            }
            Configuration.ConfigString(xmlElement, "Dir",
                                       ref logConfig.Dir, compulsory);
            if (Configuration.ConfigInt(xmlElement, "FileMode",
                                        ref intValue, compulsory))
            {
                logConfig.FileMode = intValue;
            }
            Configuration.ConfigBool(xmlElement, "ForceSync",
                                     ref logConfig.ForceSync, compulsory);
            Configuration.ConfigBool(xmlElement, "InMemory",
                                     ref logConfig.InMemory, compulsory);
            if (Configuration.ConfigUint(xmlElement, "MaxFileSize",
                                         ref uintValue, compulsory))
            {
                logConfig.MaxFileSize = uintValue;
            }
            Configuration.ConfigBool(xmlElement, "NoBuffer",
                                     ref logConfig.NoBuffer, compulsory);
            if (Configuration.ConfigUint(xmlElement, "RegionSize",
                                         ref uintValue, compulsory))
            {
                logConfig.RegionSize = uintValue;
            }
            Configuration.ConfigBool(xmlElement, "ZeroOnCreate",
                                     ref logConfig.ZeroOnCreate, compulsory);
        }
コード例 #12
0
		private async void ConfigureFolderTapped(object sender, TappedRoutedEventArgs e)
		{
			var btn = (sender as Button);
			if (btn != null)
			{
				var ctx = btn.DataContext as LogCategoryViewModel;
				if (ctx != null)
				{
					btn.IsEnabled = false;

					try
					{
						var path = Path.Combine(new[] { @"C:\Temp\", ctx.Platform.ToString(), ctx.Category.ToString() });

						using (var socket = new StreamSocket())
						{
							await socket.ConnectAsync(new HostName(@"127.0.0.1"), @"11111");

							var handler = new WinRtTransferHandler(socket);
							var requestHeader = new RequestHeader(ctx.Platform, new Version(0, 0, 0, 0), string.Empty, string.Empty);
							var config = new LogConfig(requestHeader, ctx.Category, path);
							await new LogsClientHandler(2, handler).ConfigureAsync(config);

							await handler.CloseAsync();
						}

						ctx.Path = path;
					}
					catch
					{
					}
					finally
					{
						btn.IsEnabled = true;
					}
				}
			}
		}
コード例 #13
0
ファイル: Program.cs プロジェクト: tarik1603/FirmataWebApi
        static void Main(string[] args)
        {
            Trace.Listeners.Add(new Log4netTraceListener());
            LogConfig.ConfigureLogger(Assembly.GetExecutingAssembly().Location);

            if (ServiceShell.ProcessInstallOptions(args))
            {
                return;
            }

            if (Environment.UserInteractive)
            {
                Console.SetWindowSize(Math.Min(120, Console.LargestWindowWidth), Math.Min(20, Console.LargestWindowHeight));
            }

            using (var appCore = new FirmataWebApi.Core.FirmataWebApiCore())
            {
                Service.StartService <Service>(
                    appCore.Start,
                    appCore.Stop,
                    Environment.UserInteractive);
            }
        }
コード例 #14
0
        public static LogConfig AddLogConfig(LogConfig logConfig)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(List <LogConfig>));

            configs.Add(logConfig);

            try
            {
                using (Stream fileStream = new FileStream(configFileName, FileMode.Open))
                {
                    serializer.Serialize(fileStream, configs);

                    Console.WriteLine($"DumbLogger. New log configuration : {logConfig.LogName} was added to config file {configFileName}");
                }
            }
            catch (Exception)
            {
                Console.WriteLine("DumbLogger. Error, It was not possible to update log configuration file");
                throw;
            }

            return(logConfig);
        }
コード例 #15
0
ファイル: Startup.cs プロジェクト: GPORTO95/WEB-PipeOnline
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                //app.UseExceptionHandler("/Home/Error");
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseExceptionHandler("/erro/500");
                app.UseStatusCodePagesWithRedirects("/erro/{0}");
                app.UseHsts();
            }
            app.UseHttpsRedirection();
            app.UseStaticFiles();

            app.UseRouting();

            app.UseAuthentication();
            app.UseAuthorization();

            app.UseGlobalizationConfig();

            app.UseKissLogMiddleware(options => {
                LogConfig.ConfigureKissLog(options, Configuration);
            });

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
                endpoints.MapRazorPages();
            });
        }
コード例 #16
0
ファイル: Program.cs プロジェクト: FlukeFan/LucidDotNet
        public static void Main(string[] args)
        {
            _startupTimer = new Stopwatch();
            _startupTimer.Start();

            IList <string> logSetupMessages = new List <string>();
            var            logConfigFile    = LogConfig.PrepareConfigFile(logSetupMessages);

            if (logConfigFile != null)
            {
                NLogBuilder.ConfigureNLog(logConfigFile);
            }

            var logger = LogManager.GetCurrentClassLogger();

            foreach (var logSetupMessage in logSetupMessages)
            {
                logger.Debug($"log setup: {logSetupMessage}");
            }

            logger.Info($"Logging configured using '{logConfigFile}'");

            try
            {
                CreateWebHostBuilder(args).Build().Run();
            }
            catch (Exception e)
            {
                logger.Fatal(e, $"error from web host");
                throw;
            }
            finally
            {
                logger.Info($"Shutting down logging");
                LogManager.Shutdown();
            }
        }
コード例 #17
0
ファイル: Context.cs プロジェクト: kbabiy/LogCast
        public override void Arrange()
        {
            _config = AppConfig.ChangeByResource(this, "App.config");

            LogConfig.DisableAutoConfig = true;
            if (LogConfig.IsConfigured)
            {
                LogConfig.Reset();
            }

            Target = new DirectLogManager();
            var clientFactory = new LogCastClientFactoryMock();

            LogConfig.BeginConfiguration(Target)
            .WithLogCastClientFactory(clientFactory)
            .End();

            ClientMock                = clientFactory.ConfiguredClient;
            ClientMock.LastLog        = null;
            ClientMock.LastWaitAll    = null;
            ClientMock.WaitAllTimeout = TimeSpan.FromSeconds(1);

            Logger = LogManager.GetLogger();
        }
コード例 #18
0
ファイル: LogConfigTest.cs プロジェクト: DongDongJu/kmucse
 public static void Confirm(XmlElement
                            xmlElement, LogConfig logConfig, bool compulsory)
 {
     Configuration.ConfirmBool(xmlElement, "AutoRemove",
                               logConfig.AutoRemove, compulsory);
     Configuration.ConfirmUint(xmlElement, "BufferSize",
                               logConfig.BufferSize, compulsory);
     Configuration.ConfirmString(xmlElement, "Dir",
                                 logConfig.Dir, compulsory);
     Configuration.ConfirmInt(xmlElement, "FileMode",
                              logConfig.FileMode, compulsory);
     Configuration.ConfirmBool(xmlElement, "ForceSync",
                               logConfig.ForceSync, compulsory);
     Configuration.ConfirmBool(xmlElement, "InMemory",
                               logConfig.InMemory, compulsory);
     Configuration.ConfirmUint(xmlElement, "MaxFileSize",
                               logConfig.MaxFileSize, compulsory);
     Configuration.ConfirmBool(xmlElement, "NoBuffer",
                               logConfig.NoBuffer, compulsory);
     Configuration.ConfirmUint(xmlElement, "RegionSize",
                               logConfig.RegionSize, compulsory);
     Configuration.ConfirmBool(xmlElement, "ZeroOnCreate",
                               logConfig.ZeroOnCreate, compulsory);
 }
コード例 #19
0
        public LogGUI(LogView logView)
        {
            this.logView                = logView;
            this.config                 = logView.config;
            logStyle                    = new GUIStyle();
            logStyle.font               = config.font;
            logStyle.fontSize           = 16;
            logStyle.richText           = true;
            logStyle.wordWrap           = true;
            logStyle.normal.textColor   = config.infoColor;
            logStyle.hover.textColor    = config.warnColor;
            logStyle.active.textColor   = config.warnColor;
            logStyle.onHover.textColor  = config.warnColor;
            logStyle.onActive.textColor = config.warnColor;

            logButtonStyle = new GUIStyle();
            logButtonStyle.normal.textColor = config.infoColor;
            logButtonStyle.font             = config.font;
            logButtonStyle.fontSize         = 16;
            logButtonStyle.richText         = true;
            logButtonStyle.wordWrap         = true;
            logButtonStyle.fixedHeight      = 18;
            logButtonStyle.fixedWidth       = Screen.width;
        }
コード例 #20
0
ファイル: Program.cs プロジェクト: emanuelrichieri/trivia-app
        public static void Main(string[] args)
        {
            LogConfig.Init();
            // add the framework services
            var services = new ServiceCollection();

            services.AddSingleton <IMapperFactory, TriviaMapperFactory>();

            // add StructureMap
            var container = new StructureMap.Container();

            container.Configure(config =>
            {
                // Register stuff in container, using the StructureMap APIs...
                config.Scan(_ =>
                {
                    _.AssemblyContainingType(typeof(Program));
                    _.WithDefaultConventions();
                });
                // Populate the container using the service collection
                config.Populate(services);
            });

            var serviceProvider = container.GetInstance <IServiceProvider>();

            Application.Init();

            var operativeServices  = serviceProvider.GetService <IOperativeServices>();
            var backOfficeServices = serviceProvider.GetService <IBackOfficeServices>();

            TriviaApp   triviaApp   = new TriviaApp(operativeServices, backOfficeServices);
            LogInDialog logInDialog = new LogInDialog(triviaApp);

            logInDialog.Show();
            Application.Run();
        }
コード例 #21
0
        private static bool UpdateLogConfigFile()
        {
            var updated = false;

            //check for log config and create if not existing
            try
            {
                var requiredLogs = new[] { "Bob", "Power", "Asset", "Rachelle", "Arena", "Achievements", "LoadingScreen" };

                var logConfig = new LogConfig();
                if (File.Exists(LogConfigPath))
                {
                    using (var sr = new StreamReader(LogConfigPath))
                    {
                        LogConfig.ConfigItem current = null;
                        string line;
                        while (!sr.EndOfStream && (line = sr.ReadLine()) != null)
                        {
                            var nameMatch = LogConfig.NameRegex.Match(line);
                            if (nameMatch.Success)
                            {
                                if (current != null)
                                {
                                    logConfig.Configitems.Add(current);
                                }
                                current = new LogConfig.ConfigItem(nameMatch.Groups["value"].Value);
                                continue;
                            }
                            if (current == null)
                            {
                                continue;
                            }
                            var logLevelMatch = LogConfig.LogLevelRegex.Match(line);
                            if (logLevelMatch.Success)
                            {
                                current.LogLevel = int.Parse(logLevelMatch.Groups["value"].Value);
                                continue;
                            }

                            var filePrintingMatch = LogConfig.FilePrintingRegex.Match(line);
                            if (filePrintingMatch.Success)
                            {
                                current.FilePrinting = bool.Parse(filePrintingMatch.Groups["value"].Value);
                                continue;
                            }

                            var consolePrintingMatch = LogConfig.ConsolePrintingRegex.Match(line);
                            if (consolePrintingMatch.Success)
                            {
                                current.ConsolePrinting = bool.Parse(consolePrintingMatch.Groups["value"].Value);
                                continue;
                            }

                            var screenPrintingMatch = LogConfig.ScreenPrintingRegex.Match(line);
                            if (screenPrintingMatch.Success)
                            {
                                current.ScreenPrinting = bool.Parse(screenPrintingMatch.Groups["value"].Value);
                                continue;
                            }

                            var verboseMatch = LogConfig.VerboseRegex.Match(line);
                            if (verboseMatch.Success)
                            {
                                current.Verbose = bool.Parse(verboseMatch.Groups["value"].Value);
                            }
                        }
                        if (current != null)
                        {
                            logConfig.Configitems.Add(current);
                        }
                    }
                }

                foreach (var requiredLog in requiredLogs)
                {
                    if (logConfig.Configitems.All(x => x.Name != requiredLog))
                    {
                        logConfig.Configitems.Add(new LogConfig.ConfigItem(requiredLog));
                        Logger.WriteLine("Added " + requiredLog + " to log.config.", "UpdateLogConfig");
                        updated = true;
                    }
                }

                if (logConfig.Configitems.Any(x => !x.FilePrinting || x.ConsolePrinting != Config.Instance.LogConfigConsolePrinting))
                {
                    foreach (var configItem in logConfig.Configitems)
                    {
                        configItem.ResetValues();
                    }
                    updated = true;
                }

                if (updated)
                {
                    using (var sw = new StreamWriter(LogConfigPath))
                    {
                        foreach (var configItem in logConfig.Configitems)
                        {
                            sw.WriteLine("[{0}]", configItem.Name);
                            sw.WriteLine("LogLevel={0}", configItem.LogLevel);
                            sw.WriteLine("FilePrinting={0}", configItem.FilePrinting.ToString().ToLower());
                            sw.WriteLine("ConsolePrinting={0}", configItem.ConsolePrinting.ToString().ToLower());
                            sw.WriteLine("ScreenPrinting={0}", configItem.ScreenPrinting.ToString().ToLower());
                            sw.WriteLine("Verbose={0}", configItem.Verbose.ToString().ToLower());
                        }
                    }
                }
            }
            catch (Exception e)
            {
                if (Helper.UpdateLogConfig)
                {
                    MessageBox.Show(
                        e.Message + "\n\n" + e.InnerException
                        + "\n\n Please manually copy the log.config from the Files directory to \"%LocalAppData%/Blizzard/Hearthstone\".",
                        "Error writing log.config");
                    Application.Current.Shutdown();
                }
            }
            return(updated);
        }
コード例 #22
0
 public LogWriterCsv(LogConfig logConfig) : base(logConfig)
 {
 }
コード例 #23
0
        /// <summary>
        /// Creates the file logger.
        /// </summary>
        private void InitLogger()
        {
            try
            {
                string baseDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Ozeki");
                if (!Directory.Exists(baseDir))
                    Directory.CreateDirectory(baseDir);

                baseDir = Path.Combine(baseDir, "Ozeki Demo Softphone");
                if (!Directory.Exists(baseDir))
                    Directory.CreateDirectory(baseDir);

                string logFilePath = Path.Combine(baseDir, "log.txt");

                var logConfig = new LogConfig(LogLevel.Error) { MediaLogLevel = LogLevel.Debug, CallLogLevel = LogLevel.Information };
                Logger.Attach(new DefaultFileLogger(logFilePath), logConfig);
                Logger.Attach(this, new LogConfig(LogLevel.Error) { CallLogLevel = LogLevel.Information/*, SIPLogLevel = LogLevel.Debug*/ });
                Logger.Open();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Cannot create log file. " + ex.Message);
            }
        }
コード例 #24
0
ファイル: Logz.cs プロジェクト: happy-bits/design-patterns
 public override Logger Create(LogConfig config)
 {
     return(new DatabaseLogger(config.ConnectionString));
 }
コード例 #25
0
ファイル: Logz.cs プロジェクト: happy-bits/design-patterns
 // "Factory method"
 public abstract Logger Create(LogConfig config);
コード例 #26
0
 public void RunBeforeAnyTests()
 {
     LogManager.Configuration = LogConfig.Config();
 }
コード例 #27
0
 public void Initialize(LogConfig config)
 {
     _logConfigFile = (LogConfigFile)config;
 }
コード例 #28
0
 /// <summary>
 /// 根据指定的配置信息,初始化日志组件。
 /// 通常情况下不需要调用,除非不使用默认的配置文件
 /// </summary>
 /// <param name="config">配置信息</param>
 public static void Init(LogConfig config)
 {
     WriterFactory.Init(config);
 }
コード例 #29
0
 public Startup(IConfiguration configuration)
 {
     LogConfig.Configure();
     Configuration = configuration;
 }
コード例 #30
0
 public LogWriterXml(LogConfig logConfig) : base(logConfig)
 {
 }
コード例 #31
0
ファイル: LogConfig.cs プロジェクト: Jetsly/pjsip-csharp
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(LogConfig obj)
 {
     return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
 }
コード例 #32
0
		private async Task GetConfigsAsync(ITransferHandler handler)
		{
			using (var ms = new MemoryStream())
			{
				for (var i = 0; i < _folders.Length; i++)
				{
					var folder = _folders[i];
					var platform = (ClientPlatform)(i / Categories);
					var category = (LogCategory)(i % Platforms);

					var config = new LogConfig(new RequestHeader(platform, RequestHeader.EmptyVersion, string.Empty, string.Empty), category, folder);
					var buffer = config.NetworkBuffer;
					ms.Write(buffer, 0, buffer.Length);
				}

				await handler.WriteAsync(ms.ToArray());
			}
		}
コード例 #33
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="logConfig">The log config</param>
        public Logger(LogConfig logConfig)
        {
            this.Config = logConfig.RealLogConfig;

            LogManagement.Instance().AddLogger(this);
        }
コード例 #34
0
 internal LogWriter(LogConfig logConfig)
 {
     Config      = logConfig;
     logFilePath = Config.LogDirectory + @"\" + Config.LogFileName;
 }
コード例 #35
0
		private bool UpdateLogConfigFile()
		{
			var updated = false;
			//check for log config and create if not existing
			try
			{
				var requiredLogs = new[] {"Zone", "Bob", "Power", "Asset", "Rachelle", "Arena"};

				LogConfig logConfig = new LogConfig();
				if(File.Exists(_logConfigPath))
				{
					using(var sr = new StreamReader(_logConfigPath))
					{
						LogConfig.ConfigItem current = null;
						string line;
						while(!sr.EndOfStream && (line = sr.ReadLine()) != null)
						{
							var nameMatch = LogConfig.NameRegex.Match(line);
							if(nameMatch.Success)
							{
								if(current != null)
									logConfig.Configitems.Add(current);
								current = new LogConfig.ConfigItem(nameMatch.Groups["value"].Value);
								continue;
							}
							if(current == null)
								continue;
							var logLevelMatch = LogConfig.LogLevelRegex.Match(line);
							if(logLevelMatch.Success)
							{
								current.LogLevel = int.Parse(logLevelMatch.Groups["value"].Value);
								continue;
							}

							var filePrintingMatch = LogConfig.FilePrintingRegex.Match(line);
							if(filePrintingMatch.Success)
							{
								current.FilePrinting = bool.Parse(filePrintingMatch.Groups["value"].Value);
								continue;
							}

							var consolePrintingMatch = LogConfig.ConsolePrintingRegex.Match(line);
							if(consolePrintingMatch.Success)
							{
								current.ConsolePrinting = bool.Parse(consolePrintingMatch.Groups["value"].Value);
								continue;
							}

							var screenPrintingMatch = LogConfig.ScreenPrintingRegex.Match(line);
							if(screenPrintingMatch.Success)
							{
								current.ScreenPrinting = bool.Parse(screenPrintingMatch.Groups["value"].Value);
								continue;
							}
						}
						if(current != null)
							logConfig.Configitems.Add(current);
					}
				}

				foreach(var requiredLog in requiredLogs)
				{
					if(logConfig.Configitems.All(x => x.Name != requiredLog))
					{
						logConfig.Configitems.Add(new LogConfig.ConfigItem(requiredLog));
						Logger.WriteLine("Added " + requiredLog + " to log.config.", "UpdateLogConfig");
						updated = true;
					}
				}

				if(logConfig.Configitems.Any(x => !x.FilePrinting || x.ConsolePrinting != Config.Instance.LogConfigConsolePrinting))
				{
					foreach(var configItem in logConfig.Configitems)
						configItem.ResetValues();
					updated = true;
				}

				if(updated)
				{
					using(var sw = new StreamWriter(_logConfigPath))
					{
						foreach(var configItem in logConfig.Configitems)
						{
							sw.WriteLine("[{0}]", configItem.Name);
							sw.WriteLine("LogLevel={0}", configItem.LogLevel);
							sw.WriteLine("FilePrinting={0}", configItem.FilePrinting.ToString().ToLower());
							sw.WriteLine("ConsolePrinting={0}", configItem.ConsolePrinting.ToString().ToLower());
							sw.WriteLine("ScreenPrinting={0}", configItem.ScreenPrinting.ToString().ToLower());
						}
					}
				}

			}
			catch(Exception e)
			{
				if(_updatedLogConfig)
				{
					MessageBox.Show(
					                e.Message + "\n\n" + e.InnerException
					                + "\n\n Please manually copy the log.config from the Files directory to \"%LocalAppData%/Blizzard/Hearthstone\".",
					                "Error writing log.config");
					Application.Current.Shutdown();
				}
			}
			return updated;
		}
コード例 #36
0
        internal void CreateClassificationComparisonLogger()
        {
            ILogConfig config = new LogConfig(true, "InferenceClassificationComparisons", "InferenceClassificationComparisons", Path.Combine(ExchangeSetupContext.InstallPath, "Logging\\InferenceClassification\\Comparisons"), new ulong?(ByteQuantifiedSize.FromGB(2UL).ToBytes()), new ulong?(ByteQuantifiedSize.FromMB(10UL).ToBytes()), new TimeSpan?(TimeSpan.FromDays(30.0)), 4096);

            this.classificationComparisonLogger = new InferenceClassificationComparisonLogger(config);
        }
コード例 #37
0
 public ILoggingExecute CreateLogger()
 {
     return(new LoggingExecute(LogConfig.GetLogWriter(path, conStrSettings)));
 }
コード例 #38
0
ファイル: ConsoleLog.cs プロジェクト: glucero1981/BelaxExamen
 public void Initialize(LogConfig config)
 {
     _logConfig = config;
 }
コード例 #39
0
		public void Load(LogConfig[] configs)
		{
			if (configs == null) throw new ArgumentNullException("configs");

			var localConfigs = _mobile.Concat(_ipad).Concat(_winrt).ToList();

			foreach (var config in configs)
			{
				var category = config.Category;
				var platform = config.RequestHeader.ClientPlatform;
				var match = localConfigs.SingleOrDefault(c => c.Category == category && c.Platform == platform);
				if (match != null)
				{
					var path = (config.Folder ?? string.Empty).Trim();
					if (path == string.Empty)
					{
						path = @"N/A";
					}
					match.Path = path;
				}
			}
		}
コード例 #40
0
ファイル: Logz.cs プロジェクト: happy-bits/design-patterns
 public override Logger Create(LogConfig config)
 {
     return(new FileLogger(config.FilePath, config.Rolling));
 }
コード例 #41
0
 protected FileLogBase(LogConfig logConfig) : base(logConfig)
 {
     this.WriteLock   = new SpinLock();
     _timer           = new Timer(FlushCallBack, null, FlushWaitTime, FlushWaitTime);
     _hasDataInStream = NoDataInStream;
 }
コード例 #42
0
 public override void Act()
 {
     LogConfig.BeginConfiguration(_managerMock.Object).WithMaxMessagesPerContext(23);
     base.Act();
 }
コード例 #43
0
 /// <summary>
 /// 设置Log的配置
 /// </summary>
 /// <param name="config"></param>
 public void SetLogConfig(LogConfig config)
 {
     this.mConfig = config;
 }
コード例 #44
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(LogConfig obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
コード例 #45
0
		private async Task ConfigureAsync(ITransferHandler handler, LogCategory category)
		{
			using (var ms = new MemoryStream(await handler.ReadAsync()))
			{
				var logConfig = new LogConfig().Setup(ms);
				_folders[FolderIndex(logConfig.RequestHeader.ClientPlatform, category)] = logConfig.Folder;
			}

			var buffer = new StringBuilder();
			foreach (var folder in _folders)
			{
				buffer.AppendLine(folder);
			}
			using (var sw = new StreamWriter(ConfigName))
			{
				await sw.WriteAsync(buffer.ToString());
			}
		}