Skip to content

Commit 8d91881

Browse files
committed
Initial start to epilogue
1 parent 6db0ff8 commit 8d91881

10 files changed

+127
-0
lines changed

WPILib.sln

+7
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "vbTest", "dev\vbTest\vbTest
4747
EndProject
4848
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "newcommands", "src\newcommands\newcommands.csproj", "{B09918CC-E71F-4E49-AA20-81559D3583B2}"
4949
EndProject
50+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "epilogue", "src\epilogue\epilogue.csproj", "{B8A9AFC6-01F1-44AC-95D4-0683EF31E117}"
51+
EndProject
5052
Global
5153
GlobalSection(SolutionConfigurationPlatforms) = preSolution
5254
Debug|Any CPU = Debug|Any CPU
@@ -128,6 +130,10 @@ Global
128130
{B09918CC-E71F-4E49-AA20-81559D3583B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
129131
{B09918CC-E71F-4E49-AA20-81559D3583B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
130132
{B09918CC-E71F-4E49-AA20-81559D3583B2}.Release|Any CPU.Build.0 = Release|Any CPU
133+
{B8A9AFC6-01F1-44AC-95D4-0683EF31E117}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
134+
{B8A9AFC6-01F1-44AC-95D4-0683EF31E117}.Debug|Any CPU.Build.0 = Debug|Any CPU
135+
{B8A9AFC6-01F1-44AC-95D4-0683EF31E117}.Release|Any CPU.ActiveCfg = Release|Any CPU
136+
{B8A9AFC6-01F1-44AC-95D4-0683EF31E117}.Release|Any CPU.Build.0 = Release|Any CPU
131137
EndGlobalSection
132138
GlobalSection(NestedProjects) = preSolution
133139
{8F38C25E-641E-47FC-AC0A-0717F2159E8F} = {DB664556-4BF0-4874-8CB6-DC24E60A67AF}
@@ -147,5 +153,6 @@ Global
147153
{CC242C8A-93D4-4083-9C3C-D98A1FE687C1} = {1CA9AB3B-4828-4F07-8C0E-88EF7C5A9ACD}
148154
{A364B855-95A2-435D-A627-A25F1215AB4E} = {1CA9AB3B-4828-4F07-8C0E-88EF7C5A9ACD}
149155
{B09918CC-E71F-4E49-AA20-81559D3583B2} = {DB664556-4BF0-4874-8CB6-DC24E60A67AF}
156+
{B8A9AFC6-01F1-44AC-95D4-0683EF31E117} = {DB664556-4BF0-4874-8CB6-DC24E60A67AF}
150157
EndGlobalSection
151158
EndGlobal
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace Epilogue;
2+
3+
[AttributeUsage(AttributeTargets.Class)]
4+
public sealed class CustomLoggerForAttribute : Attribute {
5+
Type[] Types { get; init; } = [];
6+
}

src/epilogue/EpilogueConfiguration.cs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using NetworkTables;
2+
3+
namespace Epilogue;
4+
5+
public class EpilogueConfiguration {
6+
public DataLogger DataLogger { get; set; } = new NTDataLogger(NetworkTableInstance.Default);
7+
public LogImportance MinimumImportance { get; set; } = LogImportance.Debug;
8+
public ErrorHandler ErrorHandler { get; set; } = new();
9+
public string Root { get; set; } = "Robot";
10+
}

src/epilogue/LogImportance.cs

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace Epilogue;
2+
3+
public enum LogImportance {
4+
Debug,
5+
Info,
6+
Critical,
7+
}

src/epilogue/LogStrategy.cs

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace Epilogue;
2+
3+
public enum LogStrategy {
4+
OptIn,
5+
OptOut,
6+
}

src/epilogue/LoggedAttribute.cs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Epilogue;
2+
3+
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Enum | AttributeTargets.Struct)]
4+
public sealed class LoggedAttribute : Attribute
5+
{
6+
public string Name { get; init; } = "";
7+
public LogStrategy Strategy { get; init; } = LogStrategy.OptOut;
8+
public LogImportance Importance { get; init; } = LogImportance.Debug;
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
using WPIUtil.Sendable;
2+
3+
namespace Epilogue.Logging;
4+
5+
public abstract class ClassSpecificLogger {
6+
private readonly Dictionary<ISendable, ISendableBuilder> m_sendables = [];
7+
8+
protected ClassSpecificLogger(Type loggedType) {
9+
LoggedType = loggedType;
10+
}
11+
12+
public bool Disabled { get; private set; }
13+
14+
public void Disable() {
15+
Disabled = true;
16+
}
17+
18+
public void Reenable() {
19+
Disabled = false;
20+
}
21+
22+
public Type LoggedType { get; }
23+
24+
protected virtual void LogSendable(DataLogger dataLogger, ISendable? sendable) {
25+
if (sendable == null) {
26+
return;
27+
}
28+
29+
var builder = m_sendables.
30+
}
31+
}
32+
33+
public abstract class ClassSpecificLogger<T> : ClassSpecificLogger {
34+
protected ClassSpecificLogger() : base(typeof(T))
35+
{
36+
}
37+
38+
protected abstract void Update(DataLogger dataLogger, T obj);
39+
40+
public void TryUpdate(DataLogger dataLogger, T obj, ErrorHandler errorHandler) {
41+
if (Disabled) {
42+
return;
43+
}
44+
45+
try {
46+
Update(dataLogger, obj);
47+
} catch (Exception e) {
48+
errorHandler(e, this);
49+
}
50+
}
51+
}

src/epilogue/Logging/DataLogger.cs

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Epilogue.Logging;
2+
3+
public interface DataLogger {
4+
public static DataLogger Multi(params DataLogger[] loggers) {
5+
return new MultiLogger(loggers);
6+
}
7+
8+
public DataLogger Lazy => new LazyLogger(this);
9+
}

src/epilogue/NotLoggedAttribute.cs

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
namespace Epilogue;
2+
3+
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Method)]
4+
public sealed class NotLoggedAttribute : Attribute {
5+
}

src/epilogue/epilogue.csproj

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<RootNamespace>Epilogue</RootNamespace>
5+
<AssemblyName>FRC.Epilogue</AssemblyName>
6+
<NoWarn>1591;CA1401;1570</NoWarn>
7+
<EnableNETAnalyzers>true</EnableNETAnalyzers>
8+
<AnalysisLevel>latest</AnalysisLevel>
9+
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
10+
</PropertyGroup>
11+
12+
<ItemGroup>
13+
<ProjectReference Include="..\ntcore\ntcore.csproj" />
14+
<ProjectReference Include="..\wpiutil\wpiutil.csproj" />
15+
</ItemGroup>
16+
17+
</Project>

0 commit comments

Comments
 (0)