Skip to content

Commit 6f531a6

Browse files
committed
Add records.sh logging library package
1 parent d13320d commit 6f531a6

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

Diff for: _posts/2023-06-13-orbit-onlinerecordssh.md

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
layout: post
3+
title: "orbit online/records.sh"
4+
description: "A small logging library for bash. Supports `cli`, `json`, `logfmt`, and custom formats. Integrates with journald and Github actions."
5+
category: bash
6+
tags: [library, logging]
7+
---
8+
9+
See https://github.com/orbit-online/records.sh for the full README and more
10+
advanced use-cases.
11+
12+
## Usage
13+
14+
Source the script with `source "records.sh"` and log messages with the
15+
lowercased loglevel as the function name:
16+
17+
```
18+
debug 'Starting up.'
19+
verbose 'Startup completed'
20+
info 'Hello world!'
21+
warning 'Careful!'
22+
error 'Oh no!'
23+
```
24+
25+
The method signature of the logging functions mimic that of `printf`:
26+
`info FORMAT [ARGS...]`. Which means you can format variables.
27+
28+
```
29+
$ var=0x1f
30+
$ info "The decimal version of %s is %d" "$var" "$var"
31+
example.sh: The decimal version of 0x1f is 31
32+
```
33+
34+
All log messages are output to stderr. If you want to log something to stdout
35+
simply run e.g. `info 'message' 2>&1`.
36+
37+
## Links
38+
39+
- [Source Code (GitHub)][https://github.com/orbit-online/records.sh]
40+
- [Author: Orbit Online A/S (Anders Ingemann)](https://orbit.online)
41+
42+
{% include JB/setup %}

0 commit comments

Comments
 (0)