Skip to content

feat: set logger level by env PICOCLAW_LOG_LEVEL#1139

Closed
lanmaoxinqing wants to merge 2 commits intosipeed:mainfrom
lanmaoxinqing:main
Closed

feat: set logger level by env PICOCLAW_LOG_LEVEL#1139
lanmaoxinqing wants to merge 2 commits intosipeed:mainfrom
lanmaoxinqing:main

Conversation

@lanmaoxinqing
Copy link
Copy Markdown

📝 Description

Add support for PICOCLAW_LOG_LEVEL environment variable to allow users to control log level via environment variable, hiding intermediate log outputs such as tool calls during execution.

🗣️ Type of Change

  • 🐞 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 📖 Documentation update
  • ⚡ Code refactoring (no functional changes, no api changes)

🤖 AI Code Generation

  • 🤖 Fully AI-generated (100% AI, 0% Human)
  • 🛠️ Mostly AI-generated (AI draft, Human verified/modified)
  • 👨‍💻 Mostly Human-written (Human lead, AI assisted or none)

📚 Technical Context (Skip for Docs)

when executing picoclaw agent -m "task", the log output is too verbose, especially for tool call logs. By adding environment variable support, users can set log level to WARN or ERROR to hide INFO-level tool call logs.

🧪 Test Environment

  • Hardware: PC
  • OS: macOS
  • Model/Provider:
  • Channels:

📸 Evidence (Optional)

  # Usage
  export PICOCLAW_LOG_LEVEL=WARN
  picoclaw agent -m "your task"

  # Supported log levels (case-insensitive)
  # DEBUG, INFO, WARN, WARNING, ERROR, FATAL

Xnip2026-03-05_18-53-51

☑️ Checklist

  • My code/docs follow the style of this project.
  • I have performed a self-review of my own changes.
  • I have updated the documentation accordingly.

lanmaoxinqing and others added 2 commits March 5, 2026 15:19
Add comprehensive test coverage for the parseLevel function that supports
parsing log level from PICOCLAW_LOG_LEVEL environment variable.

Co-Authored-By: Claude (MiniMax-M2.5) <noreply@anthropic.com>
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 5, 2026

CLA assistant check
All committers have signed the CLA.

@sipeed-bot sipeed-bot bot added type: enhancement New feature or request domain: config labels Mar 5, 2026
@yinwm
Copy link
Copy Markdown
Collaborator

yinwm commented Mar 11, 2026

⚠️ Compatibility Notice

This PR needs to be checked for compatibility with #1239 (refactor logger to zerolog).

#1239 has been merged to main and introduced significant changes to the logger:

  1. init() function completely rewritten - This PR is based on the old implementation
  2. Logger struct removed - logger = &Logger{} will cause compilation failure
  3. zerolog has built-in ParseLevel() - No need to write a custom parseLevel function

Suggested Changes

func init() {
    once.Do(func() {
        zerolog.SetGlobalLevel(zerolog.InfoLevel)
        consoleWriter := zerolog.ConsoleWriter{
            Out:        os.Stdout,
            TimeFormat: "15:04:05",
        }
        logger = zerolog.New(consoleWriter).With().Timestamp().Logger()
        fileLogger = zerolog.Logger{}
    })

    // Support PICOCLAW_LOG_LEVEL environment variable
    if levelStr := os.Getenv("PICOCLAW_LOG_LEVEL"); levelStr != "" {
        if level, err := zerolog.ParseLevel(levelStr); err == nil {
            SetLevel(level)
        }
    }
}

Please rebase onto the latest main branch and adapt to the zerolog implementation.


🤖 Detected by Claude Code

@yinwm
Copy link
Copy Markdown
Collaborator

yinwm commented Mar 25, 2026

Closing this PR as #1853 (config-based log level setting) has already been merged. The config file approach provides a more comprehensive solution for log level configuration. If you still need environment variable support for CI/CD scenarios, please feel free to reopen or open a new PR discussing the use case.

@yinwm yinwm closed this Mar 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants