Closed sweep-ai[bot] closed 1 year ago
can you implement the timestamp for the logger
can you implement the timestamp for the logger
Hi @SkuldNorniern,
I decided to make the following changes:
File Path | Proposed Changes |
---|---|
src/utils/log.rs |
Modify src/utils/log.rs with contents: • Import the Local struct from the chrono crate.• Modify the log() function to include the current timestamp in the log message.• Get the current timestamp using Local::now() .• Format the timestamp using the format() function and append it to the log message.• Write the updated log message to the log file. |
any update to the commit?
any update to the commit?
Hi @SkuldNorniern,
I decided to make the following changes:
File Path | Proposed Changes |
---|---|
src/utils/log.rs |
Modify src/utils/log.rs with contents: • Update the commit message to address any issues or provide additional information. |
GitHub actions yielded the following error.
The command that failed is cargo install clippy-sarif sarif-fmt
. Here are the relevant lines from the logs:
error[E0507]: cannot move out of `*self` which is behind a shared reference
--> /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cargo_metadata-0.15.4/src/diagnostic.rs:95:24
|
95 | #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
| ^^^^^^^^^
| |
| data moved here
| move occurs because `unrecognized` has type `Applicability`, which does not implement the `Copy` trait
|
= note: this error originates in the derive macro `Serialize` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider borrowing here
|
95 | #[derive(Debug, Clone, &Serialize, Deserialize, PartialEq, Eq, Hash)]
| +
error[E0507]: cannot move out of `*self` which is behind a shared reference
--> /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cargo_metadata-0.15.4/src/messages.rs:104:24
|
104 | #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
| ^^^^^^^^^
| |
| data moved here
| move occurs because `unrecognized` has type `Message`, which does not implement the `Copy` trait
|
= note: this error originates in the derive macro `Serialize` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider borrowing here
|
104 | #[derive(Debug, Clone, &Serialize, Deserialize, PartialEq, Eq, Hash)]
| +
For more information about this error, try `rustc --explain E0507`.
error: could not compile `cargo_metadata` (lib) due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
There are a lot of errors. This is likely due to a small parsing issue or a missing import with the files changed in the PR.
This is likely a linting or type-checking issue with the source code. Update the code changed by the PR. Don't modify the existing tests.
The command that failed is
cargo install clippy-sarif sarif-fmt
. Here are the relevant lines from the logs:error[E0507]: cannot move out of `*self` which is behind a shared reference --> /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cargo_metadata-0.15.4/src/diagnostic.rs:95:24 | 95 | #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)] | ^^^^^^^^^ | | | data moved here | move occurs because `unrecognized` has type `Applicability`, which does not implement the `Copy` trait | = note: this error originates in the derive macro `Serialize` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider borrowing here | 95 | #[derive(Debug, Clone, &Serialize, Deserialize, PartialEq, Eq, Hash)] | + error[E0507]: cannot move out of `*self` which is behind a shared reference --> /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cargo_metadata-0.15.4/src/messages.rs:104:24 | 104 | #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)] | ^^^^^^^^^ | | | data moved here | move occurs because `unrecognized` has type `Message`, which does not implement the `Copy` trait | = note: this error originates in the derive macro `Serialize` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider borrowing here | 104 | #[derive(Debug, Clone, &Serialize, Deserialize, PartialEq, Eq, Hash)] | + For more information about this error, try `rustc --explain E0507`. error: could not compile `cargo_metadata` (lib) due to 2 previous errors warning: build failed, waiting for other jobs to finish...
There are a lot of errors. This is likely due to a small parsing issue or a missing import with the files changed in the PR.
Hi @sweep-ai[bot],
I decided to make the following changes:
File Path | Proposed Changes |
---|---|
src/utils/log.rs |
Modify src/utils/log.rs with contents: • Modify line 39: Change #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)] to #[derive(Debug, Clone, &Serialize, Deserialize, PartialEq, Eq, Hash)] .• Modify line 43: Change #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)] to #[derive(Debug, Clone, &Serialize, Deserialize, PartialEq, Eq, Hash)] . |
Description
This PR modifies the
log.rs
file to support logging to a.log
file instead of the syslog. It also implements proper log level handling and follows the conventional commit rule for the commit message title. The changes are made without using any external crate.Summary
new()
function in theLog
struct to create a log file using the standard library'sstd::fs::File::create()
function.#[cfg(target_os = "~")]
attribute. The log file is created at/var/log/fluere/
for Linux, at the installation directory for Windows, and at the appropriate directories for MacOS and BSD.log()
function in theLog
struct to handle different log levels. Implemented a match statement to handle different log levels and write the appropriate log messages to the log file.std::io::Write
trait'swrite()
function to write log messages to the log file. Handled any errors that may occur during file IO.Please review and merge this PR. Thank you!
Fixes #31.
To checkout this PR branch, run the following command in your terminal:
🎉 Latest mprovements to Sweep:
💡 To get Sweep to edit this pull request, you can: