Skip to content

Commit dd3c1bb

Browse files
committed
Some fixes and logging
1 parent a18768f commit dd3c1bb

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

lib/beacon_api/controllers/error_controller.ex

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
defmodule BeaconApi.ErrorController do
2+
require Logger
23
use BeaconApi, :controller
34

45
@spec bad_request(Plug.Conn.t(), binary()) :: Plug.Conn.t()
56
def bad_request(conn, message) do
7+
Logger.error("Bad request: #{message}, path: #{conn.request_path}")
68
conn
79
|> put_status(400)
810
|> json(%{
@@ -13,6 +15,7 @@ defmodule BeaconApi.ErrorController do
1315

1416
@spec not_found(Plug.Conn.t(), any) :: Plug.Conn.t()
1517
def not_found(conn, _params) do
18+
Logger.error("Not found resource, path: #{conn.request_path}")
1619
conn
1720
|> put_status(404)
1821
|> json(%{
@@ -23,6 +26,7 @@ defmodule BeaconApi.ErrorController do
2326

2427
@spec internal_error(Plug.Conn.t(), any) :: Plug.Conn.t()
2528
def internal_error(conn, _params) do
29+
Logger.error("Internal server error, path: #{conn.request_path}")
2630
conn
2731
|> put_status(500)
2832
|> json(%{

lib/beacon_api/controllers/v1/beacon_controller.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ defmodule BeaconApi.V1.BeaconController do
3030
conn
3131
|> json(%{
3232
"data" => %{
33-
"genesis_time" => StoreDb.fetch_genesis_time!(),
33+
"genesis_time" => StoreDb.fetch_genesis_time!() |> Integer.to_string(),
3434
"genesis_validators_root" =>
3535
ChainSpec.get_genesis_validators_root() |> Utils.hex_encode(),
3636
"genesis_fork_version" => ChainSpec.get("GENESIS_FORK_VERSION") |> Utils.hex_encode()

lib/beacon_api/controllers/v1/node_controller.ex

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
defmodule BeaconApi.V1.NodeController do
22
use BeaconApi, :controller
33

4+
require Logger
45
alias BeaconApi.ApiSpec
56
alias BeaconApi.Utils
67
alias LambdaEthereumConsensus.Beacon.SyncBlocks
@@ -28,6 +29,7 @@ defmodule BeaconApi.V1.NodeController do
2829

2930
@spec health(Plug.Conn.t(), any) :: Plug.Conn.t()
3031
def health(conn, _params) do
32+
Logger.info("NODE: Health check")
3133
%{is_syncing: syncing?} = SyncBlocks.status()
3234
syncing_status = if syncing?, do: 206, else: 200
3335

@@ -38,6 +40,7 @@ defmodule BeaconApi.V1.NodeController do
3840

3941
@spec identity(Plug.Conn.t(), any) :: Plug.Conn.t()
4042
def identity(conn, _params) do
43+
Logger.info("NODE: Identity check")
4144
metadata = Metadata.get_metadata() |> Utils.to_json()
4245

4346
%{
@@ -61,6 +64,7 @@ defmodule BeaconApi.V1.NodeController do
6164

6265
@spec version(Plug.Conn.t(), any) :: Plug.Conn.t()
6366
def version(conn, _params) do
67+
Logger.info("NODE: Version check")
6468
version = Application.spec(:lambda_ethereum_consensus)[:vsn]
6569
arch = :erlang.system_info(:system_architecture)
6670

@@ -74,6 +78,7 @@ defmodule BeaconApi.V1.NodeController do
7478

7579
@spec syncing(Plug.Conn.t(), any) :: Plug.Conn.t()
7680
def syncing(conn, _params) do
81+
Logger.info("NODE: Syncing check")
7782
%{
7883
is_syncing: is_syncing,
7984
is_optimistic: is_optimistic,
@@ -93,6 +98,7 @@ defmodule BeaconApi.V1.NodeController do
9398

9499
@spec peers(Plug.Conn.t(), any) :: Plug.Conn.t()
95100
def peers(conn, _params) do
101+
Logger.info("NODE: Peers check")
96102
# TODO: (#1325) This is a stub.
97103
conn
98104
|> json(%{

0 commit comments

Comments
 (0)