{"id":28546003,"url":"https://github.com/islamghany/logy","last_synced_at":"2025-10-28T13:35:36.228Z","repository":{"id":298110444,"uuid":"998551864","full_name":"islamghany/logy","owner":"islamghany","description":"A structured logging package for Go applications built on top of `slog`. It provides JSON-formatted logs with additional features like trace ID support, service name injection, and custom event handlers.","archived":false,"fork":false,"pushed_at":"2025-06-08T21:14:01.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-07T05:39:11.567Z","etag":null,"topics":["go","golang","logging"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/islamghany.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}},"created_at":"2025-06-08T21:10:12.000Z","updated_at":"2025-06-08T21:11:57.000Z","dependencies_parsed_at":"2025-06-09T13:44:20.575Z","dependency_job_id":"5d477da4-8b75-4e40-ad5f-962edc7b8879","html_url":"https://github.com/islamghany/logy","commit_stats":null,"previous_names":["islamghany/logy"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/islamghany/logy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/islamghany%2Flogy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/islamghany%2Flogy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/islamghany%2Flogy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/islamghany%2Flogy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/islamghany","download_url":"https://codeload.github.com/islamghany/logy/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/islamghany%2Flogy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281447858,"owners_count":26503266,"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-28T02:00:06.022Z","response_time":60,"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":["go","golang","logging"],"created_at":"2025-06-09T23:08:49.854Z","updated_at":"2025-10-28T13:35:36.205Z","avatar_url":"https://github.com/islamghany.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Logy\n\nA structured logging package for Go applications built on top of `slog`. It provides JSON-formatted logs with additional features like trace ID support, service name injection, and custom event handlers.\n\n## Features\n\n- JSON-formatted structured logging\n- Context-aware logging\n- Trace ID support\n- Service name injection\n- Source file and line information\n- Custom event handlers\n- Multiple log levels (Debug, Info, Warn, Error)\n- Thread-safe logging\n\n## Installation\n\n```bash\ngo get github.com/islamghany/logy\n```\n\n## Usage\n\n### Basic Usage\n\n```go\npackage main\n\nimport (\n    \"context\"\n    \"os\"\n\n    \"github.com/islamghany/logy\"\n)\n\nfunc main() {\n    // Create a new logger with stdout output and Info level\n    logger := logy.New(os.Stdout, logy.LevelInfo, \"my-service\", nil)\n\n    ctx := context.Background()\n\n    // Log messages with different levels\n    logger.Debug(ctx, \"Debug message\")\n    logger.Info(ctx, \"Info message\", \"key\", \"value\")\n    logger.Warn(ctx, \"Warning message\")\n    logger.Error(ctx, \"Error message\")\n}\n```\n\n### With Trace ID\n\n```go\npackage main\n\nimport (\n    \"context\"\n    \"os\"\n\n    \"github.com/islamghany/logy\"\n)\n\nfunc main() {\n    // Create a trace ID function\n    traceIDFunc := func(ctx context.Context) string {\n        // Extract trace ID from context\n        return \"trace-123\"\n    }\n\n    logger := logy.New(os.Stdout, logy.LevelInfo, \"my-service\", traceIDFunc)\n\n    ctx := context.Background()\n    logger.Info(ctx, \"Message with trace ID\")\n}\n```\n\n### With Custom Event Handlers\n\n```go\npackage main\n\nimport (\n    \"context\"\n    \"os\"\n\n    \"github.com/islamghany/logy\"\n)\n\nfunc main() {\n    events := logy.Events{\n        Info: func(ctx context.Context, r logy.Record) {\n            // Custom handling for Info level logs\n            fmt.Printf(\"Custom Info handler: %s\\n\", r.Message)\n        },\n    }\n\n    logger := logy.NewWithEvents(os.Stdout, logy.LevelInfo, \"my-service\", nil, events)\n\n    ctx := context.Background()\n    logger.Info(ctx, \"Message with custom handler\")\n}\n```\n\n### Log Levels\n\n```go\nconst (\n    LevelDebug = Level(slog.LevelDebug)\n    LevelInfo  = Level(slog.LevelInfo)\n    LevelWarn  = Level(slog.LevelWarn)\n    LevelError = Level(slog.LevelError)\n)\n```\n\n## Output Format\n\nThe logger produces JSON-formatted output with the following structure:\n\n```json\n{\n  \"time\": \"2024-01-01T12:00:00Z\",\n  \"level\": \"INFO\",\n  \"msg\": \"message\",\n  \"service\": \"my-service\",\n  \"file\": \"main.go:42\",\n  \"trace_id\": \"trace-123\",\n  \"key\": \"value\"\n}\n```\n\n## License\n\nMIT License - see LICENSE file for details\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fislamghany%2Flogy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fislamghany%2Flogy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fislamghany%2Flogy/lists"}