slack-log 1.1.3

Slack log for sending plain and block messages using Slack webhook
Documentation
# Slack Logger ๐Ÿงต

A lightweight async logger for sending **structured** and **text-based logs** to Slack from your Rust applications.

## โœจ Features

- โœ… Simple `log_info()`, `log_error()`, `log_warn()` style methods
- โœ… Block-style logs with key-value pairs
- โœ… Auto-pretty-prints complex JSON data
- โœ… Runs asynchronously using `tokio::spawn`
- โœ… Works great for production observability and alerts

---

## ๐Ÿ“ฆ Installation

Add to your `Cargo.toml`:

```toml
[dependencies]
slack_log = "0.1"
```
or

```bash
cargo install slack-log
```
---

## โš™๏ธ Initialization

Before using, initialize once:

```rust
use slack_log::{slack_log_initialize, SlackConfig};

slack_log_initialize(SlackConfig {
    webhook_url: "https://hooks.slack.com/services/...".into(),
    debugger: true,
});
```

---

## ๐Ÿงช Usage Examples

### ๐Ÿ”ณ Block-style Logs

```rust
use slack_log::{log_block_success, log_block_error, log_block_info, log_block_warn, log_block, block_fields};
use serde_json::json;
use chrono::Utc;

let fields = block_fields![
    { title: "Service", value: "UI Indexer" },
    { title: "Price", value: 50000 },
    { title: "Boolean", value: false },
    { title: "Time", value: chrono::Utc::now().to_string() },
    { title: "JSON", value: json!([{ "a": 1 }, { "b": 2 }]) },
    { title: "to_string_pretty", value: serde_json::to_string_pretty(&json!([{ "a": 1 }, { "b": 2 }])).unwrap() }
];

log_block_success("Ravi bhai ka code", &fields);
log_block_error("Startup", &fields);
log_block_info("Startup", &fields);
log_block_warn("Startup", &fields);
log_block("Startup", &fields);
```

---

### ๐Ÿ’ฌ Simple Logs

```rust
use slack_log::{log, log_info, log_warn, log_success, log_error};
use serde_json::json;

log_info("App started \njay here!!!");
log_warn(1234);
log_success(true);
log_error(json!({ "event": "shutdown", "reason": "manual" }));

let data = json!([{ "a": 1 }, { "b": 2 }]);
log(serde_json::to_string_pretty(&data).unwrap());
```

---

## ๐Ÿงฑ Macro Support

Create blocks easily with:

```rust
let fields = block_fields![
    { title: "Key", value: "Value" },
    { title: "Another", value: 123 }
];
```

---

## ๐Ÿ“ License

MIT OR Apache-2.0