Skip to content

Commit 14cd6eb

Browse files
author
sfomuseumbot
committed
improved logging for app/account/add
1 parent 8f48eb7 commit 14cd6eb

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

app/account/add/add.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"fmt"
99
"image"
1010
"io"
11+
"log/slog"
1112
"net/url"
1213
"os"
1314
"regexp"
@@ -47,6 +48,8 @@ func RunWithFlagSet(ctx context.Context, fs *flag.FlagSet) error {
4748

4849
func RunWithOptions(ctx context.Context, opts *RunOptions) error {
4950

51+
logger := slog.Default()
52+
5053
accounts_db, err := database.NewAccountsDatabase(ctx, opts.AccountsDatabaseURI)
5154

5255
if err != nil {
@@ -80,6 +83,15 @@ func RunWithOptions(ctx context.Context, opts *RunOptions) error {
8083
}
8184

8285
if acct_taken {
86+
87+
other_acct, err := accounts_db.GetAccountWithName(ctx, opts.AccountName)
88+
89+
if err != nil {
90+
logger.Error("Failed to retrieve record for account with taken name", "name", opts.AccountName)
91+
} else {
92+
logger.Warn("Account with name already exists", "name", opts.AccountName, "id", other_acct.Id)
93+
}
94+
8395
return fmt.Errorf("Account name is not available")
8496
}
8597

@@ -254,5 +266,6 @@ func RunWithOptions(ctx context.Context, opts *RunOptions) error {
254266
}
255267
}
256268

269+
logger.Info("Account created", "id", a.Id)
257270
return nil
258271
}

0 commit comments

Comments
 (0)