-
-
Notifications
You must be signed in to change notification settings - Fork 15
feat(stackable-telemetry): Add RollingFileAppender #933
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
f26fb40
feat: add RollingFileAppender to stackable-telemetry
xeniape 0e16812
add changelog entry
xeniape be484ea
adjust docs
xeniape ca0ae20
adjust docs
xeniape 4d3ebd0
Merge branch 'main' into feat/add-rolling-file-appender
xeniape bfe89a7
error handling, simplify filelogsettings creation
xeniape 3676dc1
Merge branch 'main' into feat/add-rolling-file-appender
xeniape 6bb857b
Apply suggestions from code review
xeniape b927c87
Merge branch 'main' into feat/add-rolling-file-appender
xeniape b369fb2
fix use statement
xeniape b641f0f
Update crates/stackable-telemetry/src/tracing/mod.rs
xeniape 0e2226f
Merge branch 'main' into feat/add-rolling-file-appender
xeniape 6a32cdf
Merge branch 'main' into feat/add-rolling-file-appender
xeniape File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
crates/stackable-telemetry/src/tracing/settings/file_log.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
//! File Log Subscriber Settings. | ||
|
||
use std::{ops::Deref, path::PathBuf}; | ||
|
||
use super::Settings; | ||
|
||
/// Configure specific settings for the File Log subscriber. | ||
#[derive(Debug, Default, PartialEq)] | ||
pub struct FileLogSettings { | ||
/// Common subscriber settings that apply to the File Log Subscriber. | ||
pub common_settings: Settings, | ||
|
||
/// Path to directory for log files. | ||
pub file_log_dir: PathBuf, | ||
} | ||
|
||
impl Deref for FileLogSettings { | ||
type Target = Settings; | ||
|
||
fn deref(&self) -> &Self::Target { | ||
&self.common_settings | ||
} | ||
} | ||
|
||
/// For building [`FileLogSettings`]. | ||
/// | ||
/// <div class="warning"> | ||
/// Do not use directly, instead use the [`Settings::builder`] associated function. | ||
/// </div> | ||
pub struct FileLogSettingsBuilder { | ||
pub(crate) common_settings: Settings, | ||
pub(crate) file_log_dir: PathBuf, | ||
} | ||
|
||
impl FileLogSettingsBuilder { | ||
/// Consumes self and returns a valid [`FileLogSettings`] instance. | ||
pub fn build(self) -> FileLogSettings { | ||
FileLogSettings { | ||
common_settings: self.common_settings, | ||
file_log_dir: self.file_log_dir, | ||
} | ||
} | ||
} | ||
|
||
#[cfg(test)] | ||
mod test { | ||
use tracing::level_filters::LevelFilter; | ||
|
||
use super::*; | ||
|
||
#[test] | ||
fn builds_settings() { | ||
let expected = FileLogSettings { | ||
common_settings: Settings { | ||
environment_variable: "hello", | ||
default_level: LevelFilter::DEBUG, | ||
enabled: true, | ||
}, | ||
file_log_dir: PathBuf::from("/logs"), | ||
}; | ||
let result = Settings::builder() | ||
.with_environment_variable("hello") | ||
.with_default_level(LevelFilter::DEBUG) | ||
.enabled(true) | ||
.file_log_settings_builder(PathBuf::from("/logs")) | ||
.build(); | ||
|
||
assert_eq!(expected, result); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.