Post Processing


Author
Message
dv1sual
dv1sual
New Member (42 reputation)New Member (42 reputation)New Member (42 reputation)New Member (42 reputation)New Member (42 reputation)New Member (42 reputation)New Member (42 reputation)New Member (42 reputation)New Member (42 reputation)
Group: Forum Members
Posts: 9, Visits: 20
Good morning!

I edited the CustomParser template to adapt LogViewPlus to the type of my logs, and it works fine.
What I did there it just introduces the Priority based on some string in my log lines.

Now I would like to Implement a post-processor where if the message in the log entry contains the word "error" it changes the priority of the line to "Error".

In the CustomParser i would use this:

           newEntry.Priority = "Info";
if (logLine.Contains("error"))
{
newEntry.Priority = "Error";
}


But it's not working in the PostProcessor.
Any hint how do I do it?

Thanks in Advance for any advise!

Edited 4 Years Ago by dv1sual
LogViewPlus Support
LogViewPlus Support
Prestige User (3.9K reputation)Prestige User (3.9K reputation)Prestige User (3.9K reputation)Prestige User (3.9K reputation)Prestige User (3.9K reputation)Prestige User (3.9K reputation)Prestige User (3.9K reputation)Prestige User (3.9K reputation)Prestige User (3.9K reputation)
Group: Moderators
Posts: 1.1K, Visits: 3.7K
Good Morning!  :-)

From your description, this should be working fine.  There should be no problem changing the Priority.  

There are two things I would suggest:

1.  Do not use the 'Message' field, use the 'OriginalLogEntry' field.  The Message field is optional and will contain the result produced by the parser (if any).  The OriginalLogEntry is required and contains the full text of the log entry.

2.  Have you tried debugging your plug-in?  The steps described in our documentation can be used to launch LogViewPlus from within Visual Studio.  If you start LogViewPlus from a debugger, you should see your breakpoints being hit.

Hope that helps.  Please let me know if you have any further questions or issues.

Toby


dv1sual
dv1sual
New Member (42 reputation)New Member (42 reputation)New Member (42 reputation)New Member (42 reputation)New Member (42 reputation)New Member (42 reputation)New Member (42 reputation)New Member (42 reputation)New Member (42 reputation)
Group: Forum Members
Posts: 9, Visits: 20
Hi Toby,

yes, i'm doing the debugging in Visual Studio.
It gave me this:

Error    CS1061    'LogEntry' does not contain a definition for 'Contains' and no accessible extension method 'Contains' accepting a first argument of type 'LogEntry' could be found (are you missing a using directive or an assembly reference?)


I used that code easily in Parser, but not editing the post-processing file.
I'm sorry if this sounds obvious, i just have little knowledge in C#.

Let me know if i can provide more info to being able to help you help me with this.

Thanks!
Edited 4 Years Ago by dv1sual
LogViewPlus Support
LogViewPlus Support
Prestige User (3.9K reputation)Prestige User (3.9K reputation)Prestige User (3.9K reputation)Prestige User (3.9K reputation)Prestige User (3.9K reputation)Prestige User (3.9K reputation)Prestige User (3.9K reputation)Prestige User (3.9K reputation)Prestige User (3.9K reputation)
Group: Moderators
Posts: 1.1K, Visits: 3.7K
That's interesting.  It looks like a compile error rather than a runtime issue.

In your parser 'logLine' is a String.  String objects have a Contains method.

In the finalizer, you receive a LogEntry.  Not a String, but it does contain Strings.  Try newEntry.OriginalLogEntry.Contains().

Hope that helps,

Toby
dv1sual
dv1sual
New Member (42 reputation)New Member (42 reputation)New Member (42 reputation)New Member (42 reputation)New Member (42 reputation)New Member (42 reputation)New Member (42 reputation)New Member (42 reputation)New Member (42 reputation)
Group: Forum Members
Posts: 9, Visits: 20
Hi Toby.

yes, was a compile error.
Now it compiles it, and it runs LogViewPlus, but it actually doesn't work.

But that's my problem, I think somewhere in the Parser.
Would you mind to look at the full Post Processor code and tell me if you think is all right?

using Clearcove.LogViewer.Common;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;

namespace CustomPostProcessor
{

public class MyPostProcessor : ILogPostProcessor
{

public void Modify(LogEntry newEntry)
{

newEntry.Priority = "Info";
if (newEntry.OriginalLogEntry.Contains("test"))
{
newEntry.Priority = "Error";
}

}

}
}


Anything I'm missing that you can spot?

Thanks again for your patience.

L.
Edited 4 Years Ago by dv1sual
LogViewPlus Support
LogViewPlus Support
Prestige User (3.9K reputation)Prestige User (3.9K reputation)Prestige User (3.9K reputation)Prestige User (3.9K reputation)Prestige User (3.9K reputation)Prestige User (3.9K reputation)Prestige User (3.9K reputation)Prestige User (3.9K reputation)Prestige User (3.9K reputation)
Group: Moderators
Posts: 1.1K, Visits: 3.7K
The code looks fine.  When you say it doesn't work - what do you mean?  How is it now working?  Is your code being called?

I would suggest debugging to see if the OriginalLogEntry contains the text you are expecting.

Toby
Edited 4 Years Ago by LogViewPlus Support
dv1sual
dv1sual
New Member (42 reputation)New Member (42 reputation)New Member (42 reputation)New Member (42 reputation)New Member (42 reputation)New Member (42 reputation)New Member (42 reputation)New Member (42 reputation)New Member (42 reputation)
Group: Forum Members
Posts: 9, Visits: 20
Hi Toby,

When I'm saying is not working I mean that when I open up my log, all the lines that contain the word "test" are not changed to "Error" Priority, but they stay in "Info".

I'm compiling and launching it from Visual Studio, and I can see that my parser works fine (the log level are added to the log) but nothing from the PostProcessor side.

Thanks for your help so far.
LogViewPlus Support
LogViewPlus Support
Prestige User (3.9K reputation)Prestige User (3.9K reputation)Prestige User (3.9K reputation)Prestige User (3.9K reputation)Prestige User (3.9K reputation)Prestige User (3.9K reputation)Prestige User (3.9K reputation)Prestige User (3.9K reputation)Prestige User (3.9K reputation)
Group: Moderators
Posts: 1.1K, Visits: 3.7K
Thanks for the update.

When you put a break point in your code, is it being called?  Have you added the post processor to your parser configuration?
dv1sual
dv1sual
New Member (42 reputation)New Member (42 reputation)New Member (42 reputation)New Member (42 reputation)New Member (42 reputation)New Member (42 reputation)New Member (42 reputation)New Member (42 reputation)New Member (42 reputation)
Group: Forum Members
Posts: 9, Visits: 20
Hi Toby,

you're a legend.

I didn't add the post-processor to the parser.
The code is working fine!

Thanks so much for your help, you made my day!

Cheers!
LogViewPlus Support
LogViewPlus Support
Prestige User (3.9K reputation)Prestige User (3.9K reputation)Prestige User (3.9K reputation)Prestige User (3.9K reputation)Prestige User (3.9K reputation)Prestige User (3.9K reputation)Prestige User (3.9K reputation)Prestige User (3.9K reputation)Prestige User (3.9K reputation)
Group: Moderators
Posts: 1.1K, Visits: 3.7K
Glad to that helped.  Thanks for letting me know.  :-)

Toby
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Login

Explore
Messages
Mentions
Search