public void pageInit() { this.myLogSetting = new LogSetting(); if (this.myLogSetting.Maintenance == 0) { this.rbbyperiod.Checked = true; this.rbbyrecord.Checked = false; this.txtperiod.Enabled = true; this.txtrecords.Enabled = false; this.i_days = this.myLogSetting.Days; this.txtperiod.Text = this.i_days.ToString(); this.txtrecords.Text = ""; } else { this.rbbyperiod.Checked = false; this.rbbyrecord.Checked = true; this.txtperiod.Enabled = false; this.txtrecords.Enabled = true; this.i_records = this.myLogSetting.RecordNum; this.txtperiod.Text = ""; this.txtrecords.Text = this.i_records.ToString(); } this.i_pagesize = this.myLogSetting.PageSize; this.txtpagesize.Text = this.i_pagesize.ToString(); this.btnsave.Enabled = false; this.groupBox1.Update(); }
public void ArgumentKeysCaseInsensitive() { const string xml = @"<?xml version='1.0' encoding='UTF-8' ?> <logging> <factoryAdapter type='CONSOLE'> <arg key='LeVel1' value='DEBUG' /> <arg key='LEVEL2' value='DEBUG' /> <arg key='level3' value='DEBUG' /> </factoryAdapter> </logging>"; StandaloneConfigurationReader reader = new StandaloneConfigurationReader(xml); LogSetting setting = reader.GetSection(null) as LogSetting; Assert.IsNotNull(setting); Assert.AreEqual(3, setting.Properties.Count); var expectedValue = new[] { "DEBUG" }; CollectionAssert.AreEqual(expectedValue, setting.Properties.GetValues("level1")); CollectionAssert.AreEqual(expectedValue, setting.Properties.GetValues("level2")); CollectionAssert.AreEqual(expectedValue, setting.Properties.GetValues("LEVEL3")); //Assert.AreEqual( 1, setting.Properties.Count ); //Assert.AreEqual( 3, setting.Properties.GetValues("LeVeL").Length ); }
/// <summary> /// Builds a <see cref="ILoggerFactoryAdapter"/> instance from the given <see cref="LogSetting"/> /// using <see cref="Activator"/>. /// </summary> /// <param name="setting"></param> /// <returns>the <see cref="ILoggerFactoryAdapter"/> instance. Is never <c>null</c></returns> public static ILoggerFactoryAdapter BuildLoggerFactoryAdapterFromLogSettings(LogSetting setting) { ArgUtils.AssertNotNull("setting", setting); // already ensured by LogSetting // AssertArgIsAssignable<ILoggerFactoryAdapter>("setting.FactoryAdapterType", setting.FactoryAdapterType // , "Specified FactoryAdapter does not implement {0}. Check implementation of class {1}" // , typeof(ILoggerFactoryAdapter).FullName // , setting.FactoryAdapterType.AssemblyQualifiedName); ILoggerFactoryAdapter adapter = null; ArgUtils.Guard(delegate { if (setting.Properties != null && setting.Properties.Count > 0) { object[] args = { setting.Properties }; adapter = (ILoggerFactoryAdapter)Activator.CreateInstance(setting.FactoryAdapterType, args); } else { adapter = (ILoggerFactoryAdapter)Activator.CreateInstance(setting.FactoryAdapterType); } } , "Unable to create instance of type {0}. Possible explanation is lack of zero arg and single arg Common.Logging.Configuration.NameValueCollection constructors" , setting.FactoryAdapterType.FullName ); // make sure ArgUtils.AssertNotNull("adapter", adapter, "Activator.CreateInstance() returned <null>"); return(adapter); }
public void SunnyDay() { FileInfo resFile = TestResourceLoader.ExportResource(this, ".config", new FileInfo(Path.GetTempFileName() + ".config")); string exePath = resFile.FullName.Substring(0, resFile.FullName.Length - ".config".Length); Assert.IsTrue(resFile.Exists); IInternalConfigSystem prevConfig = null; try { ExeConfigurationSystem ccs = new ExeConfigurationSystem(exePath); prevConfig = ConfigurationUtils.SetConfigurationSystem(ccs, true); LogSetting settings = (LogSetting)ConfigurationManager.GetSection("common/logging"); Assert.AreEqual(typeof(TraceLoggerFactoryAdapter), settings.FactoryAdapterType); Assert.AreEqual("from custom config!", ConfigurationManager.AppSettings["key"]); Assert.IsNull(ConfigurationManager.GetSection("spring/context")); } finally { if (prevConfig != null) { ConfigurationUtils.SetConfigurationSystem(prevConfig, true); } resFile.Delete(); } }
public async Task LogIgnore() { var channel = (ITextChannel)Context.Channel; int removed; using (var uow = _db.UnitOfWork) { var config = uow.GuildConfigs.LogSettingsFor(channel.Guild.Id); LogSetting logSetting = _service.GuildLogSettings.GetOrAdd(channel.Guild.Id, (id) => config.LogSetting); removed = logSetting.IgnoredChannels.RemoveWhere(ilc => ilc.ChannelId == channel.Id); config.LogSetting.IgnoredChannels.RemoveWhere(ilc => ilc.ChannelId == channel.Id); if (removed == 0) { var toAdd = new IgnoredLogChannel { ChannelId = channel.Id }; logSetting.IgnoredChannels.Add(toAdd); config.LogSetting.IgnoredChannels.Add(toAdd); } await uow.CompleteAsync().ConfigureAwait(false); } if (removed == 0) { await ReplyConfirmLocalized("log_ignore", Format.Bold(channel.Mention + "(" + channel.Id + ")")).ConfigureAwait(false); } else { await ReplyConfirmLocalized("log_not_ignore", Format.Bold(channel.Mention + "(" + channel.Id + ")")).ConfigureAwait(false); } }
public async Task LogIgnore() { var channel = (ITextChannel)Context.Channel; int removed; using (var uow = DbHandler.UnitOfWork()) { var config = uow.GuildConfigs.LogSettingsFor(channel.Guild.Id); LogSetting logSetting = GuildLogSettings.GetOrAdd(channel.Guild.Id, (id) => config.LogSetting); removed = logSetting.IgnoredChannels.RemoveWhere(ilc => ilc.ChannelId == channel.Id); config.LogSetting.IgnoredChannels.RemoveWhere(ilc => ilc.ChannelId == channel.Id); if (removed == 0) { var toAdd = new IgnoredLogChannel { ChannelId = channel.Id }; logSetting.IgnoredChannels.Add(toAdd); config.LogSetting.IgnoredChannels.Add(toAdd); } await uow.CompleteAsync().ConfigureAwait(false); } if (removed == 0) { await channel.SendMessageAsync($"🆗 Logging will **now ignore** #⃣ `{channel.Name} ({channel.Id})`").ConfigureAwait(false); } else { await channel.SendMessageAsync($"ℹ️ Logging will **no longer ignore** #⃣ `{channel.Name} ({channel.Id})`").ConfigureAwait(false); } }
public void pageInit() { LogSetting logSetting = new LogSetting(); this.rbAll.Checked = true; this.dtpLogtimeFrom.Enabled = false; this.dtpLogtimeTo.Enabled = false; this.dtpLogtimeFrom.Value = System.DateTime.Now; this.dtpLogtimeTo.Value = System.DateTime.Now; LogSysLog.goPage = 0; this.txtGoPage.Text = ""; this.txtkey.Text = ""; this.txtPageCount.Text = ""; LogSysLog.SaveRange = 0; LogSysLog.nPerPageLogs = logSetting.PageSize; if (LogSysLog.nPerPageLogs == 0) { LogSysLog.nPerPageLogs = 17; } LogSysLog.nTatalLogs = 0; LogSysLog.nCurrentPage = 1; LogSysLog.nTotalPage = 0; this.panellist.Update(); this.btnSearch_Click(this, null); int arg_C9_0 = LogSysLog.nTatalLogs; }
/*---------------------------------------------------------------------------------------------------------------------------------- * Logging *---------------------------------------------------------------------------------------------------------------------------------*/ private questStatus loadLogSettings() { // Initialize questStatus status = null; // Get log settings. LogSetting logSetting = null; LogSettingsMgr logSettingsMgr = new LogSettingsMgr(this.UserSession); status = logSettingsMgr.Read(out logSetting); if (!questStatusDef.IsSuccess(status)) { this._logSetting = new LogSetting(); return(status); } this._logSetting = logSetting; if (this._logSetting.bLogHTTPRequests) { _httpRequestLogsMgr = new HTTPRequestLogsMgr(this.UserSession); } if (this._logSetting.bLogPortal) { _portalRequestLogsMgr = new PortalRequestLogsMgr(this.UserSession); } return(new questStatus(Severity.Success)); }
public Settings() { Direction = new DirectionSetting(); Distance = new DistanceSetting(); Overlap = new OverlapSetting(); Touch = new TouchSetting(); Contain = new ContainSetting(); Equal = new EqualSetting(); Log = new LogSetting(); RsTreeSetting = new RTreeSetting(); RsTreeSetting.SmallM = 10; RsTreeSetting.BigM = 20; //Direction.PositiveOffset = 0.0001; //Direction.RaysPerSquareMeter = 300; //Distance.RoundToZero = 0.00001; //Distance.GlobalThreshold = 3; //Touch.PositiveOffset = 10; //Touch.NegativeOffsetAsRatio = 1; //Equal.GlobalThreshold = 0.50; //Equal.SamplePerSquareMeter = 10; }
public NEventConfig() { Log = new LogSetting(); Hook = new HookSetting(); StorageEngine = new StorageEngineSetting(); SnapShotThreshold = 200; }
public NEventConfig(LogSetting log, HookSetting hook, StorageEngineSetting store, int snapShotThreshold) { Log = log; Hook = hook; StorageEngine = store; SnapShotThreshold = snapShotThreshold; }
static public void StartUp(LogSetting logSetting) { Application.logMessageReceived += UnityLogCallback; StartupTime = System.DateTime.Now.ToString("MM-dd_HH-mm-ss"); LogSetting = logSetting; SetLogPath(LogSetting.LogDir); ms_ThreadWriteFile = new Thread(WriteFileThread); ms_ThreadWriteFile.Start(); }
public static void SetLogSetting(LogSetting logset) { if (logset == LogSet) { return; } LogSet = logset; Debug.Log("Set Axon log setting to " + (logset == LogSetting.Log ? "log" : "no log")); }
private LogLevel GetLogLevel(LogSetting pattern) { var logLevel = pattern.Resource.LogLevel; if (string.IsNullOrWhiteSpace(logLevel)) { return(LogLevel.Debug); } return(LogLevel.FromString(logLevel)); }
private ulong?GetLogProperty(LogSetting l, LogType type) { switch (type) { case LogType.Other: return(l.LogOtherId); case LogType.MessageUpdated: return(l.MessageUpdatedId); case LogType.MessageDeleted: return(l.MessageDeletedId); case LogType.UserJoined: return(l.UserJoinedId); case LogType.UserLeft: return(l.UserLeftId); case LogType.UserBanned: return(l.UserBannedId); case LogType.UserUnbanned: return(l.UserUnbannedId); case LogType.UserUpdated: return(l.UserUpdatedId); case LogType.ChannelCreated: return(l.ChannelCreatedId); case LogType.ChannelDestroyed: return(l.ChannelDestroyedId); case LogType.ChannelUpdated: return(l.ChannelUpdatedId); case LogType.UserPresence: return(l.LogUserPresenceId); case LogType.VoicePresence: return(l.LogVoicePresenceId); case LogType.VoicePresenceTTS: return(l.LogVoicePresenceTTSId); case LogType.UserMuted: return(l.UserMutedId); default: return(null); } }
public void ConsoleShortCut() { const string xml = @"<?xml version='1.0' encoding='UTF-8' ?> <logging> <factoryAdapter type='CONSOLE'/> </logging>"; StandaloneConfigurationReader reader = new StandaloneConfigurationReader(xml); LogSetting setting = reader.GetSection(null) as LogSetting; Assert.IsNotNull(setting); Assert.AreEqual(typeof(ConsoleOutLoggerFactoryAdapter), setting.FactoryAdapterType); }
public Setting(string settingFile) { _settingFile = settingFile; Project = new ProjectSetting(); General = new GeneralSetting(); Interface = new InterfaceSetting(); Theme = new ThemeSetting(); Script = new ScriptSetting(); Log = new LogSetting(); ReadFromFile(); }
private static ITextChannel TryGetLogChannel(IGuild guild, LogSetting logSetting, LogChannelType logChannelType = LogChannelType.Text) { ulong id = 0; switch (logChannelType) { case LogChannelType.Text: id = logSetting.ChannelId; break; case LogChannelType.Voice: id = logSetting.VoicePresenceChannelId; break; case LogChannelType.UserPresence: id = logSetting.UserPresenceChannelId; break; } var channel = guild.GetTextChannel(id); if (channel == null) { using (var uow = DbHandler.UnitOfWork()) { var newLogSetting = uow.GuildConfigs.For(guild.Id).LogSetting; switch (logChannelType) { case LogChannelType.Text: logSetting.IsLogging = false; break; case LogChannelType.Voice: logSetting.LogVoicePresence = false; break; case LogChannelType.UserPresence: logSetting.LogUserPresence = false; break; } GuildLogSettings.AddOrUpdate(guild.Id, newLogSetting, (gid, old) => newLogSetting); uow.Complete(); return(null); } } else { return(channel); } }
public void Init() { CaravanDataSource.ClearAllTablesUseOnlyInsideUnitTestsPlease(); _myApp = new SecApp { Name = "mio_test", Description = "Test Application 1" }; CaravanDataSource.Security.AddApp(_myApp); _myApp2 = new SecApp { Name = "mio_test2", Description = "Test Application 2" }; CaravanDataSource.Security.AddApp(_myApp2); _settingError = new LogSetting() { Days = 30, Enabled = true, MaxEntries = 100 }; CaravanDataSource.Logger.AddSetting(_myApp.Name, LogLevel.Error, _settingError); CaravanDataSource.Logger.AddSetting(_myApp.Name, LogLevel.Fatal, _settingError); CaravanDataSource.Logger.AddSetting(_myApp.Name, LogLevel.Info, _settingError); CaravanDataSource.Logger.AddSetting(_myApp.Name, LogLevel.Debug, _settingError); CaravanDataSource.Logger.AddSetting(_myApp.Name, LogLevel.Warn, _settingError); }
private void btnsave_Click(object sender, System.EventArgs e) { DataTable dataTable = new DataTable(); DataColumn dataColumn = new DataColumn(); dataColumn.DataType = System.Type.GetType("System.String"); dataColumn.ColumnName = "eventid"; dataTable.Columns.Add(dataColumn); dataColumn = new DataColumn(); dataColumn.DataType = System.Type.GetType("System.Int32"); dataColumn.ColumnName = "logflag"; dataTable.Columns.Add(dataColumn); dataColumn = new DataColumn(); dataColumn.DataType = System.Type.GetType("System.Int32"); dataColumn.ColumnName = "mailflag"; dataTable.Columns.Add(dataColumn); foreach (DataGridViewRow dataGridViewRow in (System.Collections.IEnumerable) this.dataGridViewEvent.Rows) { DataRow dataRow = dataTable.NewRow(); dataRow["eventid"] = dataGridViewRow.Cells[6].Value.ToString(); DataGridViewCheckBoxCell dataGridViewCheckBoxCell = (DataGridViewCheckBoxCell)dataGridViewRow.Cells[1]; if ((bool)dataGridViewCheckBoxCell.Value) { dataRow["logflag"] = 1; } else { dataRow["logflag"] = 0; } dataGridViewCheckBoxCell = (DataGridViewCheckBoxCell)dataGridViewRow.Cells[2]; if ((bool)dataGridViewCheckBoxCell.Value) { dataRow["mailflag"] = 1; } else { dataRow["mailflag"] = 0; } dataTable.Rows.Add(dataRow); } bool flag = LogSetting.SetEventInfo(dataTable); if (flag) { ClientAPI.RemoteCall(101, 1, "1", 10000); EcoMessageBox.ShowInfo(EcoLanguage.getMsg(LangRes.OPsucc, new string[0])); } }
private questStatus loadLogSettings() { // Initialize questStatus status = null; // Get log settings. LogSetting logSetting = null; DbLogSettingsMgr dbLogSettingsMgr = new DbLogSettingsMgr(this.UserSession); status = dbLogSettingsMgr.Read(out logSetting); if (!questStatusDef.IsSuccess(status)) { this._logSetting = new LogSetting(); return(status); } this._logSetting = logSetting; return(new questStatus(Severity.Success)); }
/// <summary> /// Verifies that the logFactoryAdapter element appears once in the configuration section. /// </summary> /// <param name="parent">settings of a parent section - atm this must always be null</param> /// <param name="configContext">Additional information about the configuration process.</param> /// <param name="section">The configuration section to apply an XPath query too.</param> /// <returns> /// A <see cref="LogSetting" /> object containing the specified logFactoryAdapter type /// along with user supplied configuration properties. /// </returns> public LogSetting Create(LogSetting parent, object configContext, XmlNode section) { if (parent != null) { throw new ConfigurationException("parent configuration sections are not allowed"); } int logFactoryElementsCount = section.SelectNodes(LOGFACTORYADAPTER_ELEMENT).Count; if (logFactoryElementsCount > 1) { throw new ConfigurationException("Only one <factoryAdapter> element allowed"); } else if (logFactoryElementsCount == 1) { return(ReadConfiguration(section)); } else { return(null); } }
/// <summary> /// 处理异常。 /// </summary> /// <param name="ex">需处理异常信息。</param> public static void HandleException(Exception ex) { if ((ex != null) && LogSetting.ExceptionLogEnabled) { try { if ((((WebBase.Context == null) || System.IO.File.Exists(WebBase.Server.MapPath(WebBase.Request.Path))) || (!(ex is HttpException) || (ex.InnerException == null))) || !(ex.InnerException is FileNotFoundException)) { string path = LogSetting.ExceptionLogFilePath(DateTime.Today); string str = string.Format("Path = {0}\r\nTime = {1}\r\nClientIP = {2}\r\nType = {3}\r\nMessage = {4}\r\nSource = {5}\r\nHelpLink = {6}\r\nReflectionInfo = {7}\r\nStackTrace = {8}" , new object[] { (WebBase.Context != null) ? WebBase.Request.RawUrl : string.Empty , string.Format("{0:yyyy-MM-dd HH:mm:ss}", DateTime.Now) , (WebBase.Context != null) ? ServerVariables.TrueIP : string.Empty , ex.GetType().AssemblyQualifiedName , ex.Message , ex.Source , ex.HelpLink , GetReflectionInfo(ex).Replace("\n", "\n" + new string(' ', 0x18)) , ex.StackTrace.Replace("\n", "\n" + new string(' ', 0x18)) }); log.Fatal(str); if (ex.InnerException != null) { HandleException(ex.InnerException); } } } catch { } } }
public void UpdateSetting_EmptyAppName_Throws() { var update = new LogSetting { Days = 40, Enabled = true, MaxEntries = 50 }; CaravanDataSource.Logger.UpdateSetting("", LogLevel.Info, update); }
private static ITextChannel TryGetLogChannel(IGuild guild, LogSetting logSetting, LogChannelType logChannelType = LogChannelType.Text) { ulong id = 0; switch (logChannelType) { case LogChannelType.Text: id = logSetting.ChannelId; break; case LogChannelType.Voice: id = logSetting.VoicePresenceChannelId; break; case LogChannelType.UserPresence: id = logSetting.UserPresenceChannelId; break; } var channel = guild.GetTextChannel(id); if (channel == null) using (var uow = DbHandler.UnitOfWork()) { var newLogSetting = uow.GuildConfigs.For(guild.Id).LogSetting; switch (logChannelType) { case LogChannelType.Text: logSetting.IsLogging = false; break; case LogChannelType.Voice: logSetting.LogVoicePresence = false; break; case LogChannelType.UserPresence: logSetting.LogUserPresence = false; break; } GuildLogSettings.AddOrUpdate(guild.Id, newLogSetting, (gid, old) => newLogSetting); uow.Complete(); return null; } else return channel; }
public LogSettings() { Settings = new LogSetting[] { }; }
public void pageInit() { DataTable eventList = LogSetting.GetEventList(); this.cbselLog_changeonly = false; this.cbselEmail_changeonly = false; this.dataGridViewEvent.Rows.Clear(); bool flag = true; bool flag2 = true; int num = 0; this.indexFTSE = -1; foreach (DataRow dataRow in eventList.Rows) { string text = (string)dataRow["eventid"]; if (!LogKey.isISGEvent(text) || EcoGlobalVar.gl_supportISG) { string text2 = LogKey.strSeverity(text); string text3 = LogKey.strCategory(text); string text4 = LogKey.strEvent(text); bool flag3 = false; bool flag4 = false; int num2 = System.Convert.ToInt32(dataRow["logflag"]); if (num2 == 1) { flag3 = true; } else { flag = false; } if (!text.Equals("0120062")) { num2 = System.Convert.ToInt32(dataRow["mailflag"]); if (num2 == 1) { flag4 = true; } else { flag2 = false; } } else { this.indexFTSE = num; } this.dataGridViewEvent.Rows.Add(new object[] { num + 1, flag3, flag4, text3, text2, text4, text }); num++; } } if (this.indexFTSE >= 0) { this.dataGridViewEvent.Rows[this.indexFTSE].Cells[2].ReadOnly = true; } if (flag) { if (!this.cbselLog.Checked) { this.cbselLog_changeonly = true; this.cbselLog.Checked = true; } } else { if (this.cbselLog.Checked) { this.cbselLog_changeonly = true; this.cbselLog.Checked = false; } } if (flag2) { if (!this.cbselEmail.Checked) { this.cbselEmail_changeonly = true; this.cbselEmail.Checked = true; return; } } else { if (this.cbselEmail.Checked) { this.cbselEmail_changeonly = true; this.cbselEmail.Checked = false; } } }
public void UpdateSetting_ValidArgs_SettingUpdated() { var update = new LogSetting { Days = 40, Enabled = true, MaxEntries = 50 }; CaravanDataSource.Logger.UpdateSetting(_myApp.Name, LogLevel.Info, update); var q = CaravanDataSource.Logger.GetSettings(_myApp.Name).Where(s => s.AppName == _myApp.Name && s.LogLevel == LogLevel.Info).ToList(); Assert.That(q.Count, Is.EqualTo(1)); Assert.That(q.First().MaxEntries, Is.EqualTo(50)); Assert.That(q.First().Days, Is.EqualTo(40)); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure( IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IEmailService mailService, IOptions <EmailSettings> emailSettings, IFileService fileService, IOptions <LogSettings> logSettings) { /* * public enum LogLevel * { * Debug = 1, * Verbose = 2, * Information = 3, * Warning = 4, * Error = 5, * Critical = 6, * None = int.MaxValue * } */ //File Logs LogSetting fileLogSetting = logSettings.Value.Settings.FirstOrDefault(x => x.Type == LogType.File); if (fileLogSetting != null && fileLogSetting.On) { loggerFactory.AddFileLogger(fileService, fileLogSetting.Level); } //Email Logs LogSetting emailLogSetting = logSettings.Value.Settings.FirstOrDefault(x => x.Type == LogType.Email); if (emailLogSetting != null && emailLogSetting.On) { loggerFactory.AddEmailLogger(mailService, emailSettings, emailLogSetting.Level); } //Development settings if (Environment.IsDevelopment()) { loggerFactory.AddDebug(LogLevel.Information); loggerFactory.AddConsole(Configuration.GetSection("Logging")); } app.UseStaticFiles(); app.UseSpaStaticFiles(); app.UseMvc(routes => { routes.MapRoute( "default", "{controller}/{action=Index}/{id?}"); }); app.UseSpa(spa => { // To learn more about options for serving an Angular SPA from ASP.NET Core, // see https://go.microsoft.com/fwlink/?linkid=864501 spa.Options.SourcePath = "ClientApp"; if (env.IsDevelopment()) { spa.UseAngularCliServer("start"); } }); }
private async Task <ITextChannel> TryGetLogChannel(IGuild guild, LogSetting logSetting, LogType logChannelType) { ulong?id = null; switch (logChannelType) { case LogType.Other: id = logSetting.LogOtherId; break; case LogType.MessageUpdated: id = logSetting.MessageUpdatedId; break; case LogType.MessageDeleted: id = logSetting.MessageDeletedId; break; case LogType.UserJoined: id = logSetting.UserJoinedId; break; case LogType.UserLeft: id = logSetting.UserLeftId; break; case LogType.UserBanned: id = logSetting.UserBannedId; break; case LogType.UserUnbanned: id = logSetting.UserUnbannedId; break; case LogType.UserUpdated: id = logSetting.UserUpdatedId; break; case LogType.ChannelCreated: id = logSetting.ChannelCreatedId; break; case LogType.ChannelDestroyed: id = logSetting.ChannelDestroyedId; break; case LogType.ChannelUpdated: id = logSetting.ChannelUpdatedId; break; case LogType.UserPresence: id = logSetting.LogUserPresenceId; break; case LogType.VoicePresence: id = logSetting.LogVoicePresenceId; break; case LogType.VoicePresenceTTS: id = logSetting.LogVoicePresenceTTSId; break; case LogType.UserMuted: id = logSetting.UserMutedId; break; } if (!id.HasValue || id == 0) { UnsetLogSetting(guild.Id, logChannelType); return(null); } var channel = await guild.GetTextChannelAsync(id.Value).ConfigureAwait(false); if (channel == null) { UnsetLogSetting(guild.Id, logChannelType); return(null); } else { return(channel); } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure( IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IEmailService mailService, IOptions <EmailSettings> emailSettings, IFileService fileService, UnitOfWork unitOfWork, IOptions <LogSettings> logSettings) { /* * public enum LogLevel * { * Debug = 1, * Verbose = 2, * Information = 3, * Warning = 4, * Error = 5, * Critical = 6, * None = int.MaxValue * } */ //database Logs LogSetting dataBaseLogSetting = logSettings.Value.Settings.FirstOrDefault(x => x.Type == LogType.Database); if (dataBaseLogSetting != null && dataBaseLogSetting.On) { loggerFactory.AddDatabaseLogger( app.ApplicationServices.GetRequiredService <IServiceScopeFactory>() .CreateScope() .ServiceProvider, dataBaseLogSetting.Level); } //File Logs LogSetting fileLogSetting = logSettings.Value.Settings.FirstOrDefault(x => x.Type == LogType.File); if (fileLogSetting != null && fileLogSetting.On) { loggerFactory.AddFileLogger(fileService, fileLogSetting.Level); } //Email Logs LogSetting emailLogSetting = logSettings.Value.Settings.FirstOrDefault(x => x.Type == LogType.Email); if (emailLogSetting != null && emailLogSetting.On) { loggerFactory.AddEmailLogger(mailService, emailSettings, emailLogSetting.Level); } //Development settings if (Environment.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); loggerFactory.AddDebug(LogLevel.Information); loggerFactory.AddConsole(Configuration.GetSection("Logging")); app.UseExceptionHandler(errorApp => { errorApp.Run(async context => { context.Response.StatusCode = 500; // or another Status according to Exception Type context.Response.ContentType = "text/html"; IExceptionHandlerFeature error = context.Features.Get <IExceptionHandlerFeature>(); if (error != null) { await context.Response.WriteAsync(error.Error.ToHtml()); } }); }); } else //production { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseAuthentication(); app.UseMiddleware <HttpContextLogging>(); //Bring in Swagger definitions app.UseSwagger(); app.UseSwaggerUI(options => { options.SwaggerEndpoint( "/swagger/v1/swagger.json", "Api and Schema Definitions"); }); app.UseCors(corsPolicyBuilder => corsPolicyBuilder .WithOrigins("http://localhost:57752") .AllowAnyMethod() .AllowAnyHeader() ); app.UseMvc(routes => { routes.MapRoute( "default", "{controller=Home}/{action=Index}/{id?}"); }); }