Converted all logs to macros and modified existing log macros.#1068
Converted all logs to macros and modified existing log macros.#1068htuch merged 6 commits intoenvoyproxy:masterfrom
Conversation
|
The CI is failing because envoy-filter-example is using the old logging macros. Are these macros considered a breaking change? |
Hmm. My inclination is to say to just go for it, but this breaking change probably means we should do the back-compat dance. Is it hard in this case? Seems like it should be relatively easy to do? (Haven't looked at change yet). |
|
@mattklein123 It won't be too bad for most of them because the names are almost all distinct. The only ones whose names were repurposed were log_trace and log_debug. I think the only way to keep these two compatible would be change the names of the new ones. That should be fine though. |
|
I'm fine with making a breaking change personally, but it's going to be very hard to stage with the consuming project, and in some sense I think that's a good gut check that we shouldn't break stuff. So I guess maybe rename? @htuch ? |
|
As discussed IRL, we can avoid the breaking change since it's not that bad to maintain compatibility, but certainly deprecate the old way. |
htuch
left a comment
There was a problem hiding this comment.
Looks good, but some potato potatah stuff.
source/common/common/logger.h
Outdated
| */ | ||
| #define conn_log(LOG, LEVEL, FORMAT, CONNECTION, ...) \ | ||
| LOG.LEVEL("[C{}] " FORMAT, (CONNECTION).id(), ##__VA_ARGS__) | ||
| #define log_facility(LEVEL, ...) log_##LEVEL(log(), ##__VA_ARGS__) |
There was a problem hiding this comment.
I'm not a huge fan of the _facility suffix here, seems verbose and unclear what a "facility" is. Maybe we could add some explicit documentation of what a facility is here and/or rename to something (I'm not smart enough to figure out what that something should be).
There was a problem hiding this comment.
Totally agree. This name was due to many name collisions (outside of just the Loggable class) with the macro log. I was also tossing around class_log (also ambiguous and verbose) or lg (which was inconsistent with the other names, but was nice in that it kept the preferred macro short). For now, I can add some documentation for what a facility is, and I'll ponder on the name.
source/common/common/logger.h
Outdated
| * Convenience macros to log to the general logger. | ||
| */ | ||
| #define get_general_logger() Logger::Loggable<Logger::Id::general>::log() | ||
| #define log_general(LEVEL, ...) log_to_logger(get_general_logger(), LEVEL, ##__VA_ARGS__) |
There was a problem hiding this comment.
Should this be the general logger or misc logger. I think if it was called misc it would cause folks to think twice before using it when there is a reasonable way to put this in a "facility".
There was a problem hiding this comment.
Good point. I think misc is a good way to discourage it.
|
@mattklein123 As discussed in #1088, I added a define for NVLOG (I'm happy to change the name). Its absence (the default) turns on verbose logging. |
mattklein123
left a comment
There was a problem hiding this comment.
Looks great. Thanks for doing this. Few small things.
DEPRECATED.md
Outdated
| `statsd_udp_ip_address`. | ||
| * `HttpFilterConfigFactory` filter API has been deprecated in favor of `NamedHttpFilterConfigFactory`. | ||
| * Config option `http_codec_options` has been deprecated and has been replaced with `http2_settings`. | ||
| * The following log macros have been deprecated: `log_trace`, `log_debug`, `conn_log`, `conn_log_info`, `conn_log_debug`, `conn_log_trace`, `stream_log`, `stream_log_info`, `stream_log_debug`, `stream_log_trace`. For replacements, please see [logger.h](https://github.com/lyft/envoy/blob/master/source/common/common/logger.h). |
There was a problem hiding this comment.
nit: please break at around 100 cols.
source/common/common/logger.h
Outdated
| FUNCTION(client) \ | ||
| FUNCTION(config) \ | ||
| FUNCTION(connection) \ | ||
| FUNCTION(misc) \ |
| * Base logging macros. It is expected that users will use the convenience macros below rather than | ||
| * invoke these directly. | ||
| */ | ||
| #ifdef NVLOG |
There was a problem hiding this comment.
Can we document this somewhere on the bazel readme page? (Basically what --copt to set, and what it does, useful for perf, etc.)
|
|
||
| #ifdef NDEBUG | ||
| /** | ||
| * Base logging macros. It is expected that users will use the convenience macros below rather than |
There was a problem hiding this comment.
Now that we have macros everywhere, do you want to add file/line info also? Should be easy.
There was a problem hiding this comment.
P.S. I don't care one way or the other, but you had mentioned this previously. can also do in follow up later.
source/common/common/logger.h
Outdated
|
|
||
| /** | ||
| * Convenience macro to log to the facility of the class in which the macro is invoked. Note: | ||
| * facilities are a way of grouping classes within envoy. A facility is specified by Id enum values |
source/common/common/logger.h
Outdated
| * listed above. The facility_log is enabled within a class when the class inherits from the | ||
| * Loggable class templated by the choice of facility. | ||
| */ | ||
| #define log_facility(LEVEL, ...) log_to_logger(log(), LEVEL, ##__VA_ARGS__) |
There was a problem hiding this comment.
Still don't really like the term facility, but struggling with alternative suggestions:
- "service" <- too easy to confuse with other notions of service in Envoy.
- "category" <- make me think of category theory.
- "class/object" <- not necessarily coupled directly with class/object.
- Just "log" <- already taken.
The other alternative is we switch to all caps, which we probably should with macros anyway, then we use LOG etc.
I'm out of ideas and I can probably live with log_facility.
There was a problem hiding this comment.
What about utility or group? Here are some others: http://www.thesaurus.com/browse/convenience, http://www.thesaurus.com/browse/service, and http://www.thesaurus.com/browse/category
There was a problem hiding this comment.
I would be fine with all caps since it's a macro if that makes people happy.
|
It's fine as is as long people don't start explicitly using those macros. |
The [backtrace] search regexes required updating.
Description: add guide for local stats testing. Risk Level: low Docs Changes: added docs, built locally. Signed-off-by: Jose Nino <jnino@lyft.com> Signed-off-by: JP Simard <jp@jpsim.com>
Description: add guide for local stats testing. Risk Level: low Docs Changes: added docs, built locally. Signed-off-by: Jose Nino <jnino@lyft.com> Signed-off-by: JP Simard <jp@jpsim.com>
**Description** This parses OpenAI Web Tool requests and obfuscation used in gpt-5. As a part of this, we re-record all the affected requests. **Related Issues/PRs (if applicable)** #1068 --------- Signed-off-by: Adrian Cole <adrian@tetrate.io>
**Description** This commit is a follow up on the initial tracing implementation. There was a bug in vcr tests where streaming mode override is wrongly taken place at upstream filter level, which resulted in buffering all events at the router filter as opposed to the reality that they are streamed (not necessarily on the event boundary, as it's a tcp dataframe level), and that is why previously already passing the tests despite not taking care of the event boundaries. Notably, this makes the tracing do * Support for all backends regardless of the schema vs previously only works for OpenAI backend. * Correctly handling all streaming events vs previously assuming all events are available in buffer which is not true in end to end. * Avoids unnecessary copies around the tracing; This utilizes the already-parsed data structures, so this makes the tracing zero-copy as long as the redaction is configured. --------- Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
Three types of logging: facility, general, and to a specific logger that the user passes in. I attempted to clean up the way that log macros were being done to make them a bit simpler. They should all filter down to the log_[level] macros for ease of compiling out certain log levels and global modification of log formatting or functionality.