kratos-zapzh

module
v0.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 11, 2026 License: MIT

README

GitHub Workflow Status (branch) GoDoc Coverage Status Supported Go Versions GitHub Release Go Report Card

kratos-zapzh

Zap logging integration with Kratos microservice framework using Chinese function names.


CHINESE README

中文说明

Main Features

  • 🎯 Chinese Function Names - Use intuitive Chinese names (Get奎沱日志, New奎沱主簿, etc.)
  • 📊 Structured Logging - Use Uber Zap's fast structured logging
  • ⚡ High Performance - Benefit from Zap's zero-allocation design
  • 🔄 Kratos Compatible - Seamless integration with Kratos framework
  • 🌍 Module Tracking - Auto add module info to logs
  • 📋 Flexible Config - Custom module field naming and options

Installation

go get github.com/yylego/kratos-zapzh/zapzhkratos

Quick Start

package main

import (
    "github.com/yylego/kratos-zapzh/zapzhkratos"
    "github.com/yylego/zaplog"
)

func main() {
    // Create instance with Chinese functions
    v匝普日志 := zapzhkratos.New匝普日志(
        zaplog.LOGGER,
        zapzhkratos.New日志配置(),
    )

    // Get Kratos log.Logger
    logger := v匝普日志.Get奎沱日志("my-app")

    // Get Kratos log.Helper (主簿)
    slog := v匝普日志.Get奎沱主簿("my-module")
    slog.Info("app started")

    // Get module-aware Zap
    zapLog := v匝普日志.Sub模块匝普()
    zapLog.LOG.Info("with module context")
}

Complete Examples

See zapzhkratos-demos to view complete integration in working Kratos projects:

The demos show:

  • Integration in main.go and Wire setup
  • Usage across biz/service/data tiers
  • HTTP and gRPC setup with zapzhkratos
  • Log Helper usage in business logic

API Reference

Types

T日志配置 - Configuration options (wraps zapkratos.Options)

// Create config with default settings
cfg := zapzhkratos.New日志配置()

// Customize module field name
cfg.With模块位置键名("module")

T匝普日志 - Main struct (wraps zapkratos.ZapKratos)

// Create instance
zk := zapzhkratos.New匝普日志(zaplog.LOGGER, cfg)
Methods
Get奎沱日志 / New奎沱日志

Creates log.Logger with given caption:

logger := zk.Get奎沱日志("my-service")
// Same as New奎沱日志
logger = zk.New奎沱日志("my-service")
Get奎沱主簿 / New奎沱主簿

Creates log.Helper ("主簿" means chief clerk):

slog := zk.Get奎沱主簿("module-name")
slog.Info("message")
slog.Infow("key", "value")
Get奎沱秘书 / New奎沱秘书

Creates log.Helper ("秘书" means secretary, alternative name):

slog := zk.Get奎沱秘书("module-name")
Get基本匝普

Returns underlying Zap instance:

zap := zk.Get基本匝普()
zap.LOG.Info("message")
Sub模块匝普

Creates child Zap with module context:

zapLog := zk.Sub模块匝普()
// Auto adds module field with filename

Name Translations

  • zapzhkratos:

    • zap - Zap logging
    • zh - Chinese (中文)
    • kratos - Kratos framework
  • 日志 - Logger interface

  • 主簿 - log.Helper (chief clerk)

  • 秘书 - log.Helper (secretary, alternative)

  • 模块 - Module

  • 配置 - Configuration

Chinese Programming

This package uses Chinese function names, making it intuitive to Chinese developers while maintaining the same core functions as zapkratos.

The naming "主簿" (chief clerk) was chosen as log.Helper is difficult to translate - "侍者" (attendant), "史官" (historian), "助理" (assistant) didn't fit the context. "秘书" is also provided as an alternative.

Note: This is a test package with Chinese names. If you don't like this approach, use zapkratos instead.

Benefits of Chinese Names

Chinese function names bring semantic precision and self-documentation abilities. The characters ensure alignment with unambiguous meanings. Words like "秘书" achieve the same expressiveness with less space.

Dependencies

  • github.com/go-kratos/kratos/v2 - Kratos microservice framework
  • github.com/yylego/kratos-zap - Core zapkratos package
  • github.com/yylego/zaplog - Zap management package

Frameworks:

  • Kratos - Go microservice framework
  • Zap - Uber's structured logging

zapkratos Ecosystem:

zapzhkratos Ecosystem (Chinese):

📄 License

MIT License - see LICENSE.


💬 Contact & Feedback

Contributions are welcome! Report bugs, suggest features, and contribute code:

  • 🐛 Mistake reports? Open an issue on GitHub with reproduction steps
  • 💡 Fresh ideas? Create an issue to discuss
  • 📖 Documentation confusing? Report it so we can improve
  • 🚀 Need new features? Share the use cases to help us understand requirements
  • Performance issue? Help us optimize through reporting slow operations
  • 🔧 Configuration problem? Ask questions about complex setups
  • 📢 Follow project progress? Watch the repo to get new releases and features
  • 🌟 Success stories? Share how this package improved the workflow
  • 💬 Feedback? We welcome suggestions and comments

🔧 Development

New code contributions, follow this process:

  1. Fork: Fork the repo on GitHub (using the webpage UI).
  2. Clone: Clone the forked project (git clone https://github.com/yourname/repo-name.git).
  3. Navigate: Navigate to the cloned project (cd repo-name)
  4. Branch: Create a feature branch (git checkout -b feature/xxx).
  5. Code: Implement the changes with comprehensive tests
  6. Testing: (Golang project) Ensure tests pass (go test ./...) and follow Go code style conventions
  7. Documentation: Update documentation to support client-facing changes and use significant commit messages
  8. Stage: Stage changes (git add .)
  9. Commit: Commit changes (git commit -m "Add feature xxx") ensuring backward compatible code
  10. Push: Push to the branch (git push origin feature/xxx).
  11. PR: Open a merge request on GitHub (on the GitHub webpage) with detailed description.

Please ensure tests pass and include relevant documentation updates.


🌟 Support

Welcome to contribute to this project via submitting merge requests and reporting issues.

Project Support:

  • Give GitHub stars if this project helps you
  • 🤝 Share with teammates and (golang) programming friends
  • 📝 Write tech blogs about development tools and workflows - we provide content writing support
  • 🌟 Join the ecosystem - committed to supporting open source and the (golang) development scene

Have Fun Coding with this package! 🎉🎉🎉


GitHub Stars

Stargazers

Directories

Path Synopsis
Package zapzhkratos integrates Zap logging with Kratos microservice framework using Chinese names Wraps zapkratos package to provide intuitive Chinese function names and method names Enables structured logging with module tracking and flexible configuration options Designed to make Chinese developers more productive with intuitive naming conventions
Package zapzhkratos integrates Zap logging with Kratos microservice framework using Chinese names Wraps zapkratos package to provide intuitive Chinese function names and method names Enables structured logging with module tracking and flexible configuration options Designed to make Chinese developers more productive with intuitive naming conventions

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL