Skip to content

Commit

Permalink
Update log4rs for tari_stratum_transcoder
Browse files Browse the repository at this point in the history
  • Loading branch information
StriderDM committed Aug 11, 2021
1 parent 05f7813 commit 3e129c1
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 3 deletions.
2 changes: 1 addition & 1 deletion applications/tari_stratum_transcoder/src/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ use tari_core::blocks::{Block, NewBlockTemplate};
use tari_utilities::{hex::Hex, message_format::MessageFormat};
use tracing::{debug, error};

const LOG_TARGET: &str = "tari_stratum_proxy::proxy";
const LOG_TARGET: &str = "tari_stratum_transcoder::transcoder";

#[derive(Debug, Clone)]
pub struct StratumTranscoderProxyConfig {
Expand Down
44 changes: 44 additions & 0 deletions common/logging/log4rs_sample_transcoder.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# A sample log configuration file for running in release mode. By default, this configuration splits up log messages to
# three destinations:
# * Console: For log messages with level INFO and higher
# * log/proxy/proxy.log: All proxy logs will be written to this file
#
# See https://docs.rs/log4rs/0.8.3/log4rs/encode/pattern/index.html for deciphering the log pattern. The log format
# used in this sample configuration prints messages as:
# timestamp [target] LEVEL message
refresh_rate: 30 seconds
appenders:
# An appender named "proxy" that writes to a file with a custom pattern encoder
proxy:
kind: rolling_file
path: "log/transcoder/transcoder.log"
policy:
kind: compound
trigger:
kind: size
limit: 200mb
roller:
kind: fixed_window
base: 1
count: 50
pattern: "log/transcoder/transcoder.{}.log"
encoder:
pattern: "{d(%Y-%m-%d %H:%M:%S.%f)} [{t}] {l:5} {m}{n}"

# root (to proxy)
root:
level: debug
appenders:
- proxy

loggers:
h2:
level: info
appenders:
- transcoder
additive: false
hyper:
level: info
appenders:
- transcoder
additive: false
4 changes: 2 additions & 2 deletions common/src/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ pub fn install_default_merge_mining_proxy_logfile_config(path: &Path) -> Result<
file.write_all(source.as_ref())
}

/// Installs a new default logfile configuration, copied from `log4rs_sample_proxy.yml` to the given path.
/// Installs a new default logfile configuration, copied from `log4rs_sample_transcoder.yml` to the given path.
pub fn install_default_stratum_transcoder_logfile_config(path: &Path) -> Result<(), std::io::Error> {
let source = include_str!("../logging/log4rs_sample_proxy.yml");
let source = include_str!("../logging/log4rs_sample_transcoder.yml");
if let Some(d) = path.parent() {
fs::create_dir_all(d)?
};
Expand Down

0 comments on commit 3e129c1

Please sign in to comment.