{"id":16565174,"url":"https://github.com/shonharsh/csharp-exercism-s04e01-extensionmethods-loganalysis","last_synced_at":"2025-07-04T06:36:41.632Z","repository":{"id":244441268,"uuid":"815254450","full_name":"ShonHarsh/CSharp-Exercism-S04E01-ExtensionMethods-LogAnalysis","owner":"ShonHarsh","description":"Exercism - This C# project is about extension-methods and analyzing logs.","archived":false,"fork":false,"pushed_at":"2024-06-17T22:05:24.000Z","size":133,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-15T21:27:09.615Z","etag":null,"topics":["academic","analysis","artificial-intelligence","atom","automation","bot","config","csharp","education","git","guide","learning","logging","markdown","process","studio","testing","training-materials","trending","windows"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ShonHarsh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-14T17:32:12.000Z","updated_at":"2024-06-22T01:46:55.000Z","dependencies_parsed_at":"2024-06-14T18:55:50.744Z","dependency_job_id":"384c3d53-3e41-4cf5-bfd1-d86d434e6b0e","html_url":"https://github.com/ShonHarsh/CSharp-Exercism-S04E01-ExtensionMethods-LogAnalysis","commit_stats":null,"previous_names":["shonharsh/csharp-exercism-s04e01-extensionmethods-loganalysis"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShonHarsh%2FCSharp-Exercism-S04E01-ExtensionMethods-LogAnalysis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShonHarsh%2FCSharp-Exercism-S04E01-ExtensionMethods-LogAnalysis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShonHarsh%2FCSharp-Exercism-S04E01-ExtensionMethods-LogAnalysis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShonHarsh%2FCSharp-Exercism-S04E01-ExtensionMethods-LogAnalysis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ShonHarsh","download_url":"https://codeload.github.com/ShonHarsh/CSharp-Exercism-S04E01-ExtensionMethods-LogAnalysis/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241992601,"owners_count":20054355,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["academic","analysis","artificial-intelligence","atom","automation","bot","config","csharp","education","git","guide","learning","logging","markdown","process","studio","testing","training-materials","trending","windows"],"created_at":"2024-10-11T20:46:19.202Z","updated_at":"2025-03-05T08:28:48.019Z","avatar_url":"https://github.com/ShonHarsh.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Banner](Data/Images/CSharp-Exercism-S04E01-ExtensionMethods-LogAnalysis-Banner.png)\n\n### CSharp-Exercism-S04E01-ExtensionMethods-LogAnalysis\n\nThis repository my work for the [Exercism](https://exercism.org/) C# track.\n\n### Download Command\n`exercism download --track=csharp --exercise=log-analysis`\n\n### Submission Command\n`exercism submit \"Exercism\\csharp\\log-analysis\\LogAnalysis.cs\"`\n\n![Banner](Data/Images/CSharp-Exercism-S04-ExtensionMethods-Title.png)\n\n# Log Analysis\n\nWelcome to Log Analysis on Exercism's C# Track.\nIf you need help running the tests or submitting your code, check out `HELP.md`.\nIf you get stuck on the exercise, check out `HINTS.md`, but try and solve it without using those first :)\n\n## Introduction\n\n## Extension Methods\n\nExtension methods allow adding methods to existing types without creating a new derived type, recompiling, or otherwise modifying the original type. They are defined as static methods but are called by using instance method syntax. Their first parameter is preceded by the `this` modifier, and specifies which type the method operates on, and are brought into scope at the namespace level.\n\n```csharp\npublic static int WordCount(this string str)\n{\n    return str.Split().Length;\n}\n\n\"Hello World\".WordCount();\n// =\u003e 2\n```\n\n## Instructions\n\nIn this exercise you'll be processing log-lines.\n\nEach log line is a string formatted as follows: `\"[\u003cLEVEL\u003e]: \u003cMESSAGE\u003e\"`.\n\nThere are three different log levels:\n\n- `INFO`\n- `WARNING`\n- `ERROR`\n\nYou have several tasks, each of which will take a log line and ask you to do something with it.\n\n## 1. Allow retrieving the string after a specific substring\n\nLooking at the logs of the last month, you see that the test message is always located after a specific substring. As you're anticipating having to extract the test message sometime in the near future, you decide to create a helper method to help you with that.\n\nImplement the (_static_) `LogAnalysis.SubstringAfter()` extension method, that takes in some string delimiter and returns the substring after the delimiter.\n\n```csharp\nvar log = \"[INFO]: File Deleted.\";\nlog.SubstringAfter(\": \"); // =\u003e returns \"File Deleted.\"\n```\n\n## 2. Allow retrieving the string in between two substrings\n\nOn further inspection, you see that the log level is always located between square brackets (`[` and `]`). As you're also anticipating having to extract the log level sometime in the near future, you decide to create another helper method to help you with that.\n\nImplement the (_static_) `LogAnalysis.SubstringBetween()` extension method that takes in two string delimiters, and returns the substring that lies between the two delimiters.\n\n```csharp\nvar log = \"[INFO]: File Deleted.\";\nlog.SubstringBetween(\"[\", \"]\"); // =\u003e returns \"INFO\"\n```\n\n## 3. Parse message in a log\n\nImplement the (_static_) `LogAnalysis.Message()` extension method to return the message contained in a log.\n\n```csharp\nvar log = \"[ERROR]: Missing ; on line 20.\";\nlog.Message(); // =\u003e returns \"Missing ; on line 20.\"\n```\n\n## 4. Parse log level in a log\n\nImplement the (_static_) `LogAnalysis.LogLevel()` extension method to return the log level of a log.\n\n```csharp\nvar log = \"[ERROR]: Missing ; on line 20.\";\nlog.LogLevel(); // =\u003e returns \"ERROR\"\n```\n\n## Source\n\n### Created by\n\n- @yzAlvin\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshonharsh%2Fcsharp-exercism-s04e01-extensionmethods-loganalysis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshonharsh%2Fcsharp-exercism-s04e01-extensionmethods-loganalysis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshonharsh%2Fcsharp-exercism-s04e01-extensionmethods-loganalysis/lists"}