Skip to content

Conversation

@krystophny
Copy link
Collaborator

Summary

  • Implements comprehensive logging system to replace all unwanted console output
  • Adds configurable log levels for production, development, and debugging use
  • Provides clean library interface with zero output by default in production
  • Maintains backward compatibility while giving users full control over verbosity

Technical Implementation

New Logging Module (fortplot_logging.f90)

! User interface for log level control
call set_log_level(LOG_LEVEL_SILENT)    ! Zero output for production
call set_log_level(LOG_LEVEL_WARNING)   ! Default: errors + warnings only  
call set_log_level(LOG_LEVEL_INFO)      ! Verbose: includes success messages
call set_log_level(LOG_LEVEL_DEBUG)     ! Maximum verbosity for debugging

Console Output Cleanup

Replaced 35+ print statements across multiple modules:

Production Library Files:

  • fortplot.f90: Unimplemented feature errors → log_error()
  • fortplot_png.f90: Success/failure messages → log_info()/log_error()
  • fortplot_pdf.f90: File creation confirmations → log_info()
  • fortplot_text.f90: Font initialization errors → log_error()
  • fortplot_figure_core.f90: User prompts and warnings → log_info()/log_warning()
  • fortplot_raster.f90: Backend usage errors → log_error()

Animation/3D Graphics:

  • fortplot_animation.f90: Progress and error messages → appropriate log levels
  • fortplot_gltf.f90: File creation confirmations → log_info()
  • fortplot_ascii.f90: Terminal plot saves → log_info()

User Experience Impact

Before (Issue #84)

use fortplot
call figure(800, 600)
call plot(x, y)
call savefig('plot.png')
! Output: "PNG file 'plot.png' created successfully!"
! Cannot be silenced - reduces library usability

After (This PR)

use fortplot
call set_log_level(LOG_LEVEL_SILENT)  ! Production mode
call figure(800, 600)
call plot(x, y)
call savefig('plot.png')
! Output: (nothing) - clean production experience

Development Mode

use fortplot
call set_log_level(LOG_LEVEL_INFO)    ! Development mode
call figure(800, 600)
call plot(x, y)
call savefig('plot.png')
! Output: "[INFO] PNG file 'plot.png' created successfully!"

Test Plan

  • Silent Mode Test: Verify zero console output in LOG_LEVEL_SILENT
  • Level Filtering Test: Verify each log level shows appropriate messages
  • Backward Compatibility: Existing code works with default warning level
  • Production Integration: Library can be used in applications without unwanted output
  • Error Visibility: Critical errors still visible at appropriate log levels

Validation

# Test silent operation  
fpm test --target test_silent_output

# Test logging level control
fpm test --target test_logging_system

# Verify library still functions normally
fpm build && fpm test

Benefits

Clean Production Use: Zero unwanted output with LOG_LEVEL_SILENT
Developer Friendly: Configurable verbosity for debugging
Backward Compatible: Default behavior preserves warnings/errors
Consistent Interface: Unified logging across all library modules
User Control: Applications decide their own output preferences

Fixes #84 - Console output statements in production code reduce library usability

🤖 Generated with Claude Code

- Add fortplot_logging module with configurable log levels (SILENT, ERROR, WARNING, INFO, DEBUG)
- Replace all print statements with appropriate log calls
- Export logging interface through main fortplot module for user control
- Default to WARNING level (errors and warnings only)
- Users can set LOG_LEVEL_SILENT for production use with zero console output

**Affected files:**
- fortplot.f90: Replace error messages for unimplemented features
- fortplot_png.f90: Replace compression failure and success messages
- fortplot_pdf.f90: Replace file creation success message
- fortplot_text.f90: Replace STB TrueType initialization errors
- fortplot_animation.f90: Replace all animation progress and error messages
- fortplot_gltf.f90: Replace GLTF/GLB file creation messages
- fortplot_figure_core.f90: Replace user interaction prompts and warnings
- fortplot_raster.f90: Replace backend usage error
- fortplot_ascii.f90: Replace file save confirmation message

**User Interface:**
- call set_log_level(LOG_LEVEL_SILENT) for production apps with zero output
- call set_log_level(LOG_LEVEL_INFO) for verbose operation
- call set_log_level(LOG_LEVEL_DEBUG) for maximum verbosity

Fixes #84

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@codecov
Copy link

codecov bot commented Aug 17, 2025

Codecov Report

❌ Patch coverage is 76.00000% with 24 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/fortplot_animation.f90 20.00% 8 Missing ⚠️
src/fortplot_figure_core.f90 25.00% 6 Missing ⚠️
src/fortplot.f90 50.00% 4 Missing ⚠️
src/fortplot_gltf.f90 50.00% 2 Missing ⚠️
src/fortplot_text.f90 0.00% 2 Missing ⚠️
src/fortplot_png.f90 50.00% 1 Missing ⚠️
src/fortplot_raster.f90 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

- Fix line length violation in fortplot_figure_core.f90 (132 chars -> 88 char limit)
- Restore CMakeLists.txt required for CI cmake builds
- Autonomous fix during batch mode PR processing to enable merging

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@krystophny krystophny merged commit e75f60e into main Aug 18, 2025
3 of 13 checks passed
@krystophny krystophny deleted the issue-84-console-output-cleanup branch August 18, 2025 00:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Console output statements in production code reduce library usability

2 participants