{"id":22473104,"url":"https://github.com/bas080/bash-logger","last_synced_at":"2026-01-27T09:16:21.976Z","repository":{"id":147293172,"uuid":"174717766","full_name":"bas080/bash-logger","owner":"bas080","description":"Bash logging utility","archived":false,"fork":false,"pushed_at":"2024-11-08T15:10:18.000Z","size":25,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-02T10:53:21.085Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bas080.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2019-03-09T16:25:23.000Z","updated_at":"2023-12-24T13:24:41.000Z","dependencies_parsed_at":"2025-08-02T10:31:00.722Z","dependency_job_id":"2d303210-f61b-46ec-8b15-8189d28c36cb","html_url":"https://github.com/bas080/bash-logger","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bas080/bash-logger","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bas080%2Fbash-logger","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bas080%2Fbash-logger/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bas080%2Fbash-logger/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bas080%2Fbash-logger/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bas080","download_url":"https://codeload.github.com/bas080/bash-logger/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bas080%2Fbash-logger/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28810475,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T07:41:26.337Z","status":"ssl_error","status_checked_at":"2026-01-27T07:41:08.776Z","response_time":168,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":[],"created_at":"2024-12-06T12:18:57.430Z","updated_at":"2026-01-27T09:16:21.959Z","avatar_url":"https://github.com/bas080.png","language":"Shell","readme":"# Bash Logger\n\n\u003e Simple log functionality for bash\n\n- Writes everything to /dev/stderr.\n- STDIN support.\n- Easy to setup.\n\n## Usage\n\nSimply source the script and use the functions it defines.\n\n\n```bash bash 2\u003e\u00261\nsource ./bash-logger; log_error \"error\"\n```\n```\n2022-10-21T10:57:49+02:00[error] error\n```\n\nAn important part of the logger utility is the stdin support.\n\n```bash bash 2\u003e\u00261\nsource ./bash-logger; echo 'warn' | log_warn\n```\n```\n2022-10-21T10:57:49+02:00[warn] warn\n```\n\n## Functions\n\nLet's checkout all the functions that exist.\n\n```bash bash 2\u003e\u00261\ngrep '^function ' ./bash-logger\n```\n```\nfunction log ()\nfunction log_date ()\nfunction log_error() { log 1 \"${1:-}\"; }\nfunction log_warn()  { log 2 \"${1:-}\"; }\nfunction log_info()  { log 3 \"${1:-}\"; }\nfunction log_debug() { log 4 \"${1:-}\"; }\nfunction log_trace() { log 5 \"${1:-}\"; }\n```\n\n## Variables\n\n```bash bash 2\u003e\u00261\ngrep '^LOGGER_[A-Z]*=' ./bash-logger\n```\n```\nLOGGER_FILE=\"${LOGGER_FILE:-/dev/null}\";\nLOGGER_LEVEL=\"${LOGGER_LEVEL:-3}\";\nLOGGER_TEMPLATE=\"${LOGGER_TEMPLATE:-%s[%s] %b\\n}\";\nLOGGER_SILENT=\"${LOGGER_SILENT:-}\"\n```\n\nYou can write the log to a file by defining the `LOGGER_FILE`.\n\n```bash bash 2\u003e\u00261\nsource ./bash-logger; echo 'warn' | LOGGER_FILE=\"./bash-logger.log\" log_info \"info\"\ncat ./bash-logger.log\nrm ./bash-logger.log # Cleaning up\n```\n```\n2022-10-21T10:57:49+02:00[info] info\n2022-10-21T10:57:49+02:00[info] info\n```\n\nHow to use the `LOGGER_LEVEL`?\n\n```bash bash 2\u003e\u00261\nsource ./bash-logger; log_trace \"trace\"\n```\n\nNotice that trace is not printed. By default the `LOGGER_LEVEL` is set to\ninfo(3) by default.\n\n```bash bash 2\u003e\u00261\nsource ./bash-logger; LOGGER_LEVEL=5 log_trace \"trace\"\n```\n```\n2022-10-21T10:57:49+02:00[trace] trace\n```\n\nYou can change the `LOGGER_TEMPLATE` if desired. The template is a printf\ntemplates. See `man printf` for more information.\n\nBy default the `LOGGER_TEMPLATE` is the following.\n\n```bash bash 2\u003e\u00261\nsource ./bash-logger; echo \"$LOGGER_TEMPLATE\";\nsource ./bash-logger; printf \"$LOGGER_TEMPLATE\" '\u003cdatetime\u003e' '\u003ccode\u003e' '\u003cmessage\u003e'\n```\n```\n%s[%s] %b\\n\n\u003cdatetime\u003e[\u003ccode\u003e] \u003cmessage\u003e\n```\n\n## Define your own date.\n\nYou can overwrite the date format by simply defining your own log_date function.\n\n```bash bash 2\u003e\u00261\nsource ./bash-logger;\n\n# Make sure to define your function after sourcing bash-logger.\n\nlog_date() {\n  echo 'my own date'\n}\n\nlog_error 'important'\n```\n```\nmy own date[error] important\n```\n\n## License\n\n[GPLv3](./LICENSE.md)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbas080%2Fbash-logger","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbas080%2Fbash-logger","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbas080%2Fbash-logger/lists"}