Post Processing


Author
Message
dv1sual
dv1sual
Gaining Respect (117 reputation)Gaining Respect (117 reputation)Gaining Respect (117 reputation)Gaining Respect (117 reputation)Gaining Respect (117 reputation)Gaining Respect (117 reputation)Gaining Respect (117 reputation)Gaining Respect (117 reputation)Gaining Respect (117 reputation)
Group: Forum Members
Posts: 10, Visits: 22
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 5 Years Ago by dv1sual
Replies
LogViewPlus Support
LogViewPlus Support
Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)
Group: Moderators
Posts: 1.2K, Visits: 4.3K
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
Gaining Respect (117 reputation)Gaining Respect (117 reputation)Gaining Respect (117 reputation)Gaining Respect (117 reputation)Gaining Respect (117 reputation)Gaining Respect (117 reputation)Gaining Respect (117 reputation)Gaining Respect (117 reputation)Gaining Respect (117 reputation)
Group: Forum Members
Posts: 10, Visits: 22
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 5 Years Ago by dv1sual
LogViewPlus Support
LogViewPlus Support
Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)
Group: Moderators
Posts: 1.2K, Visits: 4.3K
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 5 Years Ago by LogViewPlus Support
dv1sual
dv1sual
Gaining Respect (117 reputation)Gaining Respect (117 reputation)Gaining Respect (117 reputation)Gaining Respect (117 reputation)Gaining Respect (117 reputation)Gaining Respect (117 reputation)Gaining Respect (117 reputation)Gaining Respect (117 reputation)Gaining Respect (117 reputation)
Group: Forum Members
Posts: 10, Visits: 22
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
Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)
Group: Moderators
Posts: 1.2K, Visits: 4.3K
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
Gaining Respect (117 reputation)Gaining Respect (117 reputation)Gaining Respect (117 reputation)Gaining Respect (117 reputation)Gaining Respect (117 reputation)Gaining Respect (117 reputation)Gaining Respect (117 reputation)Gaining Respect (117 reputation)Gaining Respect (117 reputation)
Group: Forum Members
Posts: 10, Visits: 22
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
Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)Supreme Being (12K reputation)
Group: Moderators
Posts: 1.2K, Visits: 4.3K
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...




Threaded View
Threaded View
dv1sual - 5 Years Ago
LogViewPlus Support - 5 Years Ago
dv1sual - 5 Years Ago
LogViewPlus Support - 5 Years Ago
dv1sual - 5 Years Ago
                         The code looks fine. When you say it doesn't work - what do you mean?...
LogViewPlus Support - 5 Years Ago
                             Hi Toby, When I'm saying is not working I mean that when I open up my...
dv1sual - 5 Years Ago
                                 Thanks for the update. When you put a break point in your code, is it...
LogViewPlus Support - 5 Years Ago
                                     Hi Toby, you're a legend. I didn't add the post-processor to the...
dv1sual - 5 Years Ago
                                         Glad to that helped. Thanks for letting me know. :-) Toby
LogViewPlus Support - 5 Years Ago

Similar Topics

Login

Explore
Messages
Mentions
Search