Fork me on GitHub
#babashka
<
2022-09-27
>
pavlosmelissinos09:09:07

What do you nice folks usually use to store logs in JSON format? Nothing fancy, so I'm thinking of making my own timbre appender but I'm wondering if I've missed something even more straightforward? Context: Ops people in my team are forcing me to use a log collector that requires JSON logs. 😛

borkdude09:09:11

@pavlos There is this one: https://github.com/viesti/timbre-json-appender/blob/master/src/timbre_json_appender/core.clj But it uses jsonista, so it doesn't work with bb, but you could maybe take it as inspiration

pavlosmelissinos09:09:13

Thanks, I've actually used that in another Clojure project! Babashka offers a lot of stuff out of the box and JSON logs are more or less ubiquitous nowadays, at least in corporate software, so I thought I'd ask in case there was some kind of flag or something that could automatically configure timbre accordingly for me 😛 You've ruined my capability to put effort into making stuff work! Just kidding, I'm just very grateful for bb and all the work you've done for the community 😄

❤️ 1
robert-stuttaford10:09:56

i mean feel free to add a recipe to the bb wiki once you've made one 🙂

👍 1
robert-stuttaford10:09:20

i need to do the same for a file-watcher->run-kondo script that i wrote and then accidentally git reset --hard deleted

borkdude10:09:57

or publish a library for the appender and make a PR to https://babashka.org/toolbox/ :)

borkdude10:09:25

@U0509NKGK oops :) In this case, I usually just do undo in emacs

robert-stuttaford10:09:22

my emacs automatically reverts buffers 😖

robert-stuttaford10:09:44

i was doing a training session so i had done a lot of other shit and closed and reopened etc

robert-stuttaford10:09:56

but thankfully easy to redo, so i'll just redo it heh

❤️ 1
borkdude10:09:13

@U0509NKGK You could also make a script repo like this: https://github.com/borkdude/tools And then anyone else can install your script with #babashka-bbin

borkdude10:09:20

E.g. your colleagues

borkdude10:09:34

But this is more for scripts that are not project specific

Dimitar Uzunov12:09:50

Hey folks, I was wondering if anyone uses babashka or nbb for provisioning servers and workstations; things like using yum or brew, dealing with systemd, templating config files. If so, what has been your experience? This is a rather commodity use I wonder how it compares to more commodity solutions like ansible.

borkdude12:09:01

@dimitar.ouzounoff #spire is intending to be this thing / cc @retrogradeorbit

metal 1
Dimitar Uzunov12:09:06

I don’t really need the SSH support, just a way to do idempotent scripts

Dimitar Uzunov12:09:06

more or less only yum or brew, dealing with systemd, templating config files

borkdude12:09:17

Maybe @U7ERLH6JX also has some ideas on this.

lispyclouds13:09:15

I actually had tried to do system provisioning with some babashka https://book.babashka.org/#tasks but honestly making it idempotent and specially with packages is quite verbose and messy. ended up resorting to ansible, made peace with YAML shit. at least the moving parts are written by smarter folks 😅

🆒 1
lispyclouds13:09:55

i could recommend using https://github.com/liquidz/dad for this maybe? its simpler for local things and for packages etc

borkdude13:09:44

#spire should also work for local systems I think ... @retrogradeorbit

lispyclouds13:09:25

yep it should. was saying dad as its just about packages not much more 😄

borkdude13:09:29

but nix is also a popular option

Dimitar Uzunov13:09:26

kinda wishing there were simply libs for some common idempotent tasks like setting up systemd services and wrappers for various package managers; dad seems neat for its MacOS support

lispyclouds13:09:30

yeah i looked at all but managed to do mac and linux in ansible for brew dnf packages, npm etc etc in a few yaml lines. it just works

Dimitar Uzunov13:09:24

we’ve been using ansible for a few years and I’m facing some refactoring; I was just hoping to write some clojure for this task haha

lispyclouds13:09:46

can use bb to generate ansible yamls maybe 😛

Dimitar Uzunov13:09:51

I’ve thought about that! Not sure what the benefit is other than not writing yaml directly. For larger projects sure, but in this case I want to keep things small if possible

Dimitar Uzunov13:09:12

nix is very cool, but I am afraid of dragging other team members into it

lispyclouds13:09:43

my thoughts precisely. went down the killing yaml route with clj/edn only to realise the amount of work needed to be at par with off the shelf things

Crispin13:09:12

spire can run locally too

Crispin13:09:45

You use the local transport. Which is the default

Crispin13:09:53

also supports sudo which can be helpful

Crispin13:09:28

at the moment spire is one big uberproject. There's a lot of things wrapped up together. But it can do what you want. It's just become cumbersome to work on spire itself. I am in the process of decomplecting it into its parts. If you did use spire there should be a path forwards to use one of the parts when it is broken out.

👍 1
lispyclouds13:09:39

complementary nix meme

😆 3
Crispin13:09:19

sometimes you just have to get all messy...

Crispin13:09:56

ansible smeared all over your face

lispyclouds13:09:35

yeah you aint coded well until youve taken down prod due to an indentation error

borkdude13:09:35

My nix config: install ansible

borkdude13:09:07

Well now that's what I avoid YAML for ;)

borkdude13:09:22

Take a look in #clj-yaml for more hate

Dimitar Uzunov13:09:27

well it could be bash generating yaml

Crispin13:09:38

my yaml is one giant json string on a single line

Crispin13:09:43

you could make clojure the most popular language in the universe by just converting yaml to edn and having everyone write it in yaml

1
lispyclouds13:09:16

i would say no to that but not sure if it could be misunderstood

Crispin13:09:42

wait wait... hear me out... 😄 /s

borkdude13:09:12

We could change s-expressions to YAML too right?

Crispin13:09:36

exactly. The worse you make it, the more popular it will be

Dimitar Uzunov13:09:58

that is an Aprils fool joke right there - a Clojure written in yaml syntax

Crispin13:09:11

and give the new langauge an acronym for a name... YFC (yaml flavoured clojure)

borkdude13:09:13

Python is already kind of YAML to me

Dimitar Uzunov13:09:46

that is actually one of the bad parts of ansible - it is not supposed to be a programming language yet it sneaks some programmy things to lure you in. But you want to run roles in parallel? Tough luck unless you want to do include_role tricks

Crispin13:09:33

yep. python and jmespath escaped and templated into strings inside yaml inside of python. sweeeeeet.

borkdude13:09:13

Bring back XML

lispyclouds13:09:16

youre forgetting deploy to k8s

Dimitar Uzunov13:09:43

opened a epub file in Emacs and wow it is all xml, how cool is that

Crispin13:09:45

xml clojure?

Crispin13:09:05

every s-exp is a tag and and end tag

borkdude13:09:07

YAMLX - JSX-flavored YAML, aka XML! We can hype this first among the JS people because they like JSX which is close enough to XML

Crispin13:09:37

<println>How awesome is xmoljure!</println>

borkdude13:09:05

I'll take JSON any time of the day over YAML, but it's unfortunate that they still require comma's and have no comments

borkdude13:09:41

I have promised to myself no more YAML rants within the next week on my twitter

Crispin13:09:57

it reads like you've been in therapy @U04V15CAJ

Crispin13:09:32

there is a plan underway to break the idempotent scripts out of spire. You are not the only one who wants just the idempotent parts. It's not done yet, unfortunately.

1
adi14:09:11

I juuuust republished https://www.evalapply.org/, built with my own hot-reloading (no Javascript) site maker, https://github.com/adityaathalye/shite which is written in (fairly Clojurish) Bash, for <reasons> 🤓. At some point I'm going to write a clone in Babashka. The README describes goals dreams, design details etc. If anyone here is interested in pairing on it, hit me up!

🎉 3
teodorlu15:09:04

Oooh, this looks like something I'm going to enjoy looking into. My own 💩e is a babashka cli: https://github.com/teodorlu/play.teod.eu/blob/master/play.clj But it's really asking for a rewrite away from Makefile generation towards pure bb. Interested in pairing, but I'm cronically suffering from "very full calendar syndrome".

adi05:09:54

> My own e is a babashka cli: Thanks for sharing your project, @U3X7174KS! I skimmed the code and directory layout. I noticed some design choices that you've made that I considered too. Where to keep page metadata? Where to publish html content? Should each page be standalone (e.g. include <style>?)? etc. I went down a different path. > Interested in pairing, but I'm cronically suffering from "very full calendar syndrome". Haha, I've been suffering from "chronically sidetracked" syndrome. I was supposed to blog as I made the project, but then I got totally sucked into making the project and wrote zero posts 😆 So now, on my immediate agenda is to finish the blog post series on shite. I'll do the bb yak shave only after that (I hope after and not in-between 😆).

❤️ 1
🔥 1
teodorlu06:09:25

> So now, on my immediate agenda is to finish the blog post series on shite. I'll do the bb yak shave only after that (I hope after and not in-between 😆). > I'm very much looking forward to reading those! 👌

🙌 1
borkdude08:09:21

Also https://github.com/borkdude/quickblog exists, in case you need more references :)

1
adi09:09:31

Very aware, and very intent on stealing liberally :) Code size while maintaining feature parity is going to be one of my hard-line design constraints. Right now the entire "business logic" of my system weighs in at about 350 LoC of FP-style Bash measured crudely, including all the functionality named by these files:

grep -E -v "\s?\#|^$" ./shite.sh ./bin/{events,metadata,templating,utils,hotreload}.sh | wc -l

358
HTML template Heredocs are excluded because they're (mainly) "just data" ./bin/templates.sh. Note: the full-rebuild performance is shite, but I care about interactive writing, which works acceptably well, so I'll fix the build speed maybe later.

🔥 1
adi12:09:40

@U3X7174KS the code doesn't really show it, so I updated the README with usage demo GIFs to show how it (frequently) works https://github.com/adityaathalye/shite#usage-demo

❤️ 1
teodorlu13:09:18

Nice! :star-struck:

gotta_go_fast 1