Skip to content

Converted all logs to macros and modified existing log macros.#1068

Merged
htuch merged 6 commits intoenvoyproxy:masterfrom
mrice32:log_macros
Jun 13, 2017
Merged

Converted all logs to macros and modified existing log macros.#1068
htuch merged 6 commits intoenvoyproxy:masterfrom
mrice32:log_macros

Conversation

@mrice32
Copy link
Copy Markdown
Member

@mrice32 mrice32 commented Jun 8, 2017

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.

@mrice32
Copy link
Copy Markdown
Member Author

mrice32 commented Jun 8, 2017

@htuch @jamessynge

@mrice32
Copy link
Copy Markdown
Member Author

mrice32 commented Jun 8, 2017

The CI is failing because envoy-filter-example is using the old logging macros. Are these macros considered a breaking change?

@mattklein123
Copy link
Copy Markdown
Member

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).

@mrice32
Copy link
Copy Markdown
Member Author

mrice32 commented Jun 8, 2017

@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.

@mattklein123
Copy link
Copy Markdown
Member

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 ?

@htuch
Copy link
Copy Markdown
Member

htuch commented Jun 9, 2017

As discussed IRL, we can avoid the breaking change since it's not that bad to maintain compatibility, but certainly deprecate the old way.

Copy link
Copy Markdown
Member

@htuch htuch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but some potato potatah stuff.

*/
#define conn_log(LOG, LEVEL, FORMAT, CONNECTION, ...) \
LOG.LEVEL("[C{}] " FORMAT, (CONNECTION).id(), ##__VA_ARGS__)
#define log_facility(LEVEL, ...) log_##LEVEL(log(), ##__VA_ARGS__)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

* 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__)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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".

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I think misc is a good way to discourage it.

@mrice32
Copy link
Copy Markdown
Member Author

mrice32 commented Jun 12, 2017

@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.

Copy link
Copy Markdown
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: please break at around 100 cols.

FUNCTION(client) \
FUNCTION(config) \
FUNCTION(connection) \
FUNCTION(misc) \
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: \ indent

* Base logging macros. It is expected that users will use the convenience macros below rather than
* invoke these directly.
*/
#ifdef NVLOG
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that we have macros everywhere, do you want to add file/line info also? Should be easy.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P.S. I don't care one way or the other, but you had mentioned this previously. can also do in follow up later.


/**
* 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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: s/envoyEnvoy

* 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__)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor

@hennna hennna Jun 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be fine with all caps since it's a macro if that makes people happy.

@htuch
Copy link
Copy Markdown
Member

htuch commented Jun 13, 2017

It's fine as is as long people don't start explicitly using those macros.

@htuch htuch merged commit 18fcfb7 into envoyproxy:master Jun 13, 2017
htuch added a commit to htuch/envoy that referenced this pull request Jun 14, 2017
The [backtrace] search regexes required updating.
htuch added a commit that referenced this pull request Jun 14, 2017
The [backtrace] search regexes required updating.
@mrice32 mrice32 deleted the log_macros branch June 14, 2017 17:09
jpsim pushed a commit that referenced this pull request Nov 28, 2022
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>
jpsim pushed a commit that referenced this pull request Nov 29, 2022
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>
mathetake pushed a commit that referenced this pull request Mar 3, 2026
**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>
mathetake added a commit that referenced this pull request Mar 3, 2026
**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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants