Skip to content

Commit 9d72b9c

Browse files
committed
#38: use slog
Signed-off-by: plutov <a.pliutau@gmail.com>
1 parent 58b1d68 commit 9d72b9c

20 files changed

+79
-587
lines changed

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2024 Alex Pliutau
3+
Copyright (c) 2025 Alex Pliutau
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+8-32
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
<p align="center" width="100%">
2-
<img src="https://github.com/plutov/formulosity/blob/main/ui/public/logo_wide.png" height="100px">
3-
</p>
1+
<img src="https://github.com/plutov/formulosity/blob/main/ui/public/logo_wide.png" height="100px">
42

5-
<p align="center">
6-
Formulosity is a self-hosted app for building and deploying the surveys using code instead of traditional survey builders.
7-
</p>
3+
## Formulosity - self-hosted Surveys as Code platform.
84

95
This approach offers a number of advantages, including:
106

@@ -14,9 +10,7 @@ This approach offers a number of advantages, including:
1410

1511
**Formulosity** uses human-readable declarative language [YAML](https://en.wikipedia.org/wiki/YAML).
1612

17-
<p align="center" width="100%">
18-
<img src="https://github.com/plutov/formulosity/blob/main/ui/public/questions.png" height="250px">
19-
</p>
13+
<img src="https://github.com/plutov/formulosity/blob/main/ui/public/questions.png" height="250px">
2014

2115
## Features
2216

@@ -38,13 +32,9 @@ This approach offers a number of advantages, including:
3832
- [ ] Advanced question types
3933
- [ ] Pipe answers into the following questions
4034

41-
## See it in Action!
42-
43-
<p align="center" width="100%">
44-
<a href="https://formulosity.vercel.app/app">Admin Panel</a>
45-
</p>
35+
## Demo
4636

47-
Note: use `user` / `pass` to login into the Console UI.
37+
[Demo admin panel](https://formulosity.vercel.app/app). Credentials: `user` / `pass`
4838

4939
## Survey Structure
5040

@@ -64,7 +54,7 @@ surveys/
6454
└── ...
6555
```
6656

67-
To get started, check out the `./surveys` folder with multiple examples.
57+
To get started, check out the `./api/surveys` folder with multiple examples.
6858

6959
## Survey Files
7060

@@ -297,7 +287,7 @@ Where `{SURVEY_ID}` id the UUID of a given survey.
297287
docker-compose up -d --build
298288
```
299289
300-
And you should be able to access the UI on http://localhost:3000 (default basic auth: `user:pass`).
290+
And you should be able to access the UI on [localhost:3000](http://localhost:3000) (default basic auth: `user:pass`).
301291
302292
You can deploy individual services to any cloud provider or self host them.
303293
@@ -307,28 +297,14 @@ You can deploy individual services to any cloud provider or self host them.
307297
308298
The demo service (links above) is deployed to Fly.io (Go, SQLite) and Vercel (Next.js) and are under the free tiers.
309299
310-
### Backend Development setup
311-
312-
Install AIR locally from [here](https://github.com/air-verse/air)
313-
314-
Run the following command after AIR installation
315-
316-
```
317-
cd api
318-
air
319-
```
320-
321-
This command will help in live reloading whenever changes are done in the APIs using `air`.
322-
Custom configurations can be set by modifying `air.toml` file
323-
324300
### Environment Variables
325301
326302
API:
327303
328304
- `DATABASE_TYPE` - `sqlite` or `postgres`
329305
- `DATABASE_URL` - Postgres or SQLite connection string
330-
- `LOG_LEVEL` - Log level, e.g. `info`
331306
- `SURVEYS_DIR` - Directory with surveys, e.g. `/root/surveys`. It's suggested to use mounted volume for this directory.
307+
- `UPLOADS_DIR` - Directory for uploading files from the survey forms.
332308
333309
UI:
334310

api/.air.toml

-51
This file was deleted.

api/cmd/console-api/api.go

+7-12
Original file line numberDiff line numberDiff line change
@@ -4,36 +4,31 @@ import (
44
"os"
55

66
controllers "github.com/plutov/formulosity/api/pkg/controllers"
7-
"github.com/plutov/formulosity/api/pkg/log"
87
"github.com/plutov/formulosity/api/pkg/services"
98
"github.com/plutov/formulosity/api/pkg/surveys"
109
)
1110

1211
func main() {
13-
log.Named("console-api")
14-
logLevel := "info"
15-
if os.Getenv("LOG_LEVEL") != "" {
16-
logLevel = os.Getenv("LOG_LEVEL")
17-
}
18-
log.SetLogLevel(logLevel)
19-
2012
svc, err := services.InitServices()
2113
if err != nil {
22-
log.WithError(err).Fatal("unable to init dependencies")
14+
svc.Logger.Error("unable to init dependencies", "err", err)
15+
os.Exit(1)
2316
}
2417

2518
if err := surveys.SyncSurveys(svc); err != nil {
26-
log.WithError(err).Fatal("unable to sync surveys")
19+
svc.Logger.Error("unable to sync surveys", "err", err)
20+
os.Exit(1)
2721
}
2822

2923
handler := controllers.NewHandler(svc)
3024
if err != nil {
31-
log.WithError(err).Fatal("unable to start server")
25+
svc.Logger.Error("unable to start server", "err", err)
26+
os.Exit(1)
3227
}
3328

3429
r := controllers.NewRouter(handler)
3530

3631
if err := r.Start(":8080"); err != nil {
37-
log.WithError(err).Fatal("shutting down the server")
32+
svc.Logger.Info("shutting down the server", "err", err)
3833
}
3934
}

api/pkg/controllers/surveys.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77

88
"github.com/labstack/echo/v4"
99
"github.com/plutov/formulosity/api/pkg/http/response"
10-
"github.com/plutov/formulosity/api/pkg/log"
1110
surveyspkg "github.com/plutov/formulosity/api/pkg/surveys"
1211
"github.com/plutov/formulosity/api/pkg/types"
1312
)
@@ -61,7 +60,7 @@ type updateSurveyReq struct {
6160
func (h *Handler) getSurveys(c echo.Context) error {
6261
surveys, err := h.Storage.GetSurveys()
6362
if err != nil {
64-
log.WithError(err).Error("failed to get surveys")
63+
h.Services.Logger.Error("failed to get surveys", "err", err)
6564
return response.InternalErrorDefaultMsg(c)
6665
}
6766

api/pkg/log/entry.go

-188
This file was deleted.

0 commit comments

Comments
 (0)