โ† Back to Skills Marketplace
supermario11

Cuihua Logger

by supermario11 ยท GitHub โ†— ยท v1.0.0 ยท MIT-0
cross-platform โš  suspicious
133
Downloads
0
Stars
0
Active Installs
1
Versions
Install in OpenClaw
/install cuihua-logger
Description
๐Ÿ“ AI-powered logging assistant that generates production-ready structured logs. Automatically add intelligent logging to your code with proper levels, conte...
README (SKILL.md)

cuihua-logger - Production-Ready Logging ๐Ÿ“

Debug faster with intelligent, structured logging.

An AI-powered logging assistant that automatically:

  • ๐Ÿ“ Generates structured logs with proper context
  • ๐ŸŽฏ Selects appropriate log levels (debug, info, warn, error)
  • ๐Ÿ“Š Adds performance metrics and timing
  • ๐Ÿ” Detects missing logs in critical paths
  • โšก Optimizes log output for production

๐ŸŽฏ Why cuihua-logger?

The problem:

  • โŒ Too many console.log() everywhere
  • โŒ No structure, hard to search
  • โŒ Wrong log levels (everything is "info")
  • โŒ Missing context (what user? what request?)
  • โŒ Performance overhead in production

cuihua-logger solves all of this.


๐Ÿš€ Quick Start

Analyze logging coverage

"Check logging coverage in src/"

Add structured logging

"Add logging to getUserById function"

Generate performance logs

"Add performance logging to API endpoints"


๐ŸŽจ Features

1. Structured Logging โœจ

// โŒ BEFORE - Unstructured
async function getUserById(id) {
  console.log('Getting user:', id);
  const user = await db.query('SELECT * FROM users WHERE id = $1', [id]);
  console.log('User found:', user);
  return user;
}

// โœ… AFTER - Structured
async function getUserById(id) {
  logger.info('Fetching user', { 
    userId: id,
    operation: 'getUserById'
  });
  
  const startTime = Date.now();
  const user = await db.query('SELECT * FROM users WHERE id = $1', [id]);
  const duration = Date.now() - startTime;
  
  logger.info('User fetched successfully', {
    userId: id,
    operation: 'getUserById',
    duration,
    found: !!user
  });
  
  return user;
}

2. Smart Log Levels ๐ŸŽฏ

// Automatic level selection based on context

logger.debug('Cache hit', { key, ttl }); // Development only

logger.info('User logged in', { userId, ip }); // Important events

logger.warn('Rate limit approaching', { 
  userId, 
  current: 95, 
  limit: 100 
}); // Potential issues

logger.error('Payment failed', { 
  orderId, 
  error: error.message,
  stack: error.stack 
}); // Critical errors

3. Performance Logging โšก

async function fetchData() {
  const timer = logger.startTimer();
  
  const data = await expensiveOperation();
  
  timer.done({ level: 'info', message: 'Operation complete' });
  
  return data;
}

// Output: "Operation complete" duration=1234ms

4. Request Tracking ๐Ÿ”

app.use((req, res, next) => {
  req.requestId = generateId();
  req.logger = logger.child({ 
    requestId: req.requestId,
    method: req.method,
    path: req.path 
  });
  
  req.logger.info('Request started');
  
  res.on('finish', () => {
    req.logger.info('Request completed', {
      statusCode: res.statusCode,
      duration: Date.now() - req.startTime
    });
  });
  
  next();
});

๐Ÿ“‹ Usage Examples

Example 1: Add Logging to Function

User: "Add logging to processOrder function"

Generated:

async function processOrder(orderId, items) {
  logger.info('Processing order', { orderId, itemCount: items.length });
  
  try {
    // Validate
    if (!orderId || !items.length) {
      logger.warn('Invalid order data', { orderId, items });
      throw new ValidationError('Invalid order');
    }
    
    // Create order
    const order = await createOrder(orderId, items);
    logger.info('Order created', { orderId, orderNumber: order.number });
    
    // Process payment
    const payment = await processPayment(order);
    logger.info('Payment processed', { 
      orderId, 
      paymentId: payment.id,
      amount: payment.amount 
    });
    
    return order;
    
  } catch (error) {
    logger.error('Order processing failed', {
      orderId,
      error: error.message,
      stack: error.stack
    });
    throw error;
  }
}

Example 2: API Endpoint Logging

app.post('/api/users', async (req, res) => {
  const { logger } = req;
  
  logger.info('Creating user', { email: req.body.email });
  
  try {
    const user = await userService.create(req.body);
    
    logger.info('User created successfully', {
      userId: user.id,
      email: user.email
    });
    
    res.status(201).json(user);
    
  } catch (error) {
    logger.error('User creation failed', {
      email: req.body.email,
      error: error.message
    });
    
    res.status(500).json({ error: 'Failed to create user' });
  }
});

โš™๏ธ Logger Configuration

Winston

import winston from 'winston';

const logger = winston.createLogger({
  level: process.env.LOG_LEVEL || 'info',
  format: winston.format.combine(
    winston.format.timestamp(),
    winston.format.errors({ stack: true }),
    winston.format.json()
  ),
  transports: [
    new winston.transports.File({ filename: 'error.log', level: 'error' }),
    new winston.transports.File({ filename: 'combined.log' })
  ]
});

Pino (fastest)

import pino from 'pino';

const logger = pino({
  level: process.env.LOG_LEVEL || 'info',
  timestamp: pino.stdTimeFunctions.isoTime,
  formatters: {
    level: (label) => ({ level: label })
  }
});

๐Ÿ“Š Log Levels

Level When to Use Example
debug Development debugging logger.debug('Cache miss', { key })
info Important events logger.info('User logged in', { userId })
warn Potential issues logger.warn('Rate limit approaching', { userId })
error Errors that need attention logger.error('Payment failed', { orderId })

๐Ÿ’ฐ Pricing

Free

  • โœ… Basic log generation
  • โœ… Up to 10 files

Pro ($8/month)

  • โœ… Unlimited files
  • โœ… Performance logging
  • โœ… Request tracking
  • โœ… CI/CD integration

Enterprise ($59/month)

  • โœ… Team policies
  • โœ… Log aggregation setup
  • โœ… Custom formatters

๐Ÿ“š Best Practices

  1. Always log errors with context
  2. Use structured logging (objects, not strings)
  3. Include request IDs for tracing
  4. Don't log sensitive data (passwords, tokens)
  5. Use appropriate log levels

๐Ÿ“œ License

MIT


๐Ÿ™ Acknowledgments

Built with ๐ŸŒธ by ็ฟ ่Šฑ (Cuihua)


Made with ๐ŸŒธ | Cuihua Series | ClawHub Pioneer

Usage Guidance
This package appears to be a local static analyzer that reports where logging is missing and produces example logging snippets, but it does NOT automatically patch your source files. If you expect automated in-place changes, this will not do that as-is. Before running: (1) review logger.js (it reads every file under the target path) and run it only on a project copy or in a sandboxed repo to avoid scanning unintended files; (2) if you need automated edits, either implement a safe write/patch step yourself or verify the tool that will apply the snippets; (3) confirm node is installed and run the CLI with an explicit path (e.g., ./src) rather than root/~/; (4) because the tool reads your codebase, donโ€™t run it on directories containing secrets or system configs. If you want the tool to actually insert logging automatically, ask the author for an implementation that writes changes and includes safeguards (backups, dry-run, and clear patching behavior).
Capability Assessment
โš  Purpose & Capability
Name/description promise: 'automatically add intelligent logging' and examples showing generated 'after' code and 'Add logging to function' workflows. Actual bundled code (logger.js) implements scanning, detection of functions lacking logging, generating logging snippet text, and producing a coverage report, but it does not write changes back to source files or integrate with repositories/CI. No environment variables, binaries, or external services are requested โ€” those ARE consistent with a local analysis tool, but the 'auto-add' and 'multiple logger support' claims are overstated relative to what the code actually performs.
โ„น Instruction Scope
SKILL.md instructs analysis and shows examples for adding logging and running commands like 'node logger.js check ./src'. The runtime instructions and the shipped CLI align with scanning/analysis of a target path. However SKILL.md implies the agent will 'add' or patch logging into functions; the provided code only returns generated snippet text and a report and does not implement in-place modifications, patching, or writing files. The tool reads arbitrary files under the target path (as expected) โ€” exercise caution about which path you point it at (don't run against system directories or secrets).
โœ“ Install Mechanism
Instruction-only install (no install spec) and a single Node CLI file. Requires 'node' binary which matches the code. No network downloads or extract steps are present. Low install risk.
โœ“ Credentials
No environment variables, credentials, or config paths are declared or required. The code operates on filesystem paths only and does not access or require secrets โ€” proportional to the stated purpose of static analysis/coverage reporting.
โœ“ Persistence & Privilege
Skill does not request persistent/always-on presence. It is user-invocable and the CLI runs on demand. The code does not modify other skills or global agent configuration.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install cuihua-logger
  3. After installation, invoke the skill by name or use /cuihua-logger
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.0
๐Ÿ“ First release! AI-powered structured logging for production systems.
Metadata
Slug cuihua-logger
Version 1.0.0
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 1
Frequently Asked Questions

What is Cuihua Logger?

๐Ÿ“ AI-powered logging assistant that generates production-ready structured logs. Automatically add intelligent logging to your code with proper levels, conte... It is an AI Agent Skill for Claude Code / OpenClaw, with 133 downloads so far.

How do I install Cuihua Logger?

Run "/install cuihua-logger" in the OpenClaw or Claude Code chat to install it in one step โ€” no extra setup required.

Is Cuihua Logger free?

Yes, Cuihua Logger is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does Cuihua Logger support?

Cuihua Logger is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created Cuihua Logger?

It is built and maintained by supermario11 (@supermario11); the current version is v1.0.0.

๐Ÿ’ฌ Comments