Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve logging infrastructure - main synchronization from CLP #73

Merged
merged 2 commits into from
Apr 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions ModelCompiler Solution.sln
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.1622
# Visual Studio Version 17
VisualStudioVersion = 17.1.32228.430
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{01D50556-A863-4999-9A5E-13488F9ABFDF}"
ProjectSection(SolutionItems) = preProject
.gitignore = .gitignore
.gitmodules = .gitmodules
Bin\Debug\asp.log = Bin\Debug\asp.log
BuildEngineeringUnits.bat = BuildEngineeringUnits.bat
BuildStandardTypes.bat = BuildStandardTypes.bat
PublishModel.bat = PublishModel.bat
Expand Down
12 changes: 6 additions & 6 deletions ModelCompilerUI.UnitTest/ModelCompilerUI.UnitTest.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\MSTest.TestAdapter.2.2.8\build\net45\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.2.2.8\build\net45\MSTest.TestAdapter.props')" />
<Import Project="..\packages\MSTest.TestAdapter.2.2.9\build\net46\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.2.2.9\build\net46\MSTest.TestAdapter.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
Expand Down Expand Up @@ -58,10 +58,10 @@
<HintPath>..\packages\CommandLineParser.2.8.0\lib\net461\CommandLine.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\MSTest.TestFramework.2.2.8\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
<HintPath>..\packages\MSTest.TestFramework.2.2.9\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\MSTest.TestFramework.2.2.8\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
<HintPath>..\packages\MSTest.TestFramework.2.2.9\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
Expand Down Expand Up @@ -139,8 +139,8 @@
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.2.8\build\net45\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.2.8\build\net45\MSTest.TestAdapter.props'))" />
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.2.8\build\net45\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.2.8\build\net45\MSTest.TestAdapter.targets'))" />
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.2.9\build\net46\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.2.9\build\net46\MSTest.TestAdapter.props'))" />
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.2.9\build\net46\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.2.9\build\net46\MSTest.TestAdapter.targets'))" />
</Target>
<Import Project="..\packages\MSTest.TestAdapter.2.2.8\build\net45\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.2.2.8\build\net45\MSTest.TestAdapter.targets')" />
<Import Project="..\packages\MSTest.TestAdapter.2.2.9\build\net46\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.2.2.9\build\net46\MSTest.TestAdapter.targets')" />
</Project>
4 changes: 4 additions & 0 deletions ModelCompilerUI.UnitTest/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.Logging.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.1" newVersion="6.0.0.1" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" /></startup></configuration>
4 changes: 2 additions & 2 deletions ModelCompilerUI.UnitTest/packages.config
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="CommandLineParser" version="2.8.0" targetFramework="net48" />
<package id="MSTest.TestAdapter" version="2.2.8" targetFramework="net472" />
<package id="MSTest.TestFramework" version="2.2.8" targetFramework="net472" />
<package id="MSTest.TestAdapter" version="2.2.9" targetFramework="net48" />
<package id="MSTest.TestFramework" version="2.2.9" targetFramework="net48" />
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net472" />
<package id="Portable.BouncyCastle" version="1.9.0" targetFramework="net472" />
<package id="System.Buffers" version="4.5.1" targetFramework="net472" />
Expand Down
77 changes: 53 additions & 24 deletions ModelCompilerUI/App.config
Original file line number Diff line number Diff line change
@@ -1,26 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Formats.Asn1" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="BouncyCastle.Crypto" publicKeyToken="0e99375e54769942" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.9.0.0" newVersion="1.9.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
<system.diagnostics>
<sources>
<source name="ModelCompilerUI" switchValue="All" switchType="System.Diagnostics.SourceSwitch">
<listeners>
<add name="LogFile" />
<add name="WarningFile" />
<add name="configConsoleListener" />
<remove name="Default" />
</listeners>
</source>
</sources>
<sharedListeners>
<add name="WarningFile" type="System.Diagnostics.DelimitedListTraceListener" initializeData="OOIMC.warnings.log" traceOutputOptions="None">
<filter type="System.Diagnostics.EventTypeFilter" initializeData="Information" />
</add>
<add name="LogFile" type="System.Diagnostics.DelimitedListTraceListener" initializeData="OOIMC.log" traceOutputOptions="None">
<filter type="System.Diagnostics.EventTypeFilter" initializeData="All" />
</add>
<add name="configConsoleListener" type="System.Diagnostics.ConsoleTraceListener">
<filter type="System.Diagnostics.EventTypeFilter" initializeData="Warning" />
<!--All, Critical, Error, Information, Off, Verbose, Warning-->
</add>
</sharedListeners>
<trace autoflush="true" />
</system.diagnostics>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Formats.Asn1" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="BouncyCastle.Crypto" publicKeyToken="0e99375e54769942" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.9.0.0" newVersion="1.9.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.Logging.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.1" newVersion="6.0.0.1" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
4 changes: 1 addition & 3 deletions ModelCompilerUI/CommandLineSyntax/CompilerOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ internal class CompilerOptions
private const string cgHelp = "Creates the identifier file if it does not exist (used instead of the -c option).";
private const string oHelp = "The output directory for the generated files.";
private const string idHelp = "The first identifier to use when assigning new ids to nodes.";
private const string excludeHeelp = "Comma seperated list of ReleaseStatus values to exclude from output.";
private const string excludeHeelp = "Comma separated list of ReleaseStatus values to exclude from output.";
private const string versionHelp = "Selects the source for the input files. v103 | v104 | v105 are supported.";
private const string useAllowSubtypesHelp = " When subtypes are allowed for a field, C# code with the class name from the model is created instead of ExtensionObject. No effect when subtypes are not allowed.";
private const string mvHelp = "The version of the model to produce.";
Expand Down Expand Up @@ -101,8 +101,6 @@ public class UpdateHeadersOptions

//Opc.Ua.ModelCompiler.exe - d2 < filepath > -c[g] < filepath > -o2 < directorypath >

//-console The output goes to the standard error output (console) instead of error window

// OptionsNames:
//
//InputPath = "input";
Expand Down
63 changes: 63 additions & 0 deletions ModelCompilerUI/Diagnostic/AssemblyTraceSource.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
//__________________________________________________________________________________________________
//
// Copyright (C) 2021, Mariusz Postol LODZ POLAND.
//
// To be in touch join the community at GitHub: https://github.com/mpostol/OPC-UA-OOI/discussions
//__________________________________________________________________________________________________

using System;
using UAOOI.Common.Infrastructure.Diagnostic;
using UAOOI.SemanticData.BuildingErrorsHandling;

namespace OOI.ModelCompilerUI.Diagnostic
{
/// <summary>
/// Class AssemblyTraceSource. Implements the <see cref="ITraceSource" />
/// </summary>
/// <seealso cref="ITraceSource" />
internal class AssemblyTraceSource : IBuildErrorsHandling
{
#region constructors

/// <summary>
/// Returns singleton of the <see cref="IBuildErrorsHandling"/>.
/// </summary>
internal static IBuildErrorsHandling Log => buildErrorsHandling.Value;

/// <summary>
/// Initializes a new instance of the <see cref="AssemblyTraceSource"/> class using a provided implementation of the <see cref="ITraceSource"/>.
/// </summary>
/// <param name="traceEvent">The provided implementation of the <see cref="ITraceSource"/>.</param>
private AssemblyTraceSource(ITraceSource traceSource)
{
this.traceSource = traceSource;
}

#endregion constructors

#region IBuildErrorsHandling

/// <summary>
/// Writes the trace message <see cref="TraceMessage"/>.
/// </summary>
/// <param name="id">A numeric identifier for the event.</param>
/// <param name="traceMessage">The trace message.</param>
public void WriteTraceMessage(TraceMessage traceMessage, int id = 1560515041)
{
traceSource.TraceData(traceMessage.TraceLevel, id, traceMessage.ToString());
if (traceMessage.BuildError.Focus != Focus.Diagnostic)
Errors++;
}

public int Errors { get; private set; } = 0;

#endregion IBuildErrorsHandling

#region private

private ITraceSource traceSource = null;
private static Lazy<IBuildErrorsHandling> buildErrorsHandling = new Lazy<IBuildErrorsHandling>(() => new AssemblyTraceSource(new TraceSourceBase("ModelCompilerUI")));

#endregion private
}
}
26 changes: 26 additions & 0 deletions ModelCompilerUI/Diagnostic/IBuildErrorsHandling.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//__________________________________________________________________________________________________
//
// Copyright (C) 2022, Mariusz Postol LODZ POLAND.
//
// To be in touch join the community at GitHub: https://github.com/mpostol/OPC-UA-OOI/discussions
//__________________________________________________________________________________________________

using UAOOI.SemanticData.BuildingErrorsHandling;

namespace OOI.ModelCompilerUI.Diagnostic
{
internal interface IBuildErrorsHandling
{
/// <summary>
/// Traces the event using <see cref="TraceMessage"/>.
/// </summary>
/// <param name="traceMessage">The message to be send to trace.</param>
void WriteTraceMessage(TraceMessage traceMessage, int id = 1560515041);

/// <summary>
/// Gets the number of traced errors.
/// </summary>
/// <value>The errors.</value>
int Errors { get; }
}
}
Loading