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

Release googlelog version 0.1.0 #201

Merged
merged 3 commits into from
Dec 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ documentation = "https://github.com/bolcom/unFTP"
path = "crates/redislog"
version = "0.1.2"

[dependencies.googlelog]
[dependencies.slog-google]
path = "crates/googlelog"
features = ["shipper"]
version = "0.1.0"
Expand Down
8 changes: 7 additions & 1 deletion crates/googlelog/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
[package]
name = "googlelog"
name = "slog-google"
description = "Google Logging drain for slog-rs"
version = "0.1.0"
edition = "2021"
license = "Apache-2.0"
authors = [
"Rob klein Gunnewiek <[email protected]>"
]
keywords = ["slog", "logging", "log", "google", "gcp"]
categories = ["development-tools::debugging"]
homepage = "https://github.com/bolcom/unFTP/tree/master/crates/googlelog"
repository = "https://github.com/bolcom/unFTP/tree/master/crates/googlelog"

[features]
shipper = []
Expand Down
33 changes: 33 additions & 0 deletions crates/googlelog/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
.PHONY: help
help: # Show available `make` commands
@awk -F'#' '\
BEGIN{n=split("$(DOCKER_IMAGES)", docker_images, " ")} \
/^[%a-z][.A-Za-z0-9]+/ { \
if (NF > 1) { \
sub(/:[^#]*/, ""); \
if ($$1 ~ /%/ && $$1 ~ /[Dd]ocker/) { \
line=$$0; \
for (i=1; i<=n; ++i) { \
$$0 = line; \
gsub(/%/, docker_images[i]); \
printf("%-25s %s\n", $$1, $$2) \
} \
} else { \
printf("%-25s %s\n", $$1, $$2) \
} \
} \
}\
/^##/ { printf("\n") }' Makefile

##
.PHONY: pr-prep
pr-prep: # Runs checks to ensure you're ready for a pull request
cargo fmt --all -- --check
cargo clippy -- -D warnings
cargo test
cargo test --doc
cargo build
cargo doc --no-deps --features shipper

publish:
cargo publish --verbose
4 changes: 2 additions & 2 deletions crates/googlelog/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//!
//! Warning: Currently, this library only works in the context of [workload identity](https://cloud.google.com/iam/docs/workload-identity-federation).
//!
//! The `googlelog` drain creates log entries compatible with [Google Cloud Logging](https://cloud.google.com/logging).
//! The `slog_google` drain creates log entries compatible with [Google Cloud Logging](https://cloud.google.com/logging).
//! Depending on how you want to ship these logs to the Google Logging API, you can choose from one of the available build methods.
//!
//! Start by configuring the Logger with the builder ([`Builder`](logger::Builder::new)) and selecting the appropriate build method based on your shipping requirements:
Expand All @@ -16,7 +16,7 @@
//! The [`builder`](struct@logger::Builder) supports several `with_*` methods to customize the log message format,
//! particularly the default labels attached to [log entries](https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry).
//!
/// Googlelog Error types
/// slog-google Error types
pub mod error;

/// The [`slog::Drain`](https://slog-rs.github.io/slog/slog/trait.Drain.html) Implementation of the slog Drain for [Google Cloud Logging](https://cloud.google.com/logging)
Expand Down
6 changes: 3 additions & 3 deletions crates/googlelog/src/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl Builder {
/// # Example
///
/// ```
/// use googlelog::logger::Builder;
/// use slog_google::logger::Builder;
/// let (drain, _) = Builder::new(
/// "projects/my-gcp-project/logs/my-log-id",
/// "k8s_container",
Expand Down Expand Up @@ -81,7 +81,7 @@ impl Builder {
/// "namespace_name": "my-gke-namespace"
/// });
///
/// use googlelog::logger::Builder;
/// use slog_google::logger::Builder;
/// let (drain, _) = Builder::new(
/// "projects/my-gcp-project/logs/my-log-id",
/// "k8s_container",
Expand Down Expand Up @@ -195,7 +195,7 @@ impl Builder {
/// "namespace_name": "my-gke-namespace"
/// });
///
/// use googlelog::logger::Builder;
/// use slog_google::logger::Builder;
/// let (drain, mut shipper) = Builder::new(
/// "projects/my-gcp-project/logs/my-log-id",
/// "k8s_container",
Expand Down
6 changes: 3 additions & 3 deletions src/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ where

pub fn create_logger(
arg_matches: &ArgMatches,
) -> Result<(slog::Logger, Option<googlelog::shipper::Shipper>), String> {
) -> Result<(slog::Logger, Option<slog_google::shipper::Shipper>), String> {
let min_log_level = match arg_matches.occurrences_of(VERBOSITY) {
0 => Level::Warning,
1 => Level::Info,
Expand Down Expand Up @@ -140,7 +140,7 @@ fn load_labels_file(file_path: &str, hostname: &str) -> Result<serde_json::Value

fn google_logger(
m: &ArgMatches,
) -> Result<Option<(googlelog::logger::Logger, googlelog::shipper::Shipper)>, String> {
) -> Result<Option<(slog_google::logger::Logger, slog_google::shipper::Shipper)>, String> {
match (m.value_of(GLOG_LOGNAME), m.value_of(GLOG_RESOURCE_TYPE)) {

(Some(logname), Some(resource_type)) => {
Expand All @@ -150,7 +150,7 @@ fn google_logger(

let (labels_file, level_label) = (m.value_of(GLOG_LABELS_FILE), m.value_of(GLOG_LEVEL_LABEL));

let mut builder = googlelog::logger::Builder::new(
let mut builder = slog_google::logger::Builder::new(
logname,
resource_type,
);
Expand Down
Loading