Skip to content

Commit

Permalink
debug mineur (logentry session, cooltools unique id)
Browse files Browse the repository at this point in the history
  • Loading branch information
oldbrazil committed May 19, 2022
1 parent 3f6895c commit b00a43b
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 52 deletions.
56 changes: 14 additions & 42 deletions Source/SerialLabs.Logging.AzureTable/ApplicationLogEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,74 +9,46 @@ namespace SerialLabs.Logging.AzureTable
public class ApplicationLogEntity : TableEntity
{
#region Properties
/// <summary>
/// ApplicationName
/// </summary>
[DataMemberAttribute]
public string ApplicationName { get; set; }
/// <summary>
/// EventId
/// </summary>

[DataMemberAttribute]
public int EventId { get; set; }
/// <summary>
/// Priority
/// </summary>

[DataMemberAttribute]
public int Priority { get; set; }
/// <summary>
/// Severity
/// </summary>

[DataMemberAttribute]
public string Severity { get; set; }
/// <summary>
/// Category
/// </summary>

[DataMemberAttribute]
public string Category { get; set; }
/// <summary>
/// Title
/// </summary>

[DataMemberAttribute]
public string Title { get; set; }
/// <summary>
/// MachineName
/// </summary>

[DataMemberAttribute]
public string MachineName { get; set; }
/// <summary>
/// AppDomainName
/// </summary>

[DataMemberAttribute]
public string AppDomainName { get; set; }
/// <summary>
/// ProcessId
/// </summary>

[DataMemberAttribute]
public string ProcessId { get; set; }
/// <summary>
/// ProcessName
/// </summary>
public string SessionId { get; set; }

[DataMemberAttribute]
public string ProcessName { get; set; }
/// <summary>
/// ThreadName
/// </summary>

[DataMemberAttribute]
public string ThreadName { get; set; }
/// <summary>
/// Win32ThreadId
/// </summary>

[DataMemberAttribute]
public string Win32ThreadId { get; set; }
/// <summary>
/// Message
/// </summary>

[DataMemberAttribute]
public string Message { get; set; }
/// <summary>
/// FormattedMessage
/// </summary>

[DataMemberAttribute]
public string FormattedMessage { get; set; }
#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public static ApplicationLogEntity CreateFromLogEntry(LogEntry logEntry, ILogFor
Message = logEntry.Message,
Priority = logEntry.Priority,
ProcessId = logEntry.ProcessId,
SessionId = logEntry.SessionId,
ProcessName = logEntry.ProcessName,
Severity = logEntry.Severity.ToString(),
ThreadName = logEntry.ManagedThreadName,
Expand Down
5 changes: 4 additions & 1 deletion Source/SerialLabs.Logging/LogEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -362,11 +362,13 @@ private void InitializeSessionId()
{
try
{
this.sessionId = HttpContext.Current.Session.SessionID;
this.sessionId = HttpContext.Current.Session.SessionID.Substring(0, 6);
}
catch (Exception e)
{
this.sessionId = e.Message;
if (e is NullReferenceException) this.sessionId = "*null*";

}
}

Expand Down Expand Up @@ -467,6 +469,7 @@ public object Clone()
result.MachineName = this.MachineName;
result.AppDomainName = this.AppDomainName;
result.ProcessId = this.ProcessId;
result.sessionId = this.sessionId;
result.ProcessName = this.ProcessName;
result.ManagedThreadName = this.ManagedThreadName;
result.ActivityId = this.ActivityId;
Expand Down
4 changes: 2 additions & 2 deletions Source/SerialLabs.Web/SerialLabs.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
<Reference Include="System.Web.Helpers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.AspNet.WebPages.3.0.0\lib\net45\System.Web.Helpers.dll</HintPath>
</Reference>
<Reference Include="System.Web.Http, Version=5.2.8.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.AspNet.WebApi.Core.5.2.8\lib\net45\System.Web.Http.dll</HintPath>
<Reference Include="System.Web.Http, Version=5.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\MyBlazon.vNext\packages\Microsoft.AspNet.WebApi.Core.5.1.2\lib\net45\System.Web.Http.dll</HintPath>
</Reference>
<Reference Include="System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\packages\Microsoft.AspNet.Mvc.5.0.0\lib\net45\System.Web.Mvc.dll</HintPath>
Expand Down
2 changes: 1 addition & 1 deletion Source/SerialLabs.Web/packages.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<package id="Microsoft.AspNet.Mvc" version="5.0.0" targetFramework="net451" />
<package id="Microsoft.AspNet.Razor" version="3.0.0" targetFramework="net451" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.8" targetFramework="net451" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.8" targetFramework="net451" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.1.2" targetFramework="net451" />
<package id="Microsoft.AspNet.WebPages" version="3.0.0" targetFramework="net451" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net451" />
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net451" />
Expand Down
12 changes: 6 additions & 6 deletions Source/SerialLabs/CoolTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1718,15 +1718,15 @@ public static string LongToBase(long value)
public static string LongToBase(long value, char[] alphabet)

{
long targetBase = BaseChars.Length;
long targetBase = alphabet.Length;
// Determine exact number of characters to use.
char[] buffer = new char[Math.Max(
(int)Math.Ceiling(Math.Log(value + 1, targetBase)), 1)];

var i = buffer.Length;
do
{
buffer[--i] = BaseChars[value % targetBase];
buffer[--i] = alphabet[value % targetBase];
value = value / targetBase;
}
while (value > 0);
Expand Down Expand Up @@ -1875,13 +1875,13 @@ public string GetBase32UniqueId(byte[] basis, int numDigits)
return ret;
}

public static string ticksTo2080base60()
public static string ticksTo2080base36()
{
return CoolTools.ConvertNumFromBaseToBase.LongToBase(
(new DateTime(2080, 01, 01).Ticks - DateTime.Now.Ticks) / 1000000,
ConvertNumFromBaseToBase.BaseChars36minus);
}
public static string ticksFrom2022base60()
public static string ticksFrom2022base36()
{
return CoolTools.ConvertNumFromBaseToBase.LongToBase(
(DateTime.Now.Ticks- new DateTime(2022, 01, 01).Ticks ) / 1000000,
Expand All @@ -1891,11 +1891,11 @@ public static string ticksFrom2022base60()

public static string generateUIDdesc()
{
return ticksTo2080base60() + "-" + new UniqueIdGenerator().GetBase32UniqueId(6);
return ticksTo2080base36() + "-" + new UniqueIdGenerator().GetBase32UniqueId(6);
}
public static string generateUIDasc()
{
return ticksFrom2022base60() + "-" + new UniqueIdGenerator().GetBase32UniqueId(6);
return ticksFrom2022base36() + "-" + new UniqueIdGenerator().GetBase32UniqueId(6);
}
}
}/// class CoolTools
Expand Down

0 comments on commit b00a43b

Please sign in to comment.