Merge pull request #4568 from sbwalker/dev

fix #4559 - prevednt Log fields from exceeding column length
This commit is contained in:
Shaun Walker 2024-08-26 12:05:05 -04:00 committed by GitHub
commit c77ded51a9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -48,6 +48,12 @@ namespace Oqtane.Repository
public void AddLog(Log log)
{
if (log.Url.Length > 2048) log.Url = log.Url.Substring(0, 2048);
if (log.Server.Length > 200) log.Server = log.Server.Substring(0, 200);
if (log.Category.Length > 200) log.Category = log.Category.Substring(0, 200);
if (log.Feature.Length > 200) log.Feature = log.Feature.Substring(0, 200);
if (log.Function.Length > 20) log.Function = log.Function.Substring(0, 20);
if (log.Level.Length > 20) log.Level = log.Level.Substring(0, 20);
using var db = _dbContextFactory.CreateDbContext();
db.Log.Add(log);
db.SaveChanges();