Skip to content

Conversation

GioMaz
Copy link
Contributor

@GioMaz GioMaz commented Aug 21, 2023

Grok grok = new Grok("%{MONTHDAY:month}-%{MONTHDAY:day}-%{MONTHDAY:year} %{TIME:timestamp};%{WORD:id};%{LOGLEVEL:loglevel};%{WORD:func};%{GREEDYDATA:msg}");

string logs = @"06-21-19 21:00:13:589241;15;INFO;main;DECODED: 775233900043 DECODED BY: 18500738 DISTANCE: 1.5165
                06-22-19 22:00:13:589265;156;WARN;main;DECODED: 775233900043 EMPTY DISTANCE: --------";

var grokResult = grok.AsDictionary(logs);

foreach (var item in grokResult)
{
    Console.WriteLine($"{item.Key}:");
    foreach (var value in item.Value)
    {
        Console.WriteLine("\t" + value);
    }
}

this will now print:

month:
        06
        06
day:
        21
        22
year:
        19
        19
timestamp:
        21:00:13:589241
        22:00:13:589265
id:
        15
        156
loglevel:
        INFO
        WARN
func:
        main
        main
msg:
        DECODED: 775233900043 DECODED BY: 18500738 DISTANCE: 1.5165
        DECODED: 775233900043 EMPTY DISTANCE: --------

@GioMaz GioMaz changed the title Get Dictionary instead of GrokResult with AsDictionary method Get Dictionary instead of GrokResult with AsDictionary method (#72) Aug 21, 2023
Copy link
Owner

@Marusyk Marusyk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your time.
The changes seem overcomplicated and violate some good OOP practices. I'm sure we can done this in "1 line of code"
tip - look at the title of the #72 😉

@Marusyk Marusyk added the enhancement New feature or request label Aug 21, 2023
@Marusyk Marusyk added this to the 1.2.0 milestone Aug 21, 2023
@Marusyk Marusyk linked an issue Aug 21, 2023 that may be closed by this pull request
Copy link
Owner

@Marusyk Marusyk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍Thanks a lot

@Marusyk Marusyk merged commit 435d30b into Marusyk:main Aug 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GrokResult as a dictionary
4 participants