mirror of
https://github.com/langgenius/dify-plugin-daemon.git
synced 2026-07-21 17:25:23 -04:00
ca3d00229e
* use slog instead of log package and format to new log schema * update the environment name to LOG_OUTPUT_FORMAT * add the env to .env.example * fix log reference error * change the order of milldlewares * delete unused code * fix the concurrently session potential race condition * fix the log format in tests * update the duplicate code * refactor: convert log functions to slog structured format - Change log.Error/Info/Warn/Debug/Panic to accept msg + key-value pairs - Remove printf-style formatting from log functions - Update log calls in internal/cluster, internal/db, internal/core/session_manager - Remove unused 'initialized' variable from log package - Remaining files will be updated in follow-up commits 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * refactor: update all log call sites to use slog structured format Convert all log.Error, log.Info, log.Warn, log.Debug, and log.Panic calls from printf-style formatting to slog key-value pairs. Before: log.Error("failed to do something: %s", err.Error()) After: log.Error("failed to do something", "error", err) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * refactor: update cmd/ log calls to use slog structured format 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * feat: implement GnetLogger for structured logging in gnet * refactor: remove deprecated log visibility functions and related calls * feat: enhance session management with trace and identity context propagation * feat: implement serverless transaction handler and writer for plugin runtime * refactor: rename context field to traceCtx in RealBackwardsInvocation --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: Yeuoly <admin@srmxy.cn>
87 lines
2.1 KiB
Go
87 lines
2.1 KiB
Go
package plugin
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"text/tabwriter"
|
|
|
|
"github.com/langgenius/dify-plugin-daemon/pkg/plugin_packager/decoder"
|
|
"github.com/langgenius/dify-plugin-daemon/pkg/utils/log"
|
|
)
|
|
|
|
// Language represents supported README languages
|
|
type Language struct {
|
|
Code string
|
|
Name string
|
|
Available bool
|
|
}
|
|
|
|
// GetLanguageName returns the full language name for a given language code
|
|
func GetLanguageName(code string) string {
|
|
languageNames := map[string]string{
|
|
"en_US": "English",
|
|
"zh_Hans": "简体中文 (Simplified Chinese)",
|
|
"ja_JP": "日本語 (Japanese)",
|
|
"pt_BR": "Português (Portuguese - Brazil)",
|
|
}
|
|
|
|
if name, exists := languageNames[code]; exists {
|
|
return name
|
|
}
|
|
return "unknown"
|
|
}
|
|
|
|
// ListReadme displays README language information in table format for a specific plugin
|
|
func ListReadme(pluginPath string) {
|
|
var pluginDecoder decoder.PluginDecoder
|
|
var err error
|
|
|
|
stat, err := os.Stat(pluginPath)
|
|
if err != nil {
|
|
log.Error("failed to get plugin file stat", "error", err)
|
|
return
|
|
}
|
|
|
|
if stat.IsDir() {
|
|
pluginDecoder, err = decoder.NewFSPluginDecoder(pluginPath)
|
|
} else {
|
|
fileContent, err := os.ReadFile(pluginPath)
|
|
if err != nil {
|
|
log.Error("failed to read plugin file", "error", err)
|
|
return
|
|
}
|
|
pluginDecoder, err = decoder.NewZipPluginDecoder(fileContent)
|
|
if err != nil {
|
|
log.Error("failed to create zip plugin decoder", "error", err)
|
|
return
|
|
}
|
|
}
|
|
if err != nil {
|
|
log.Error("your plugin is not a valid plugin", "error", err)
|
|
return
|
|
}
|
|
|
|
// Get available i18n README files
|
|
availableReadmes, err := pluginDecoder.AvailableI18nReadme()
|
|
if err != nil {
|
|
log.Error("failed to get available README files", "error", err)
|
|
return
|
|
}
|
|
|
|
// Create a new tabwriter
|
|
w := tabwriter.NewWriter(os.Stdout, 0, 8, 3, ' ', 0)
|
|
|
|
// Print table header
|
|
fmt.Fprintln(w, "language-code\tlanguage\tavailable")
|
|
fmt.Fprintln(w, "-------------\t--------\t---------")
|
|
|
|
// Print each available README
|
|
for code, _ := range availableReadmes {
|
|
languageName := GetLanguageName(code)
|
|
fmt.Fprintf(w, "%s\t%s\t✅\n", code, languageName)
|
|
}
|
|
|
|
// Flush the writer to ensure all output is printed
|
|
w.Flush()
|
|
}
|