Skip to content

Commit

Permalink
Rename the logger package to log
Browse files Browse the repository at this point in the history
  • Loading branch information
Piszmog committed Feb 8, 2024
1 parent 0ce8203 commit 0235ca4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ Everything else uses the standard library.
│   └── dist.go
├── go.mod
├── go.sum
├── logger
│   └── logger.go
├── log
│   └── log.go
├── main.go
├── server
│   ├── handler
Expand Down Expand Up @@ -85,7 +85,7 @@ Note, the `dist/assets/css` will be ignored by `git` (configured in `.gitignore`
files that are written to this directory are done by the Tailwind CSS CLI. Custom styles should
go in the `styles/input.css` file.

### Logger
### Log

This contains helper function to create a `slog.Logger`.

Expand Down
2 changes: 1 addition & 1 deletion logger/logger.go → log/log.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package logger
package log

import (
"log/slog"
Expand Down
16 changes: 8 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,37 @@ package main
import (
"context"
"go-htmx-template/db"
"go-htmx-template/logger"
"go-htmx-template/log"
"go-htmx-template/server"
"go-htmx-template/server/router"
"os"
)

func main() {
log := logger.New(
logger.GetLevel(),
logger.GetOutput(),
logger := log.New(
log.GetLevel(),
log.GetOutput(),
)

database, err := db.NewSQLite("./db.sqlite3")
if err != nil {
log.Error("Failed to create database", "error", err)
logger.Error("Failed to create database", "error", err)
os.Exit(1)
}
defer database.Close()

err = db.InitSchema(context.Background(), database)
if err != nil {
log.Error("Failed to initialize schema", "error", err)
logger.Error("Failed to initialize schema", "error", err)
os.Exit(1)
}

queries := db.New(database)

svr := server.New(
log,
logger,
":8080",
server.WithRouter(router.New(log, queries)),
server.WithRouter(router.New(logger, queries)),
)

svr.StartAndWait()
Expand Down

0 comments on commit 0235ca4

Please sign in to comment.