Skip to content

Replace debug IO.puts statements with proper Logger calls in copi.owasp.org #2287

@immortal71

Description

@immortal71

Description

The copi.owasp.org/lib/copi_web/live/player_live/show.ex file contains several IO.puts debug statements that should be replaced with proper Logger calls.

Issue

In production Elixir applications, IO.puts is not appropriate for logging because:

  1. It writes directly to stdout without any log level context
  2. Output is not captured by structured logging systems (e.g., Logger backends)
  3. Can't be filtered or controlled via log level configuration
  4. No metadata (timestamp, module, function) is included
  5. Not suitable for production monitoring and debugging

Location

File: copi.owasp.org/lib/copi_web/live/player_live/show.ex

The following debug statements need to be replaced:

Line 112:

IO.puts("Continue vote added successfully")

Line 114:

IO.puts("Continue voting failed")

Line 135:

IO.puts("player has voted")

Line 138:

IO.puts("player hasn't voted")

Line 141:

IO.puts("voted successfully")

Line 143:

IO.puts("voting failed")

Proposed Solution

Replace all IO.puts statements with appropriate Logger calls:

  • Success messagesLogger.debug/1 (since these are routine operations)
  • Error messagesLogger.warning/1 or Logger.error/1 (for failed operations)

Example replacements:

# Before
IO.puts("Continue vote added successfully")

# After
Logger.debug("Continue vote added successfully for player_id: #{player.id}, game_id: #{game.id}")
# Before
IO.puts("Continue voting failed")

# After  
Logger.warning("Continue voting failed for player_id: #{player.id}, game_id: #{game.id}")

Additional Context

This appears to be leftover debug code from development. The rest of the codebase properly uses Logger (e.g., in rate_limiter.ex and user_socket.ex), so this should be updated for consistency.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions