{"id":16019833,"url":"https://github.com/fabasoad/sh-logging","last_synced_at":"2026-01-26T09:00:36.528Z","repository":{"id":247789164,"uuid":"825139087","full_name":"fabasoad/sh-logging","owner":"fabasoad","description":"Lightweight POSIX shell compatible library for logging","archived":false,"fork":false,"pushed_at":"2026-01-15T22:07:57.000Z","size":37,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-16T01:44:16.015Z","etag":null,"topics":["bpkg-package","logging","logging-library","shell","shell-logging"],"latest_commit_sha":null,"homepage":"","language":"Shell","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/fabasoad.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","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},"funding":{"custom":["https://www.bitcoinqrcodemaker.com/?style=bitcoin\u0026address=145HwyQAcv4vrzUumJhu7nWGAVBysX9jJH\u0026prefix=on","https://paypal.me/fabasoad"],"github":["fabasoad"],"ko_fi":"fabasoad","liberapay":"fabasoad"}},"created_at":"2024-07-06T22:34:49.000Z","updated_at":"2026-01-15T22:08:01.000Z","dependencies_parsed_at":"2024-07-10T16:46:05.768Z","dependency_job_id":"2e1ce830-65a5-4600-a331-f2920ef1919a","html_url":"https://github.com/fabasoad/sh-logging","commit_stats":null,"previous_names":["fabasoad/sh-logging"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/fabasoad/sh-logging","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabasoad%2Fsh-logging","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabasoad%2Fsh-logging/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabasoad%2Fsh-logging/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabasoad%2Fsh-logging/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fabasoad","download_url":"https://codeload.github.com/fabasoad/sh-logging/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fabasoad%2Fsh-logging/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28771503,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-26T08:38:24.014Z","status":"ssl_error","status_checked_at":"2026-01-26T08:38:22.080Z","response_time":59,"last_error":"SSL_read: 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":["bpkg-package","logging","logging-library","shell","shell-logging"],"created_at":"2024-10-08T17:05:35.148Z","updated_at":"2026-01-26T09:00:36.482Z","avatar_url":"https://github.com/fabasoad.png","language":"Shell","funding_links":["https://www.bitcoinqrcodemaker.com/?style=bitcoin\u0026address=145HwyQAcv4vrzUumJhu7nWGAVBysX9jJH\u0026prefix=on","https://paypal.me/fabasoad","https://github.com/sponsors/fabasoad","https://ko-fi.com/fabasoad","https://liberapay.com/fabasoad"],"categories":[],"sub_categories":[],"readme":"# Shell logging\n\n[![Stand With Ukraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/badges/StandWithUkraine.svg)](https://stand-with-ukraine.pp.ua)\n![GitHub release](https://img.shields.io/github/v/release/fabasoad/sh-logging?include_prereleases)\n![security](https://github.com/fabasoad/sh-logging/actions/workflows/security.yml/badge.svg)\n![linting](https://github.com/fabasoad/sh-logging/actions/workflows/linting.yml/badge.svg)\n\nShell library for logging.\n\n## Table of Contents\n\n- [Shell logging](#shell-logging)\n  - [Table of Contents](#table-of-contents)\n  - [Outline](#outline)\n  - [How to use?](#how-to-use)\n    - [Prerequisites](#prerequisites)\n    - [Installation](#installation)\n  - [Features](#features)\n    - [Config file](#config-file)\n    - [Supported parameters](#supported-parameters)\n      - [Log level](#log-level)\n      - [Output format](#output-format)\n      - [Date format](#date-format)\n      - [Header](#header)\n      - [Text color](#text-color)\n      - [Text format](#text-format)\n\n## Outline\n\n- Supports 5 log levels: `debug`, `info`, `warning`, `error`, `off`.\n- Supports 3 output formats: `json`, `xml` and `text`.\n- Supports output customization for `text` output format.\n- Supports colorized/non-colorized printing.\n- Supports customization via environment variables.\n- Supports customization via configuration file.\n\n## How to use?\n\n### Prerequisites\n\nThe following tools have to be available on a machine prior using this library:\n\n- [bash \u003e=4.0](https://www.gnu.org/software/bash/)\n- [jq](https://jqlang.github.io/jq/) - Only if you're using config file or JSON\n  output format.\n\n### Installation\n\n```shell\nbpkg install fabasoad/sh-logging\n```\n\nSee [installation options](https://github.com/bpkg/bpkg?tab=readme-ov-file#installing-packages)\nfor more details.\n\n## Features\n\n### Config file\n\nFor each log function call you can specify a path to config file. Example:\n\n```shell\nfabasoad_log \"info\" \"This is info message\" \"./config.json\"\n```\n\nWhere `./config.json` has the following content:\n\n```json\n{\n  \"version\": \"v0.1.0\",\n  \"config\": {\n    \"date-format\": \"%Y-%m-%d %T\",\n    \"header\": \"fabasoad-log-json\",\n    \"log-level\": \"info\",\n    \"output-format\": \"text\",\n    \"text-color\": false,\n    \"text-format\": \"[\u003cheader\u003e] \u003ctimestamp\u003e level=\u003clevel\u003e \u003cmessage\u003e\"\n  }\n}\n```\n\nIn your application you can wrap this function with your own function, so you do\nnot need to specify all the parameters every time. Example:\n\n```shell\nlog_info() {\n  fabasoad_log \"info\" \"${1}\" \"./config.json\"\n}\n\nlog_info \"This is info message\"\n```\n\n### Supported parameters\n\n#### Log level\n\nLevel of logging to produce.\n\n- Environment variable: `FABASOAD_LOG_CONFIG_LOG_LEVEL`.\n- Possible options: `debug`, `info`, `warning`, `error`, `off`.\n- Default value: `info`.\n\nThe rules are the following:\n\n- If log level is `off` then no logs will be produced.\n- If log level is `debug` then all logs will be produced.\n- If log level is `info` then all logs except of `debug` logs will be produced.\n- If log level is `warning` then only `warning` and `error` logs will be produced.\n- If log level is `error` then only `error` logs will be produced.\n\n#### Output format\n\nThe format of logs to produce.\n\n- Environment variable: `FABASOAD_LOG_CONFIG_OUTPUT_FORMAT`.\n- Possible options: `text`, `json`, `xml`.\n- Default value: `text`.\n\n#### Date format\n\nFormat that passes to [date](https://pubs.opengroup.org/onlinepubs/009695399/utilities/date.html)\nshell command, e.g. if you want `date +%s` to be used then you need to use `%s`.\n\n- Environment variable: `FABASOAD_LOG_CONFIG_DATE_FORMAT`.\n- Possible options: Any `string` value.\n- Default value: `%Y-%m-%d %T`.\n\n#### Header\n\nIt is usually used to mention your program name in the logs. For example, if you\nwant your logs to be something like this:\n\n```text\n[my-app] [error] Validation error!\n```\n\nThen you need to use `my-app` as a header value.\n\n- Environment variable: `FABASOAD_LOG_CONFIG_HEADER`.\n- Possible options: Any `string` value.\n- Default value: `fabasoad-log`.\n\n#### Text color\n\nEnables/disables coloring of the logs output.\n\n- Environment variable: `FABASOAD_LOG_CONFIG_TEXT_COLOR`.\n- Possible options: `true`, `false`.\n- Default value: `true`.\n\n#### Text format\n\nThe format/pattern of the text logs. It works only if output format is set to `text`.\n\n- Environment variable: `FABASOAD_LOG_CONFIG_TEXT_FORMAT`.\n- Possible options: Any `string` value.\n- Default value: `[\u003cheader\u003e] \u003ctimestamp\u003e level=\u003clevel\u003e \u003cmessage\u003e`.\n\nIt supports the following templates: `\u003cheader\u003e`, `\u003ctimestamp\u003e`, `\u003clevel\u003e`,\n`\u003cmessage\u003e`. For example, if you want your logs to be like this:\n\n```text\n[my-app] [info] \"2024-07-14 21:30:47\" Downloading binary\n```\n\nThen you need to set text format to `[\u003cheader\u003e] [\u003clevel\u003e] \"\u003ctimestamp\u003e\" \u003cmessage\u003e`.\n\n## Contributions\n\n![Alt](https://repobeats.axiom.co/api/embed/dbcfa742767def40574e8a3f4b33ca544834b758.svg \"Repobeats analytics image\")\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffabasoad%2Fsh-logging","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffabasoad%2Fsh-logging","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffabasoad%2Fsh-logging/lists"}