{"id":31655497,"url":"https://github.com/sivel/zprint","last_synced_at":"2025-10-07T13:14:58.737Z","repository":{"id":316102411,"uuid":"1061970646","full_name":"sivel/zprint","owner":"sivel","description":"Thread-safe print utilities for Zig CLI applications with formatted printing to stdout and stderr","archived":false,"fork":false,"pushed_at":"2025-09-22T16:48:13.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-09-22T18:47:40.183Z","etag":null,"topics":["zig","zig-package","ziglang"],"latest_commit_sha":null,"homepage":"","language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sivel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-22T16:19:58.000Z","updated_at":"2025-09-22T16:48:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"28c48ddf-03d2-4584-82b9-d1f4909af58c","html_url":"https://github.com/sivel/zprint","commit_stats":null,"previous_names":["sivel/zprint"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/sivel/zprint","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sivel%2Fzprint","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sivel%2Fzprint/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sivel%2Fzprint/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sivel%2Fzprint/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sivel","download_url":"https://codeload.github.com/sivel/zprint/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sivel%2Fzprint/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278780068,"owners_count":26044493,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["zig","zig-package","ziglang"],"created_at":"2025-10-07T13:14:56.529Z","updated_at":"2025-10-07T13:14:58.731Z","avatar_url":"https://github.com/sivel.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"# zprint\n\nThread-safe print utilities for Zig CLI applications with formatted printing to stdout and stderr.\n\n## Features\n\n- **Thread-safe**: Uses recursive mutexes for concurrent access\n- **Formatted printing**: Supports all Zig format specifiers\n- **Explicit error handling**: Choose between error-returning and error-ignoring variants\n- **Flexible**: Generic `WriterConfig` allows custom file handles with their own mutexes\n- **Auto-buffering**: Internal buffering with automatic flushing\n- **Cross-platform**: Handles Windows/Unix differences automatically\n\n## Installation\n\nAdd zprint to your project using `zig fetch`:\n\n```bash\nzig fetch --save https://github.com/sivel/zprint/archive/v0.1.0.tar.gz\n```\n\nThen in your `build.zig`, add the dependency:\n\n```zig\nconst zprint = b.dependency(\"zprint\", .{});\nexe.root_module.addImport(\"zprint\", zprint.module(\"zprint\"));\n```\n\n## Usage\n\n### Basic printing\n\n```zig\nconst zprint = @import(\"zprint\");\n\n// Print to stdout with error handling\ntry zprint.stdout(\"Hello {s}! Number: {d}\\n\", .{ \"world\", 42 });\n\n// Print to stderr with error handling\ntry zprint.stderr(\"Error: {s}\\n\", .{\"something went wrong\"});\n```\n\n### Debug printing (ignores errors)\n\n```zig\n// Debug versions that silently ignore errors\nzprint.debug.stdout(\"Debug message to stdout\\n\", .{});\nzprint.debug.stderr(\"Debug message to stderr\\n\", .{});\n```\n\n### Custom writer configurations\n\n```zig\nconst std = @import(\"std\");\nconst zprint = @import(\"zprint\");\n\n// Example: Custom log file writer\nvar log_file = try std.fs.cwd().createFile(\"app.log\", .{});\ndefer log_file.close();\n\nvar log_mutex = std.Thread.Mutex.Recursive.init;\nvar log_buffer: [1024]u8 = undefined;\nvar log_file_writer = log_file.writer(\u0026log_buffer);\n\nconst log_config = zprint.WriterConfig{\n    .mutex = \u0026log_mutex,\n    .writer = \u0026log_file_writer.interface,\n};\n\n// Use the custom config\ntry zprint.print(log_config, \"Log entry: {s}\\n\", .{\"custom message\"});\n```\n\n### Testing with buffer capture\n\n```zig\nconst std = @import(\"std\");\nconst zprint = @import(\"zprint\");\n\n// Capture output to a buffer for testing\nvar output_buffer: [512]u8 = undefined;\nvar test_mutex = std.Thread.Mutex.Recursive.init;\nvar test_writer = std.Io.Writer.fixed(output_buffer[0..]);\n\nconst test_config = zprint.WriterConfig{\n    .mutex = \u0026test_mutex,\n    .writer = \u0026test_writer,\n};\n\ntry zprint.print(test_config, \"Test: {d}\\n\", .{42});\n\n// Verify output\nconst written = output_buffer[0..test_writer.end];\n// written contains: \"Test: 42\\n\"\n```\n\n## API Reference\n\n### Main Functions\n\n- `stdout(fmt, args) !void` - Print to stdout with error handling\n- `stderr(fmt, args) !void` - Print to stderr with error handling\n- `print(config, fmt, args) !void` - Core function using a WriterConfig (thread-safe, with flushing)\n\n### Debug Functions (error-ignoring)\n\n- `debug.stdout(fmt, args) void` - Print to stdout, ignore errors\n- `debug.stderr(fmt, args) void` - Print to stderr, ignore errors\n\n### Types\n\n- `WriterConfig` - Configuration struct containing:\n  - `mutex: *std.Thread.Mutex.Recursive` - Mutex for thread safety\n  - `writer: *std.Io.Writer` - The writer interface to use\n\n## Why zprint?\n\nZig's standard library provides `std.debug.print` for debugging (stderr only) but lacks a higher level stdout printing solution for CLI applications. zprint fills this gap by providing:\n\n1. **Proper stdout support** - Unlike `std.debug.print` which only goes to stderr\n2. **Thread safety** - Safe for concurrent use across threads\n3. **Error handling** - Choose explicit error handling or error-ignoring variants\n4. **Flexibility** - Works with any writer, not just stdout/stderr\n\n## License\n\nMIT License - see LICENSE file for details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsivel%2Fzprint","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsivel%2Fzprint","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsivel%2Fzprint/lists"}