Comments (4)
Try log.With
.
from trpc-go.
log.With add a field in json mode, can't format, any other way?
code:
log.With(log.Field{Key: "test_field", Value: "123456789"}).Debug("try log with")
output:
2023-12-13 16:45:54.457 DEBUG demo/test.go:48 try log with {"test_field": "123456789"}
from trpc-go.
@rhoninzhang, please check out the changes made in #146.
I have provided an example in zaplogger_test.go. The idea is to implement a custom encoder. However, I found it challenging to get it right, and the implementation is not straightforward. For instance, the fields
argument in EncodeEntry(entry zapcore.Entry, fields []zapcore.Field)
is always an empty array, regardless of whether the logger is decorated with additional fields. This can be quite confusing. I suggest you switch to this branch and explore it yourself. Feel free to provide more feedback.
from trpc-go.
I noticed that the InlineMarshalerType
might be what you're looking for when dealing with unstructured JSON values (where only the value itself is shown, rather than {key: value}
). However, I found that this utility seems to be inaccessible from the trpc-go logging package. It provides its own log.Field
type and uses zapcore.Any
to extract possible value types, but unfortunately, InlineMarshalerType
is not included.
from trpc-go.
Related Issues (20)
- Congratulation! Should I submit the PR directly here or go to Tencent's internal GIT repository? HOT 5
- 没看到tracing的实现代码,我看首页的架构图里有这个 HOT 2
- the repository URL on GitHub and the module definition in go.mod are not consistent HOT 2
- trpc-go doesn't support gRPC protocol? HOT 10
- affected/package: config.go HOT 3
- Why FormDataSerialization.Marshal use JSONPBSerialization.Marshal to implement? HOT 1
- 有没有相关交流群呢 HOT 1
- When I go to run $ cd server && go run main.go times wrong./ trpc_go.yaml does not exist HOT 2
- When I go to run $ cd server && go run main.go times wrong./ trpc_go.yaml does not exist
- git lfs png fail
- Difference between intranet and open source project HOT 3
- Ask some trpc-go project for RESTful API HOT 1
- google.protobuf.Empty unknown
- Could you share some of the more frequently asked framework questions from the internal network (similar to common software issues) HOT 2
- plugin: Simplify global config by generic HOT 6
- proposal: codec: remove json-iterator and use official encoding/json HOT 16
- Are there community communication channels like WeChat or Slack available for the project? HOT 2
- Is there any plan for this project this year?
- question: how to solve the problem that the program show error code :141 and 171 HOT 12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from trpc-go.