Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shonharsh/csharp-exercism-s03e01-strings-loglevels
Exercism - This C# project is regarding strings and processing logs.
https://github.com/shonharsh/csharp-exercism-s03e01-strings-loglevels
academic artificial-intelligence atom automation bot config csharp education git guide learning logging markdown process strings studio testing training-materials trending windows
Last synced: 8 days ago
JSON representation
Exercism - This C# project is regarding strings and processing logs.
- Host: GitHub
- URL: https://github.com/shonharsh/csharp-exercism-s03e01-strings-loglevels
- Owner: ShonHarsh
- License: mit
- Created: 2024-06-14T17:31:03.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-06-17T22:06:40.000Z (7 months ago)
- Last Synced: 2024-11-15T10:07:54.266Z (2 months ago)
- Topics: academic, artificial-intelligence, atom, automation, bot, config, csharp, education, git, guide, learning, logging, markdown, process, strings, studio, testing, training-materials, trending, windows
- Language: C#
- Homepage:
- Size: 132 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
![Banner](Data/Images/CSharp-Exercism-S03E01-Strings-LogLevels-Banner.png)
### CSharp-Exercism-S03E01-Strings-LogLevels
This repository my work for the [Exercism](https://exercism.org/) C# track.
### Download Command
`exercism download --track=csharp --exercise=log-levels`### Submission Command
`exercism submit "Exercism\csharp\log-levels\LogLevels.cs"`![Banner](Data/Images/CSharp-Exercism-S03-Strings-Title.png)
# Log Levels
Welcome to Log Levels on Exercism's C# Track.
If you need help running the tests or submitting your code, check out `HELP.md`.
If you get stuck on the exercise, check out `HINTS.md`, but try and solve it without using those first :)## Introduction
## Strings
A `string` in C# is an object that represents immutable text as a sequence of Unicode characters (letters, digits, punctuation, etc.). Double quotes are used to define a `string` instance:
```csharp
string fruit = "Apple";
```Strings are manipulated by calling the string's methods. Once a string has been constructed, its value can never change. Any methods that appear to modify a string will actually return a new string.
Multiple strings can be concatenated (added) together. The simplest way to achieve this is by using the `+` operator.
```csharp
string name = "Jane";
"Hello " + name + "!";
// => "Hello Jane!"
```For any string formatting more complex than simple concatenation, string interpolation is preferred. To use interpolation in a string, prefix it with the dollar (`$`) symbol. Then you can use curly braces (`{}`) to access any variables inside your string.
```csharp
string name = "Jane";
$"Hello {name}!";
// => "Hello Jane!"
```## Instructions
In this exercise you'll be processing log-lines.
Each log line is a string formatted as follows: `"[]: "`.
There are three different log levels:
- `INFO`
- `WARNING`
- `ERROR`You have three tasks, each of which will take a log line and ask you to do something with it.
## 1. Get message from a log line
Implement the (_static_) `LogLine.Message()` method to return a log line's message:
```csharp
LogLine.Message("[ERROR]: Invalid operation")
// => "Invalid operation"
```Any leading or trailing white space should be removed:
```csharp
LogLine.Message("[WARNING]: Disk almost full\r\n")
// => "Disk almost full"
```## 2. Get log level from a log line
Implement the (_static_) `LogLine.LogLevel()` method to return a log line's log level, which should be returned in lowercase:
```csharp
LogLine.LogLevel("[ERROR]: Invalid operation")
// => "error"
```## 3. Reformat a log line
Implement the (_static_) `LogLine.Reformat()` method that reformats the log line, putting the message first and the log level after it in parentheses:
```csharp
LogLine.Reformat("[INFO]: Operation completed")
// => "Operation completed (info)"
```## Source
### Created by
- @ErikSchierboom
### Contributed to by
- @yzAlvin