Skip to content

Commit

Permalink
readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Akmot9 committed Aug 18, 2023
1 parent 817fa13 commit 857d2d8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "my_logger"
version = "0.2.0"
version = "0.2.1"
authors = ["akmot9 avicocyprien@yahoo.com"]
edition = "2018"
description = "A simple marco to do logging in a file.log"
Expand Down
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,32 @@ Add this crate to your `Cargo.toml`:

```toml
[dependencies]
my_logger = "0.1.0" # Replace with the latest version available
my_logger = "0.2.1" # Replace with the latest version available
```

## Usage
First, import the log! macro from the crate:
```rust
use my_logger::log;
use my_logger::{log, logw, logd};
```
Then, you can use the log! macro to log messages:
```rust
fn main() {
log!("This is a log message.");
log!("Another log message with a value: {}", 42);
let err = "Something went wrong!";
log!("error: {}", err);
logd!("debug: {}", err);
logw!("warning: {}", err);
}
```
The log messages will be written to a file named "file.log" in the current directory, and each log entry will include a timestamp.

## Exemple
The log file (file.log) will contain a line like this:
```log
[2023-08-04T12:34:56Z] This is a log message.
[2023-08-04T12:34:56Z] Another log message with a value: 42
[2023-08-18 21:48:01] This is a log message.
[2023-08-18 21:48:02] Another log message with a value: 42
[2023-08-18 21:48:03] error: Something went wrong!
[2023-08-18 21:48:04] warning: Something went wrong!
``````

0 comments on commit 857d2d8

Please sign in to comment.