Comments (7)
Hey @sebastianwebber I think I’ve got most of it done already in a local branch, just finalizing how I want to do the stack trace stuff, I’ll let you know if I could use help with anything though :)
from log.
ok @sebastianwebber @Perlence I finally got around to updating this library and it now supports sharing fields between entries!
sorry for how long it took, just be so busy with....everything.
from log.
Hey @Perlence
No you haven't missed anything, when I was designing, I wanted to make sure that log
was safe to be called from multiple goroutines and if the Entry was reusable then a possibility exists that someone could call it from multiple goroutines and cause themselves problems.
I do however understand your scenario and could look into creating a Release option or function to tell the Entry not to put itself and fields back into the pool.
Would that be something you'd be interested in.?
eg.
// Calling Release() releases the Entry and all fields from
// being managed by the package...
l := log.WithFields(...).Release()
l.Info(...)
I can't promise anything, but I could look into this sort of functionality.
from log.
Thank you for reply. I really don't want to force you to make decisions that you'll regret later, so everything is completely up to you 😄
I think that while Release allows to log same fields multiple times, it cannot be used to add one-off fields, e.g. some error information, and then log an entry with initial fields, because WithFields adds fields in place. So there could be something like (*Entry) CopyWithFields
. But I'd like to see one method that can be used either to fix fields for later use or to copy existing fields into a new Entry.
"Release" also doesn't sound too clear to me, kind of low level, for example I didn't know about entry pool before fields started to "leak" through to other entries when I used context multiple times.
from log.
Thanks for the ideas, let me think about how and if I could achieve this.
CopyWithFields() does seem like a good solution!
It may take me a bit to get to this as I'm adding new things to some of my other packages also, but I will get to this 😄
from log.
@joeybloggs do you need help to implement this feature?
from log.
nice @joeybloggs
For now, i'm using:
...
log := log.WithFields(log.F("key", "value"))
log.Info("bla")
...
from log.
Related Issues (20)
- Help Wanted - adding more log Handlers HOT 2
- UTC time HOT 2
- group entries HOT 4
- is there anyway to define logging time? e.g. use Local Time instead of UTC HOT 1
- Not all error prefixes make it to the logging field
- Unable to remove handlers HOT 2
- Can it use as a simple log HOT 11
- Synchronization HOT 7
- Ability to change or disable log levels HOT 3
- Ability to disable the email handler from sending emails HOT 1
- cannot use syscall.Stdout as type int in argument to terminal.IsTerminal HOT 3
- Windows color HOT 2
- Every visit add a line ....
- Cannot use in a module based project HOT 2
- Go playground issue HOT 4
- Gather file + line info on all error type logs
- v8 How to turn off the default output HOT 2
- Add configurable skip level for file + line number
- SetFormatFunc is useless HOT 4
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 log.