GithubHelp home page GithubHelp logo

olsh / resharper-structured-logging Goto Github PK

View Code? Open in Web Editor NEW
136.0 7.0 14.0 840 KB

An extension for ReSharper and Rider that highlights structured logging templates and contains some useful analyzers

License: MIT License

C# 95.80% Batchfile 0.13% PowerShell 1.89% Shell 1.47% Kotlin 0.70%
resharper rider analyzers jetbrains-plugins highlighting serilog nlog structured-logging

resharper-structured-logging's Introduction

ReSharper Structured Logging

Build status Quality Gate Status

An extension for ReSharper and Rider IDE that highlights structured logging templates and contains some useful analyzers

The highlighting is a built-in feature starting from R#/Rider 2021.2, but the extension still contains some useful analyzers that are not (yet) implemented by JetBrains team

At the moment it supports Serilog, NLog, and Microsoft.Extensions.Logging

Installation ReSharper

Look for Structured Logging in ReSharper -> Extension manager.
JetBrains Plugins Repository

Installation Rider

Look for Structured Logging in Settings -> Plugins -> Browse repositories.
JetBrains Plugins Repository

Highlighting

Highlighting

Analyzers

Turning Off Analyzers

Individual analyzers can be disabled as needed either through code comments or by adding a line to a project's .editorconfig file.

Turning Off Via Comments

The analyzer name can be used as-is in a ReSharper comment to disable an analyzer on a per-file or per-line basis. For example:

// ReSharper disable once TemplateIsNotCompileTimeConstantProblem

Turning Off Via .editorconfig

To disable an analyzer for an entire directory, you can add a line to a .editorconfig file (learn more). In this case, the analyzer name needs to be converted to snake_case, prefixed with resharper_ and suffixed with _highlighting. For example:

resharper_template_is_not_compile_time_constant_problem_highlighting = none

Credits

Inspired by SerilogAnalyzer

resharper-structured-logging's People

Contributors

agentschmitt avatar brandondusseau avatar c0shea avatar dependabot[bot] avatar inyutin-maxim avatar matkoch avatar olsh avatar vladyslav-burylov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

resharper-structured-logging's Issues

2019.1 EAP support

Hi,
do you know why the plugin is not available in extension manager in ReSharper 2019.1 EAP?
Could you release a beta for it?
Or can I help somehow with it?

F# Support

There doesn't seem to be any syntax highlighting for F# code, are there any plans to add F# support?
Thanks!

Doesn't work for concatenated string

Very often (almost always) logged messages are long and don't fit on one line, so they have to be split. Unfortunately, that completely breaks the extension:

image

Exception in ComplexObjectDestructureAnalyzer.CheckComplexObjectInTemplate

Hi, just wanted to let you know that there have been many exception reports with the following stack trace recently:

JetBrains Rider 2021.2.1 Build RD-212.5080.71 Date 2021-08-26T12:44:28.230+0000

--- EXCEPTION #1/2 [IndexOutOfRangeException]
Message = “Index was outside the bounds of the array.”
ExceptionPath = Root.InnerException
ClassName = System.IndexOutOfRangeException
HResult = COR_E_INDEXOUTOFRANGE=80131508
Source = ReSharper.Structured.Logging.Rider

StackTraceString = “
  at ReSharper.Structured.Logging.Analyzer.ComplexObjectDestructureAnalyzer.CheckComplexObjectInTemplate(IInvocationExpression element, IHighlightingConsumer consumer) in C:\projects\resharper-structured-logging\src\ReSharper.Structured.Logging\Analyzer\ComplexObjectDestructureAnalyzer.cs:line 61
     at ReSharper.Structured.Logging.Analyzer.ComplexObjectDestructureAnalyzer.Run(IInvocationExpression element, ElementProblemAnalyzerData data, IHighlightingConsumer consumer) in C:\projects\resharper-structured-logging\src\ReSharper.Structured.Logging\Analyzer\ComplexObjectDestructureAnalyzer.cs:line 34
     at JetBrains.ReSharper.Feature.Services.Daemon.ElementProblemAnalyzerRegistrar.ElementAnalyzerDispatcher.Run(ITreeNode element, IHighlightingConsumer consumer)
”

Exception in CompileTimeConstantTemplateAnalyzer

Hello,
There is NPE in analyzer, could you please take a look?

Analyzer 'ReSharper.Structured.Logging.Analyzer.CompileTimeConstantTemplateAnalyzer' threw the following exception: Object reference not set to an instance of an object.

at ReSharper.Structured.Logging.Analyzer.CompileTimeConstantTemplateAnalyzer.Run(IInvocationExpression element, ElementProblemAnalyzerData data, IHighlightingConsumer consumer) in C:\projects\resharper-structured-logging\src\ReSharper.Structured.Logging\Analyzer\CompileTimeConstantTemplateAnalyzer.cs:line 24
at JetBrains.ReSharper.Feature.Services.Daemon.ElementProblemAnalyzerRegistrar.ElementAnalyzerDispatcher.Run(ITreeNode element, IHighlightingConsumer consumer)

Convert to compile time constant codefix should cover more cases

Hi,
The "Convert to compile time constant message template" generally works and produces nice results:
image

Where it falls short is when presented with more challenging (but sadly, more frequent) structured logging bad practice i.e.:

log.InfoFormat("Name:" + name + " age " + age);

No code fix is presented in such case:
image

While it might be tempting to add support for such bad-practices fixes, I'd propose to alternatively allow R# to use it's own "Convert concatenation to interpolation" action:
image

Your plugin somehow prohibits this action from displaying in suggestion list

Would it be feasible to allow R# to propose it's own suggestions/code fixes ?

Using "Convert concatenation to interpolation" followed by your code fix would allow many ill-structured logging calls to be mended

2019.3 support

Can you update the extension to support ReSharper 2019.3 that was released yesterday?

TemplateIsNotCompileTimeConstant should ignore NameOf()

Hiya,

I often have messagetemplates like:

_logger.LogError(e, $"Caught exception in {nameof(PostStock)}");

Where instead of typing PostStock as constant string, I tend to use NameOf which is useful because the name may change.
This could also include SizeOf - but i'm not sure whether that is a compile time variable as NameOf is....
The docs mention 'constants' but still...

Related:

https://github.com/olsh/resharper-structured-logging/blob/f7ac19c8af6d15e5a2314d27a7cd9bef9082a3a1/rules/TemplateIsNotCompileTimeConstantProblem.md

I would love if the warning wouldn't show up in the case of NameOf.

False positive naming warning

  • Rider 2019.3.1
  • Structured Logging 2019.3.1.59
  • Windows 10 x64

The following code

var newItem = 42;
_logger.LogError("Answer is {newItem}", newItem);

emits a warning about property naming (false positive)

Property name 'newItem' does  not naming rules'. Suggested name is 'NewItem'.

The warning disappears if plugin is deactivated.

Support R#/Rider 2020.3

JetBrains released R# and Rider. Please update references and publish new release for you cool plugin

Allow disabling analyzer in .editorconfig

Rider allows disabling specific code inspections on a directory level by setting an option in .editorconfig. It doesn't appear that it's currently possible to use these to disable particular analyzers provided by this plugin.

For example, my team wants to disable the warning for making log messages compile-time constants. As far as I can tell, currently this requires placing the following comment into each affected file.

// ReSharper disable once TemplateIsNotCompileTimeConstantProblem

Is there a solution-wide method to disable this that I haven't been able to find? Is .editorconfig supported without me realizing it? If neither is the case, what would it take to implement support for this? Is it even possible for a plugin to make Rider recognize additional editorconfig options?

Thanks for your time.

Object logging do not works after following structured logging

I have a logging error code


           Logger.Main.LogError($"Api status={statusCode} message={e.Message} uri={uri} {requestId}", new
                    {
                        e.HttpStatusCode,
                        e.StatusCode,
                        e.Message,
                        e.InvalidParameters,
                        e.Details
                    });

After refactoring like structured logging suggest the ode looks like below. Unfortunately, the last parameter anonymous object is not logged anymore. Is this the problem with my Logging implementation or I just missing something?

         Logger.Main.LogError("Api status={StatusCode} message={Message} uri={Uri} {RequestId}", statusCode, e.Message, uri, requestId, new
                    {
                        e.HttpStatusCode,
                        e.StatusCode,
                        e.Message,
                        e.InvalidParameters,
                        e.Details
                    });

Please optimise code in PsiExtensions.GetTemplateParameterName

You can see screenshot from snapshot where Member.GetAttributeInstances method took long time. Most of usages came from PsiExtensions.GetTemplateParameterName and all other ReSharper usages took a little.
There is a special instrument in ReSharper for caching information from attributes. Hope it can help. You can create YourOwnAttributeProvider and mark it with [CodeAnnotationProvider] attribute and inherit CodeAnnotationInfoProvider class. It will take care about attribute information caching.

Here are backtraces
image

Log Properties Naming Style not working

Using 2023.2 EAP 6 the warning for naming style does not work anymore:

image

JetBrains Rider 2023.2 EAP 6
Build #RD-232.8296.16, built on June 26, 2023
Licensed to JetBrains Rider EAP user: Oliver Ehrenmüller
Expiration date: July 26, 2023
Runtime version: 17.0.7+7-b1000.2 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Windows 11.0
.NET Core v7.0.7 x64 (Server GC)
GC: G1 Young Generation, G1 Old Generation
Memory: 16384M
Cores: 24
Registry:
ide.find.use.editor.font=true
ide.experimental.ui=true
ide.images.show.chessboard=true
ide.new.project.model.index.case.sensitivity=true
vcs.empty.toolwindow.show=false

Non-Bundled Plugins:
com.intellij.ideolog (222.1.0.0)
com.intellij.plugins.riderkeymap (201.6251.22)
Abc.MoqComplete.Rider (2023.2.0.1)
com.intellij.resharper.StructuredLogging (2023.2.0.297-eap02)
tanvd.grazi (232.8296.18)
mobi.hsz.idea.gitignore (4.5.1)
com.intellij.plugin.adernov.powershell (2.0.10)

PacalCase?

Are your sure it's called "PacalCase"? I always thought it's PascalCase

Convert to Roslyn Analyzer

Rider/Resharper supports Roslyn analyzers. Roslyn analyzers are now standard and should be used in replace of ReSharper analyzers.

Analyzer 'ReSharper.Structured.Logging.Analyzer.ComplexObjectDestructureAnalyzer' is throwing IndexOutOfBoundException

Could you please take a look at the exception?

Summary: Analyzer 'ReSharper.Structured.Logging.Analyzer.ComplexObjectDestructureAnalyzer' threw the following exception: Index was outside the bounds of the array.

Description:
JetBrains Rider 2021.3 Build RD-213.4631.30 Date 2021-10-08T14:16:31.524+0000

--- EXCEPTION #1/2 [IndexOutOfRangeException]
Message = “Index was outside the bounds of the array.�
ExceptionPath = Root.InnerException
ClassName = System.IndexOutOfRangeException
HResult = COR_E_INDEXOUTOFRANGE=80131508
Source = ReSharper.Structured.Logging.Rider
StackTraceString = “
  at ReSharper.Structured.Logging.Analyzer.ComplexObjectDestructureAnalyzer.CheckComplexObjectInTemplate(IInvocationExpression element, IHighlightingConsumer consumer) in C:\projects\resharper-structured-logging\src\ReSharper.Structured.Logging\Analyzer\ComplexObjectDestructureAnalyzer.cs:line 61
     at ReSharper.Structured.Logging.Analyzer.ComplexObjectDestructureAnalyzer.Run(IInvocationExpression element, ElementProblemAnalyzerData data, IHighlightingConsumer consumer) in C:\projects\resharper-structured-logging\src\ReSharper.Structured.Logging\Analyzer\ComplexObjectDestructureAnalyzer.cs:line 34
     at JetBrains.ReSharper.Feature.Services.Daemon.ElementProblemAnalyzerRegistrar.ElementAnalyzerDispatcher.Run(ITreeNode element, IHighlightingConsumer consumer)
�

--- Outer ---

--- EXCEPTION #2/2 [LoggerException]
Message = “Analyzer 'ReSharper.Structured.Logging.Analyzer.ComplexObjectDestructureAnalyzer' threw the following exception: Index was outside the bounds of the array.�
ExceptionPath = Root
ClassName = JetBrains.Util.LoggerException
InnerException = “Exception #1 at Root.InnerException�
HResult = COR_E_APPLICATION=80131600
StackTraceString = “
  at JetBrains.Util.LoggerBase.Log(LoggingLevel level, String message, Exception ex)
     at JetBrains.Util.Logging.Logger.LogException(String comment, Exception ex)
     at JetBrains.ReSharper.Feature.Services.Daemon.ElementProblemAnalyzerRegistrar.ElementAnalyzerDispatcher.Run(ITreeNode element, IHighlightingConsumer consumer)
     at JetBrains.ReSharper.Daemon.CSharp.Stages.CSharpErrorStageProcess.ProcessAfterInterior(ITreeNode element, IHighlightingConsumer consumer)
     at JetBrains.ReSharper.Psi.RecursiveElementProcessorExtensions.ProcessDescendants(ITreeNode root, IRecursiveElementProcessor processor)
     at JetBrains.ReSharper.Psi.RecursiveElementProcessorExtensions.ProcessThisAndDescendants(ITreeNode root, IRecursiveElementProcessor processor)
     at JetBrains.ReSharper.Daemon.CSharp.Stages.CSharpIncrementalDaemonStageProcessBase.<>c__DisplayClass4_0.<Execute>g__MemberHighlighter|0(ICSharpTypeMemberDeclaration declaration)
     at JetBrains.ReSharper.Psi.Extensions.<>c__DisplayClass0_0.<EnqueueJob>b__0()
     at JetBrains.Application.Threading.Tasks.TaskHost.AccessViolationCatcher(Action action)
     at JetBrains.Application.Threading.Tasks.TaskHost.<>c__DisplayClass36_0.<Create>b__1(Object state)
     at System.Threading.Tasks.Task.Execute()
     at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
     at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
     at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
     at System.Threading.Tasks.Task.ExecuteEntry(Boolean bPreventDoubleExecution)
     at JetBrains.Application.Threading.Tasks.Scheduler.JetScheduler.ExecuteTask(Task task)
     at JetBrains.Application.Threading.Tasks.Scheduler.JetSchedulerThread.EnqueueNextTask()
     at JetBrains.Application.Threading.Tasks.Scheduler.JetSchedulerThread.ThreadPoolProc()
     at JetBrains.Util.Reflection.CallStackAnnotation.CatchAnnotatedInvocation[TClassOfNewFrame](String methodNameOfNewFrame, Action actionToAnnotate)
     at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
     at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
     at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
     at System.Threading.ThreadHelper.ThreadStart()
�


last.action = null

app.eap = true
app.internal = false
app.build = RD-213.4631.30
app.version.major = 2021
app.version.minor = 3
app.build.date = 2021-10-08T14:16:31.524+0000
app.build.date.release = 2021-12-01T00:00:31.524+0000
app.build.date.release = 2021-12-01T00:00:31.524+0000
app.product.code = RD

os.name = Windows 10
os.cpu.arch = amd64
java.version = 11.0.12
java.vm.vendor = JetBrains s.r.o.

UIUtil.isRetina = false
JBUI.isHiDPI() = false
ImageScaleFactor = 1

netcore = false

.NET Framework 4.0.30319.42000

Plugin incompatible with Rider EAP 2021.3

An early access of rider has been released with UWP app debugging support which is nice. The bad news is that the plugin "Structured Logging" is not compatible with the new rider. So it would be nice to see the plugin support for rider 2021.3

Exception in Plugin (2023.2.0.297-eap02)

com.intellij.diagnostic.PluginException: No display name is specified for configurable com.jetbrains.rider.settings.StructuredLoggingPluginOptionsPage in xml file;
specify it using 'displayName' or 'key' attribute to avoid necessity to load the configurable class when Settings dialog is opened [Plugin: com.intellij.resharper.StructuredLogging]
	at com.intellij.openapi.options.ex.ConfigurableWrapper.getDisplayName(ConfigurableWrapper.java:156)
	at com.intellij.openapi.options.ex.Weighted.lambda$static$0(Weighted.java:26)
	at java.base/java.util.TimSort.countRunAndMakeAscending(TimSort.java:360)
	at java.base/java.util.TimSort.sort(TimSort.java:220)
	at java.base/java.util.Arrays.sort(Arrays.java:1307)
	at java.base/java.util.ArrayList.sort(ArrayList.java:1721)
	at com.intellij.openapi.options.ex.SortedConfigurableGroup.buildConfigurables(SortedConfigurableGroup.java:41)
	at com.intellij.openapi.options.SearchableConfigurable$Parent$Abstract.getConfigurables(SearchableConfigurable.java:75)
	at com.intellij.openapi.options.ex.EpBasedConfigurableGroupKt.collect(EpBasedConfigurableGroup.kt:148)
	at com.intellij.openapi.options.ex.EpBasedConfigurableGroupKt.access$collect(EpBasedConfigurableGroup.kt:1)
	at com.intellij.openapi.options.ex.EpBasedConfigurableGroup.<init>(EpBasedConfigurableGroup.kt:110)
	at com.intellij.openapi.options.ex.ConfigurableExtensionPointUtil.getConfigurableGroup(ConfigurableExtensionPointUtil.java:119)
	at com.intellij.ide.actions.ShowSettingsUtilImpl$Companion.getConfigurableGroups(ShowSettingsUtilImpl.kt:48)
	at com.intellij.ide.actions.ShowSettingsUtilImpl.getConfigurableGroups(ShowSettingsUtilImpl.kt)
	at com.intellij.ide.actions.ShowSettingsAction.perform(ShowSettingsAction.java:60)
	at com.intellij.ide.actions.ShowSettingsAction.actionPerformed(ShowSettingsAction.java:47)
	at com.intellij.openapi.actionSystem.ex.ActionUtil.doPerformActionOrShowPopup(ActionUtil.java:339)
	at com.intellij.openapi.keymap.impl.ActionProcessor.performAction(ActionProcessor.java:47)
	at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher$myActionProcessor$1.performAction(IdeKeyEventDispatcher.kt:502)
	at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcherKt.doPerformActionInner$lambda$5$lambda$4(IdeKeyEventDispatcher.kt:865)
	at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:105)
	at com.intellij.openapi.application.TransactionGuardImpl.performUserActivity(TransactionGuardImpl.java:94)
	at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcherKt.doPerformActionInner$lambda$5(IdeKeyEventDispatcher.kt:865)
	at com.intellij.openapi.actionSystem.ex.ActionUtil.performDumbAwareWithCallbacks(ActionUtil.java:362)
	at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcherKt.doPerformActionInner(IdeKeyEventDispatcher.kt:863)
	at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcherKt.access$doPerformActionInner(IdeKeyEventDispatcher.kt:1)
	at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processAction$intellij_platform_ide_impl(IdeKeyEventDispatcher.kt:587)
	at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processAction(IdeKeyEventDispatcher.kt:513)
	at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.processActionOrWaitSecondStroke(IdeKeyEventDispatcher.kt:454)
	at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.inInitState(IdeKeyEventDispatcher.kt:447)
	at com.intellij.openapi.keymap.impl.IdeKeyEventDispatcher.dispatchKeyEvent(IdeKeyEventDispatcher.kt:309)
	at com.intellij.ide.IdeEventQueue.dispatchKeyEvent(IdeEventQueue.kt:617)
	at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.kt:587)
	at com.intellij.ide.IdeEventQueue.access$_dispatchEvent(IdeEventQueue.kt:67)
	at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.compute(IdeEventQueue.kt:369)
	at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.compute(IdeEventQueue.kt:368)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:787)
	at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1.invoke(IdeEventQueue.kt:368)
	at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1.invoke(IdeEventQueue.kt:363)
	at com.intellij.ide.IdeEventQueueKt.performActivity$lambda$1(IdeEventQueue.kt:992)
	at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:113)
	at com.intellij.ide.IdeEventQueueKt.performActivity(IdeEventQueue.kt:992)
	at com.intellij.ide.IdeEventQueue.dispatchEvent$lambda$7(IdeEventQueue.kt:363)
	at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:861)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.kt:405)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
	at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92)

Support for Rider 2021.1

This plugin does not support Rider > 2020.3.2
Is there any reason for that or can you upgrade the dependency to 2021.1

Plugin Installation Error

When trying to update the plugin to the latest revision I'm getting this error message when restarting the IDE:

picture

After restart, the plugin is still shown as needs update.

The IDE I'm using is Rider 2022.2.3.

Incompatibility with ReSharper 2023.3

Hi,
it seems that Structure Logging has compatibility set to be compatible with ReSharper 2023.3 which causes quite unwelcome issues for the customers that have installed ReSharper 2023.3.
Could you please change the compatibility so it won't be available for 2023.3 users?

Possibility for configuring custom InconsistentLogPropertyNaming

Discussed in #50

Originally posted by corey-re-leased November 4, 2021
Hi,

Within our team, we use prefixes to our Log Properties to allow for filtering in Serilog Seq.

This is demonstrated below:
_logger.LogInformation("Starting Execution of {RLS_FunctionName}", functionName);

Unfortunately, this is leading to InconsistentLogPropertyNaming message: suggested name is RlsFunctionName

I was wondering whether you could implement some sort of configuration to exclude some custom LogPropertyNaming patterns?

Thanks,
Corey

Add Subcategory to Issues

Is it possible to add a subcategory to all of the issues? Perhaps something like "Structured Logging Misuse".

If this is something you'd be open to, I'd be glad to try my hand at it and submit a PR.

Structured Logging 2023.2.0.301-eap09

com.intellij.diagnostic.PluginException: No display name is specified for configurable com.jetbrains.rider.settings.StructuredLoggingPluginOptionsPage in xml file;
specify it using 'displayName' or 'key' attribute to avoid necessity to load the configurable class when Settings dialog is opened [Plugin: com.intellij.resharper.StructuredLogging]
at com.intellij.openapi.options.ex.ConfigurableWrapper.getDisplayName(ConfigurableWrapper.java:156)
at com.intellij.openapi.options.ex.Weighted.lambda$static$0(Weighted.java:26)
at java.base/java.util.TimSort.binarySort(TimSort.java:296)
at java.base/java.util.TimSort.sort(TimSort.java:221)
at java.base/java.util.Arrays.sort(Arrays.java:1307)
at java.base/java.util.ArrayList.sort(ArrayList.java:1721)
at com.intellij.openapi.options.ex.SortedConfigurableGroup.buildConfigurables(SortedConfigurableGroup.java:41)
at com.intellij.openapi.options.SearchableConfigurable$Parent$Abstract.getConfigurables(SearchableConfigurable.java:75)
at com.intellij.openapi.options.ex.EpBasedConfigurableGroupKt.collect(EpBasedConfigurableGroup.kt:148)
at com.intellij.openapi.options.ex.EpBasedConfigurableGroupKt.access$collect(EpBasedConfigurableGroup.kt:1)
at com.intellij.openapi.options.ex.EpBasedConfigurableGroup.(EpBasedConfigurableGroup.kt:110)
at com.intellij.openapi.options.ex.ConfigurableExtensionPointUtil.getConfigurableGroup(ConfigurableExtensionPointUtil.java:119)
at com.intellij.ide.actions.ShowSettingsUtilImpl$Companion.getConfigurableGroups(ShowSettingsUtilImpl.kt:48)
at com.intellij.ide.actions.ShowSettingsUtilImpl.getConfigurableGroups(ShowSettingsUtilImpl.kt)
at com.intellij.ide.actions.ShowSettingsAction.perform(ShowSettingsAction.java:60)
at com.intellij.ide.actions.ShowSettingsAction.actionPerformed(ShowSettingsAction.java:47)
at com.intellij.openapi.actionSystem.ex.ActionUtil.doPerformActionOrShowPopup(ActionUtil.java:339)
at com.intellij.openapi.actionSystem.ex.ActionUtil.lambda$performActionDumbAwareWithCallbacks$4(ActionUtil.java:313)
at com.intellij.openapi.actionSystem.ex.ActionUtil.performDumbAwareWithCallbacks(ActionUtil.java:362)
at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAwareWithCallbacks(ActionUtil.java:313)
at com.intellij.openapi.actionSystem.ex.ActionUtil.invokeAction(ActionUtil.java:538)
at com.intellij.ui.popup.ActionPopupStep.performAction(ActionPopupStep.java:261)
at com.intellij.ui.popup.ActionPopupStep.lambda$onChosen$3(ActionPopupStep.java:238)
at com.intellij.ui.popup.AbstractPopup.lambda$dispose$18(AbstractPopup.java:1636)
at com.intellij.openapi.wm.impl.FocusManagerImpl.lambda$doWhenFocusSettlesDown$3(FocusManagerImpl.java:173)
at com.intellij.util.ui.EdtInvocationManager.invokeLaterIfNeeded(EdtInvocationManager.java:33)
at com.intellij.ide.IdeEventQueue.ifFocusEventsInTheQueue(IdeEventQueue.kt:210)
at com.intellij.ide.IdeEventQueue.executeWhenAllFocusEventsLeftTheQueue(IdeEventQueue.kt:176)
at com.intellij.openapi.wm.impl.FocusManagerImpl.doWhenFocusSettlesDown(FocusManagerImpl.java:169)
at com.intellij.openapi.wm.impl.FocusManagerImpl.doWhenFocusSettlesDown(FocusManagerImpl.java:163)
at com.intellij.ui.popup.AbstractPopup.dispose(AbstractPopup.java:1634)
at com.intellij.ui.popup.WizardPopup.dispose(WizardPopup.java:165)
at com.intellij.ui.popup.list.ListPopupImpl.dispose(ListPopupImpl.java:397)
at com.intellij.ui.popup.PopupFactoryImpl$ActionGroupPopup.dispose(PopupFactoryImpl.java:293)
at com.intellij.openapi.util.ObjectTree.runWithTrace(ObjectTree.java:129)
at com.intellij.openapi.util.ObjectTree.executeAll(ObjectTree.java:161)
at com.intellij.openapi.util.Disposer.dispose(Disposer.java:262)
at com.intellij.openapi.util.Disposer.dispose(Disposer.java:250)
at com.intellij.ui.popup.WizardPopup.disposeAllParents(WizardPopup.java:273)
at com.intellij.ui.popup.list.ListPopupImpl.disposePopup(ListPopupImpl.java:499)
at com.intellij.ui.popup.list.ListPopupImpl.handleNextStep(ListPopupImpl.java:526)
at com.intellij.ui.popup.list.ListPopupImpl._handleSelect(ListPopupImpl.java:486)
at com.intellij.ui.popup.list.ListPopupImpl.handleSelect(ListPopupImpl.java:432)
at com.intellij.ui.popup.PopupFactoryImpl$ActionGroupPopup.handleSelect(PopupFactoryImpl.java:305)
at com.intellij.ui.popup.list.ListPopupImpl$MyMouseListener.mouseReleased(ListPopupImpl.java:698)
at java.desktop/java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:298)
at java.desktop/java.awt.Component.processMouseEvent(Component.java:6657)
at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3385)
at com.intellij.ui.popup.list.ListPopupImpl$MyList.processMouseEvent(ListPopupImpl.java:763)
at java.desktop/java.awt.Component.processEvent(Component.java:6422)
at java.desktop/java.awt.Container.processEvent(Container.java:2266)
at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5027)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2324)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4855)
at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4954)
at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4581)
at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4522)
at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2310)
at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2808)
at java.desktop/java.awt.Component.dispatchEvent(Component.java:4855)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:791)
at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:740)
at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:734)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:97)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:764)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:762)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:761)
at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.kt:685)
at com.intellij.ide.IdeEventQueue.dispatchMouseEvent(IdeEventQueue.kt:633)
at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.kt:588)
at com.intellij.ide.IdeEventQueue.access$_dispatchEvent(IdeEventQueue.kt:67)
at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.compute(IdeEventQueue.kt:369)
at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.compute(IdeEventQueue.kt:368)
at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:787)
at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1.invoke(IdeEventQueue.kt:368)
at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1.invoke(IdeEventQueue.kt:363)
at com.intellij.ide.IdeEventQueueKt.performActivity$lambda$1(IdeEventQueue.kt:992)
at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:113)
at com.intellij.ide.IdeEventQueueKt.performActivity(IdeEventQueue.kt:992)
at com.intellij.ide.IdeEventQueue.dispatchEvent$lambda$7(IdeEventQueue.kt:363)
at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:861)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.kt:405)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92)

Include or exclude files by filename pattern

Our team is using the structured logging plugin primarily to support good coding practices with Serilog and MS logging, and I really appreciate the insights and suggestions it provides.

We have a very large monolithic solution (~130 projects), which I wish was not the case, but I mention it because Rider will often take a long time to reindex, etc. after a build. For the same reason, a full rebuild can result in a large build log file:
image

Unfortunately, the plugin's analysis engine doesn't seem to take kindly to these build logs when they are large. About 15 minutes after opening the 12 MB log file in the image above, I get this:
image

Often I'll just go to Task Manager and issue an "End Task" command for Rider (instead of waiting for the JRE to realize it has run out of memory) so I can continue working.

It seems like any one of these build logs that's more than a few hundred KB in size will cause a massive CPU and memory usage spike. The image below shows the IDE's state after opening a 3 MB build log file. This file size didn't cause an out-of-memory condition, but the IDE did show me a "low memory" warning, and it's basically unusable with this file open.
image

Edit: I did end up getting an out-of-memory dialog from Rider a few minutes after I opened this issue. The IDE never did return to a responsive state.

This might not be an issue in and of itself: I don't know how common it is to have build log files of this size, and I don't know if logs in a format that the plugin does recognize are handled more efficiently.

My request is either for Structured Logging to hard-code ignoring JetBrainsLog.ReSharperBuild_*.log (so that the log file just opens in an editor window), or that you provide a way to exclude filenames from consideration by pattern, and not just assume that every file whose name ends with .log should be analyzed.

Exception in plugin on Rider 2023.2

After installing Rider 2023.2 update this error began to appear:

com.intellij.diagnostic.PluginException: No display name is specified for configurable com.jetbrains.rider.settings.StructuredLoggingPluginOptionsPage in xml file;
specify it using 'displayName' or 'key' attribute to avoid necessity to load the configurable class when Settings dialog is opened [Plugin: com.intellij.resharper.StructuredLogging]
	at com.intellij.openapi.options.ex.ConfigurableWrapper.getDisplayName(ConfigurableWrapper.java:156)
	at com.intellij.openapi.options.ex.Weighted.lambda$static$0(Weighted.java:26)
	at java.base/java.util.TimSort.countRunAndMakeAscending(TimSort.java:360)
	at java.base/java.util.TimSort.sort(TimSort.java:220)
	at java.base/java.util.Arrays.sort(Arrays.java:1307)
	at java.base/java.util.ArrayList.sort(ArrayList.java:1721)
	at com.intellij.openapi.options.ex.SortedConfigurableGroup.buildConfigurables(SortedConfigurableGroup.java:41)
	at com.intellij.openapi.options.SearchableConfigurable$Parent$Abstract.getConfigurables(SearchableConfigurable.java:75)
	at com.intellij.openapi.options.ex.EpBasedConfigurableGroupKt.collect(EpBasedConfigurableGroup.kt:148)
	at com.intellij.openapi.options.ex.EpBasedConfigurableGroupKt.access$collect(EpBasedConfigurableGroup.kt:1)
	at com.intellij.openapi.options.ex.EpBasedConfigurableGroup.<init>(EpBasedConfigurableGroup.kt:110)
	at com.intellij.openapi.options.ex.ConfigurableExtensionPointUtil.getConfigurableGroup(ConfigurableExtensionPointUtil.java:119)
	at com.intellij.ide.actions.ShowSettingsUtilImpl$Companion.getConfigurableGroups(ShowSettingsUtilImpl.kt:48)
	at com.intellij.ide.actions.ShowSettingsUtilImpl.getConfigurableGroups(ShowSettingsUtilImpl.kt)
	at com.intellij.ide.actions.ShowSettingsAction.perform(ShowSettingsAction.java:60)
	at com.intellij.ide.actions.ShowSettingsAction.actionPerformed(ShowSettingsAction.java:47)
	at com.intellij.openapi.actionSystem.ex.ActionUtil.doPerformActionOrShowPopup(ActionUtil.java:339)
	at com.intellij.openapi.actionSystem.ex.ActionUtil.lambda$performActionDumbAwareWithCallbacks$4(ActionUtil.java:313)
	at com.intellij.openapi.actionSystem.ex.ActionUtil.performDumbAwareWithCallbacks(ActionUtil.java:362)
	at com.intellij.openapi.actionSystem.ex.ActionUtil.performActionDumbAwareWithCallbacks(ActionUtil.java:313)
	at com.intellij.openapi.actionSystem.impl.ActionMenuItem.lambda$performAction$5(ActionMenuItem.java:300)
	at com.intellij.openapi.wm.impl.FocusManagerImpl.runOnOwnContext(FocusManagerImpl.java:226)
	at com.intellij.openapi.actionSystem.impl.ActionMenuItem.performAction(ActionMenuItem.java:293)
	at com.intellij.openapi.actionSystem.impl.ActionMenuItem.lambda$new$0(ActionMenuItem.java:68)
	at java.desktop/javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1972)
	at com.intellij.openapi.actionSystem.impl.ActionMenuItem.lambda$fireActionPerformed$4(ActionMenuItem.java:115)
	at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:105)
	at com.intellij.openapi.application.TransactionGuardImpl.performUserActivity(TransactionGuardImpl.java:94)
	at com.intellij.openapi.actionSystem.impl.ActionMenuItem.fireActionPerformed(ActionMenuItem.java:115)
	at com.intellij.ui.plaf.beg.BegMenuItemUI.doClick(BegMenuItemUI.java:526)
	at com.intellij.ui.plaf.beg.BegMenuItemUI$MyMouseInputHandler.mouseReleased(BegMenuItemUI.java:558)
	at java.desktop/java.awt.Component.processMouseEvent(Component.java:6657)
	at java.desktop/javax.swing.JComponent.processMouseEvent(JComponent.java:3385)
	at java.desktop/java.awt.Component.processEvent(Component.java:6422)
	at java.desktop/java.awt.Container.processEvent(Container.java:2266)
	at java.desktop/java.awt.Component.dispatchEventImpl(Component.java:5027)
	at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2324)
	at java.desktop/java.awt.Component.dispatchEvent(Component.java:4855)
	at java.desktop/java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4954)
	at java.desktop/java.awt.LightweightDispatcher.processMouseEvent(Container.java:4581)
	at java.desktop/java.awt.LightweightDispatcher.dispatchEvent(Container.java:4522)
	at java.desktop/java.awt.Container.dispatchEventImpl(Container.java:2310)
	at java.desktop/java.awt.Window.dispatchEventImpl(Window.java:2808)
	at java.desktop/java.awt.Component.dispatchEvent(Component.java:4855)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:791)
	at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:740)
	at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:734)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:97)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:764)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:762)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:761)
	at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.kt:685)
	at com.intellij.ide.IdeEventQueue.dispatchMouseEvent(IdeEventQueue.kt:633)
	at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.kt:588)
	at com.intellij.ide.IdeEventQueue.access$_dispatchEvent(IdeEventQueue.kt:67)
	at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.compute(IdeEventQueue.kt:369)
	at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1$1.compute(IdeEventQueue.kt:368)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:787)
	at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1.invoke(IdeEventQueue.kt:368)
	at com.intellij.ide.IdeEventQueue$dispatchEvent$processEventRunnable$1$1.invoke(IdeEventQueue.kt:363)
	at com.intellij.ide.IdeEventQueueKt.performActivity$lambda$1(IdeEventQueue.kt:992)
	at com.intellij.openapi.application.TransactionGuardImpl.performActivity(TransactionGuardImpl.java:113)
	at com.intellij.ide.IdeEventQueueKt.performActivity(IdeEventQueue.kt:992)
	at com.intellij.ide.IdeEventQueue.dispatchEvent$lambda$7(IdeEventQueue.kt:363)
	at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:861)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.kt:405)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
	at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92)

I am using rider on windows 10:

Runtime version: 17.0.7+7-b1000.6 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.

.NET Core v7.0.7 x64 (Server GC)

Implement log rows hiding

Hi!

Can you implement log row hiding, something like this?
Naturally, hiding must be optional and works until pointer isn't on this row.

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.