Welcome to Trifle Documentation
Opinionated Swiss Army knife of little big tools.
These gems came from necessity of building better solutions to common problems. Tired of using shitty analytics and reading through shitty log output. These are small and simple. And that is OK. It is not one solution fits all type of things.
All gems from this collection are released under MIT license.
Made by galons of ☕️ and 🍺 by JozefVaclavik.
Trifle::Docs
for ruby
.
Simple router for your static documentation. Like markdown, or textile, or whatever files.
It maps your docs folder structure into URLs and renders them within the simplest template possible.
It turns your docs/example/snippet.md
file
---
title: Snippet
---
# Snippet
This is snippet.
And renders it as example/snippet
with
<!DOCTYPE html>
<html lang="en">
<head>
<title>Trifle::Docs</title>
</head>
<body>
<h1 id="snippet">Snippet</h1>
<p>This is snippet.</p>
</body>
</html>
Templates are completely in your control, you just use few provided variables.
More here.
Trifle::Logs
for ruby
.
Simple log storage where you can dump your data. It allows you to search on top of your log files with ripgrep
for fast regexp queries and utilises head
and tail
to paginate through a file.
It dumps your data
Trifle::Logs.dump('test', 'This is test message')
Trifle::Logs.dump('test', 'Or another message')
Trifle::Logs.dump('test', 'That noone cares about')
And lets you search on top of it
search = Trifle::Logs.searcher('test', pattern: 'test')
search.perform.data
[
{
"type"=>"match",
"data"=>{
"path"=>{"text"=>"<stdin>"},
"lines"=>{"text"=>"2022-09-17T08:33:04.843195 {\"scope\":{},\"content\":\"This is test message\"}\n"},
"line_number"=>1,
"absolute_offset"=>0,
"submatches"=>[{"match"=>{"text"=>"test"}, "start"=>58, "end"=>62}]
}
}
]
More here.
Trifle::Stats
for ruby
.
Simple analytics backed by Redis, Postgres, MongoDB, Google Analytics, Segment, or whatever.
It gets you from having bunch of these occuring within few minutes
Trifle::Stats.track(key: 'event::logs', at: Time.now, values: { count: 1, duration: 2, lines: 241 })
Trifle::Stats.track(key: 'event::logs', at: Time.now, values: { count: 1, duration: 1, lines: 56 })
Trifle::Stats.track(key: 'event::logs', at: Time.now, values: { count: 1, duration: 5, lines: 361 })
To being able to say what happened on 25th January 2021.
Trifle::Stats.values(key: 'event::logs', from: Time.now, to: Time.now, range: :day)
=> {:at=>[2021-01-25 00:00:00 +0100], :values=>[{"count"=>3, "duration"=>8, "lines"=>658}]}
More here.
Trifle::Traces
for ruby
.
Simple log tracer that collects messages and values from your code and returns Hash (at least for now).
It saves you from reading through your standard logger
Trifle::Traces.trace('This is important output')
now = Trifle::Traces.trace('And it\'s important to know it happened at') do
Time.now
end
To being able to say what happened on 25th January 2021.
[
{at: 2021-01-25 00:00:00 +0100, message: 'This is important output', state: :success, head: false, meta: false}
{at: 2021-01-25 00:00:00 +0100, message: 'And it\'s important to know it happened ', state: :success, head: false, meta: false}
{at: 2021-01-25 00:00:00 +0100, message: '=> 2021-01-25 00:00:00 +0100', state: :success, head: false, meta: true}
]
More here.
Trifle.Stats
for elixir
.
Simple analytics backed by MongoDB (others coming eventually).
It gets you from having bunch of these occuring within few minutes
Trifle.Stats.track('event::logs', DateTime.utc_now(), %{count: 1, duration: 2, lines: 241})
Trifle.Stats.track('event::logs', DateTime.utc_now(), %{count: 1, duration: 1, lines: 56})
Trifle.Stats.track('event::logs', DateTime.utc_now(), %{count: 1, duration: 5, lines: 3611})
To being able to say what happened on 19th August 2023.
Trifle.Stats.values('event::logs', DateTime.utc_now, DateTime.utc_now, :day)
%{at: [#DateTime<2023-08-19 00:00:00+02:00 CEST Europe/Bratislava>], values: [%{"count" => 3, "duration" => 8, "lines" => 658}]}
More here.