Skip to content
Draft
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
30 changes: 23 additions & 7 deletions README_ADVANCED.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,24 @@ Displays:
- Network information
- Port allocations

### `logs`
Shows combined Docker logs for the current foc-devnet run.

```bash
foc-devnet logs [OPTIONS]
```

**Options:**
- `--follow`, `-f` - Follow logs from all current-run containers
- `--tail <LINES>` - Number of recent lines to show per container before following (default: 100, only valid with `--follow`)

**Examples:**
```bash
foc-devnet logs # Print all current-run container logs in timestamp order
foc-devnet logs --follow # Tail combined logs from all current-run containers
foc-devnet logs -f --tail 50 # Tail logs, starting with 50 recent lines per container
```

### `version`
Shows version information.

Expand Down Expand Up @@ -1148,10 +1166,8 @@ docker ps | grep curio
docker network ls | grep cur-m-net
# Should see: foc-<run-id>-cur-m-net-{1,2,3,4,5}

# Monitor logs
docker logs -f foc-<run-id>-curio-1
docker logs -f foc-<run-id>-curio-2
# ... etc
# Monitor combined logs
foc-devnet logs --follow
```

### Querying SP Status
Expand All @@ -1160,8 +1176,8 @@ docker logs -f foc-<run-id>-curio-2
# List all containers
docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"

# Check specific SP logs
docker logs foc-<run-id>-curio-2
# Print combined logs in timestamp order
foc-devnet logs

# Query provider IDs
cat ~/.foc-devnet/state/latest/pdp_sps/*.provider_id.json
Expand Down Expand Up @@ -1207,7 +1223,7 @@ vim ~/.foc-devnet/config.toml
### Container won't start
```bash
# Check logs
docker logs foc-<run-id>-lotus
foc-devnet logs

# Check if image exists
docker images | grep foc-lotus
Expand Down
72 changes: 72 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ pub enum Commands {
},
/// Show status of the foc-devnet system
Status,
/// Show combined logs for the current foc-devnet run
Logs {
/// Follow logs from all current-run containers
#[arg(short, long)]
follow: bool,
/// Number of recent lines to show per container before following
#[arg(long, value_name = "LINES", requires = "follow")]
tail: Option<usize>,
},
/// Show version information
Version {
/// Force plain output without tracing prefixes, even when stdout is a terminal
Expand All @@ -89,6 +98,69 @@ pub enum Commands {
},
}

#[cfg(test)]
mod tests {
use super::*;
use clap::Parser;

#[test]
fn test_parse_logs_default() {
let cli = Cli::try_parse_from(["foc-devnet", "logs"]).unwrap();

match cli.command {
Commands::Logs { follow, tail } => {
assert!(!follow);
assert_eq!(tail, None);
}
_ => panic!("expected logs command"),
}
}

#[test]
fn test_parse_logs_follow_long() {
let cli = Cli::try_parse_from(["foc-devnet", "logs", "--follow"]).unwrap();

match cli.command {
Commands::Logs { follow, tail } => {
assert!(follow);
assert_eq!(tail, None);
}
_ => panic!("expected logs command"),
}
}

#[test]
fn test_parse_logs_follow_short() {
let cli = Cli::try_parse_from(["foc-devnet", "logs", "-f"]).unwrap();

match cli.command {
Commands::Logs { follow, tail } => {
assert!(follow);
assert_eq!(tail, None);
}
_ => panic!("expected logs command"),
}
}

#[test]
fn test_parse_logs_follow_tail() {
let cli = Cli::try_parse_from(["foc-devnet", "logs", "--follow", "--tail", "50"]).unwrap();

match cli.command {
Commands::Logs { follow, tail } => {
assert!(follow);
assert_eq!(tail, Some(50));
}
_ => panic!("expected logs command"),
}
}

#[test]
fn test_parse_logs_tail_requires_follow() {
assert!(Cli::try_parse_from(["foc-devnet", "logs", "--tail", "50"]).is_err());
}
}

/// Build subcommands
#[derive(Subcommand)]
pub enum BuildCommands {
Expand Down
Loading