{"id":43045528,"url":"https://github.com/as/log","last_synced_at":"2026-01-31T09:47:32.879Z","repository":{"id":51211894,"uuid":"369066523","full_name":"as/log","owner":"as","description":"a simple structured log package in Go","archived":false,"fork":false,"pushed_at":"2023-05-03T17:25:23.000Z","size":49,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-03-19T01:47:04.750Z","etag":null,"topics":["go","log","logger","logs","simple"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/as.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}},"created_at":"2021-05-20T03:20:53.000Z","updated_at":"2024-03-19T01:47:04.751Z","dependencies_parsed_at":"2023-01-22T14:00:11.467Z","dependency_job_id":null,"html_url":"https://github.com/as/log","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/as/log","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/as%2Flog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/as%2Flog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/as%2Flog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/as%2Flog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/as","download_url":"https://codeload.github.com/as/log/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/as%2Flog/sbom","scorecard":{"id":210593,"data":{"date":"2025-08-11","repo":{"name":"github.com/as/log","commit":"4257ef908c6bac165f62ff9af406bb6e5af51cc7"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/27 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: The Unlicense: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 2 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-17T00:42:41.987Z","repository_id":51211894,"created_at":"2025-08-17T00:42:41.987Z","updated_at":"2025-08-17T00:42:41.987Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28937710,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-31T08:53:31.997Z","status":"ssl_error","status_checked_at":"2026-01-31T08:51:38.521Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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","log","logger","logs","simple"],"created_at":"2026-01-31T09:47:32.190Z","updated_at":"2026-01-31T09:47:32.870Z","avatar_url":"https://github.com/as.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Synopsis\n\nPackage log implements a simple structured JSON logger. The goal of this package is to eliminate logging clutter generated by more complex logging packages that encourage useless type conversions, declarations, and other noise. The logger starts with a few pre-initialized log fields that can be extended in the package scope, of which individual log lines can be derived from and operated on.\n\n# Variables\n\nTo use, first override the package-scoped variables at runtime.\n\n```\nvar (\n\t// Service name\n\tService = \"\"\n\n\t// Time is your time function\n\tTime    = func() interface{} {\n\t\treturn time.Now().UnixNano() / int64(time.Millisecond)\n\t}\n\n\t// Default is the level used when calling Printf\n\tDefault = Info\n)\n```\n\n# Install\n\n```\ngo get github.com/as/log\ngo test github.com/as/log -v -bench . \ngo test github.com/as/log -race -count 1\n```\n\nThis code may also be copied and pasted into your microservice\nand modified to your liking. Put it in a package called\nlog. A little copying is better than a little dependency.\n\nThe only file you need is `log.go`, there are no external dependencies.\n\n# Example 1\n\nmain.go\n```\npackage main\n\nimport \"github.com/as/log\"\n\nfunc main() {\n\tlog.Service = \"ex\"\n\tlog.Time = func() interface{} { return \"2121.12.04\" }\n\n\tlog.Error.Add(\n\t\t\"env\", \"prod\",\n\t\t\"burning\", true,\n\t\t\"pi\", 3.14,\n\t).Printf(\"error: %v\", io.EOF)\n}\n```\n\noutput\n```\n{\"svc\":\"ex\", \"time\":\"2121.12.04\", \"level\":\"error\", \"msg\":\"error: EOF\", \"env\":\"prod\", \"burning\":true, \"pi\":3.14}\n```\n\n# Example 2\n\n```\npackage main\n\nimport (\n        \"io\"\n        \"github.com/as/log\"\n)\n\nfunc main() {\n        log.Service = \"plumber\"\n        log.Tags = log.Tags.Add(\"env\", \"dev\", \"host\", \"scruffy\") // package scoped tags attach to all logs\n        unclog()\n}\n\nfunc unclog() {\n        line := log.Info.Add(\n                \"op\", \"unclog\",\n                \"account\", \"514423351351\",\n                \"toilets\", []string{\"foo\", \"bar\"}, // easily queried for membership in common log aggregators\n        )\n        line.Printf(\"enter\")\n        defer line.Printf(\"exit\")\n\n        // each operation copies the object and returns its copy with any tags added\n        line.Add(\"action\", \"plunge\").Printf(\"good god man\")\n        line.Error().Add(\"action\", \"flush\", \"err\", io.ErrClosedPipe).Printf(\"damn\")\n\n        line = line.Warn().Add(\"action\", \"bill\", \"mood\", \"exhausted\")\n        line.Printf(\"you need a bigger toilet\")\n        line.Printf(\"it gets clogged to easily\")\n}\n```\n\n```\ngo mod init\ngo get github.com/as/log\ntouch main.go # copy the example above to this file\ngo run main.go\n```\n\n```\n{\"svc\":\"plumber\", \"ts\":1682559034, \"level\":\"info\", \"env\":\"dev\", \"host\":\"scruffy\", \"op\":\"unclog\", \"account\":\"514423351351\", \"toilets\":[\"foo\",\"bar\"], \"msg\":\"enter\"}\n{\"svc\":\"plumber\", \"ts\":1682559034, \"level\":\"info\", \"env\":\"dev\", \"host\":\"scruffy\", \"op\":\"unclog\", \"account\":\"514423351351\", \"toilets\":[\"foo\",\"bar\"], \"action\":\"plunge\", \"msg\":\"good god man\"}\n{\"svc\":\"plumber\", \"ts\":1682559034, \"level\":\"error\", \"env\":\"dev\", \"host\":\"scruffy\", \"op\":\"unclog\", \"account\":\"514423351351\", \"toilets\":[\"foo\",\"bar\"], \"action\":\"flush\", \"err\":\"io: read/write on closed pipe\", \"msg\":\"damn\"}\n{\"svc\":\"plumber\", \"ts\":1682559034, \"level\":\"warn\", \"env\":\"dev\", \"host\":\"scruffy\", \"op\":\"unclog\", \"account\":\"514423351351\", \"toilets\":[\"foo\",\"bar\"], \"action\":\"bill\", \"mood\":\"exhausted\", \"msg\":\"you need a bigger toilet\"}\n{\"svc\":\"plumber\", \"ts\":1682559034, \"level\":\"warn\", \"env\":\"dev\", \"host\":\"scruffy\", \"op\":\"unclog\", \"account\":\"514423351351\", \"toilets\":[\"foo\",\"bar\"], \"action\":\"bill\", \"mood\":\"exhausted\", \"msg\":\"it gets clogged to easily\"}\n{\"svc\":\"plumber\", \"ts\":1682559034, \"level\":\"info\", \"env\":\"dev\", \"host\":\"scruffy\", \"op\":\"unclog\", \"account\":\"514423351351\", \"toilets\":[\"foo\",\"bar\"], \"msg\":\"exit\"}\n```\n\n# Example 3: But my caller frames!\n\nYou can use `AddFunc`, which has behavior similar to `Add`. It returns a copy of the line with the attached function executing before every print operation. Some precautions have been taken to avoid infinite recursion, but use of this feature is still mildly discouraged.\n\n```\npackage main\n\nimport (\n        \"fmt\"\n        \"path\"\n        \"runtime\"\n\n        \"github.com/as/log\"\n)\n\nfunc main() {\n        log.Service = \"plumber\"\n        unclog()\n}\n\nfunc unclog() {\n        fn := func(l log.Line) log.Line {\n                return l.Add(\"func\", where())\n        }\n        line := log.Info.AddFunc(fn)\n        line.Printf(\"enter\")\n        defer line.Printf(\"exit\")\n}\n\nfunc where() string {\n        pc, file, line, ok := runtime.Caller(1)\n        if !ok {\n                return \"/dev/null\"\n        }\n        file = path.Base(file)\n\n        fn := runtime.FuncForPC(pc)\n        if fn == nil {\n                return fmt.Sprintf(\"%s:%d\", file, line)\n        }\n        return fmt.Sprintf(\"%s:/%s/\", file, fn.Name())\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fas%2Flog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fas%2Flog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fas%2Flog/lists"}