Skip to content
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

Add syslog capabilities #212

Merged
merged 1 commit into from Nov 4, 2023

Conversation

azenna
Copy link
Contributor

@azenna azenna commented Oct 4, 2023

Add syslog capabilities

I have

  • run cargo fmt;
  • run cargo clippy;
  • run cargo testand all tests pass;
  • linked to the originating issue (if applicable).

resolves #38

Copy link
Member

@vadorovsky vadorovsky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on that and sorry for late reaction!

For now I have just one comment, but I will take a deeper look later today.


loop {
tokio::select! {
r = shutdown.recv() => return r,
_ = rx_config.changed() => {
logger = Logger::from_config(rx_config.read()?);
logger = Logger::from_config(rx_config.read()?).unwrap_or_else(|e| e);
Copy link
Member

@vadorovsky vadorovsky Oct 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from_config returns Result, so I think just:

Suggested change
logger = Logger::from_config(rx_config.read()?).unwrap_or_else(|e| e);
logger = Logger::from_config(rx_config.read()?)?;

should work?

Copy link
Contributor Author

@azenna azenna Oct 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from_config returns Result<Self, Self>, .unwrap(|e| e) doesn't early return. Err(Self) is used to add a warning to the module status describing failure to connect to syslog without causing the logger module to fail. It's a little weird, can go either direction with syslog failure causing module failure I don't know which fits pulsars design better (also caught your talk about ebpf on youtube the other day was very good!)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree it's a weird way of handling it but I don't have a better solution right now.

Probably you should also add the warning in the "changed-config" branch

crates/modules/logger/src/lib.rs Outdated Show resolved Hide resolved
@@ -49,51 +64,68 @@ impl TryFrom<&ModuleConfig> for Config {
Ok(Self {
console: config.with_default("console", true)?,
// file: config.required("file")?,
// syslog: config.required("syslog")?,
syslog: config.with_default("syslog", true)?,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you should update also the README to include this default

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!

crates/modules/logger/src/lib.rs Outdated Show resolved Hide resolved

loop {
tokio::select! {
r = shutdown.recv() => return r,
_ = rx_config.changed() => {
logger = Logger::from_config(rx_config.read()?);
logger = Logger::from_config(rx_config.read()?).unwrap_or_else(|e| e);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree it's a weird way of handling it but I don't have a better solution right now.

Probably you should also add the warning in the "changed-config" branch

@azenna azenna force-pushed the 38-add-syslog-capabilities branch 2 times, most recently from c908b81 to 3607743 Compare October 12, 2023 19:29
@banditopazzo
Copy link
Member

Please try to rebase on the main, the linker issue should be solved

@azenna
Copy link
Contributor Author

azenna commented Oct 19, 2023

Rebased!

@banditopazzo banditopazzo merged commit 52071af into exein-io:main Nov 4, 2023
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add syslog logging capabilities
3 participants