Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logging: add option to use android logger for process logs #9767

Merged
merged 8 commits into from
Jan 28, 2020
Merged

logging: add option to use android logger for process logs #9767

merged 8 commits into from
Jan 28, 2020

Conversation

junr03
Copy link
Member

@junr03 junr03 commented Jan 22, 2020

Description: this PR adds an option to select different process loggers based on bazel config. Notably it introduces an Android Logger that is able to log to Android App's log stream.
Risk Level: low. The new functionality is bazel config guarded.
Testing: local. CI
Docs Changes: documented in bazel's README.md

Jose Nino added 6 commits January 21, 2020 15:58
Signed-off-by: Jose Nino <jnino@lyft.com>
fmt
Signed-off-by: Jose Nino <jnino@lyft.com>
Signed-off-by: Jose Nino <jnino@lyft.com>
fmt
Signed-off-by: Jose Nino <jnino@lyft.com>
fmt
Signed-off-by: Jose Nino <jnino@lyft.com>
fmt
Signed-off-by: Jose Nino <jnino@lyft.com>
@junr03
Copy link
Member Author

junr03 commented Jan 22, 2020

@jmarantz do you mind taking a look at this approach?

My initial thought was to derive from the SinkDelegate class structure. However, __android_log_write needs level information, and the android log levels are different from the spdlog and envoy log levels. Conveniently, spdlog already has an android sink, so I leveraged that in this PR.

I went for the lowest level at which I could interact with a spdlog::sinks::sink, and that was replacing the DelegatingLogSink whole sale when we construct Logger's logger_. This seemed cleaned enough, but do let me know if you can think of something else. Very open to suggestions.

Signed-off-by: Jose Nino <jnino@lyft.com>
jmarantz
jmarantz previously approved these changes Jan 22, 2020
@junr03
Copy link
Member Author

junr03 commented Jan 23, 2020

@zuercher do you mind taking a look?

Copy link
Member

@zuercher zuercher left a comment

Choose a reason for hiding this comment

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

I think this is generally fine, but I had a question about the bazel side of this.

bazel/README.md Outdated Show resolved Hide resolved
"//conditions:default": [],
}),
strip_include_prefix = "android",
deps = [":base_logger_lib"],
Copy link
Member

@zuercher zuercher Jan 23, 2020

Choose a reason for hiding this comment

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

Given that the andoid sink in spdlog is #ifdef __ANDROID__, does it make sense to gate this logger on the android equivalent of //bazel::windows_x86_64 and //bazel:apple (instead of a flag that won't work in any other env) and following the pattern used for envoy_cc_win32_library?

(The file watcher lib should get the same treatment for apple, but that's another PR.)

Copy link
Member Author

Choose a reason for hiding this comment

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

That was my first idea, but @goaway pointed out that there might be cases where we might want the StandardLogger when __ANDROID__ is defined, e.g running envoy as a process in an android device, rather than in a sandboxed application.

Copy link
Member

Choose a reason for hiding this comment

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

Ok. Do we want to pull the selection logic out into helpers?

Copy link
Member Author

Choose a reason for hiding this comment

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

I also debated about this. Given that it was only used once now and for the foreseeable future I opted for not introducing more helpers into the build system until they are needed. But if you think it is worth it, I am happy to add!

Copy link
Member

Choose a reason for hiding this comment

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

I think the thing I'm getting it is whether having an empty envoy_cc_library (logger_impl_lib_android) when android logging is disabled causes some kind of problem for bazel (particular the query subcommand). It seemed like there was something related to that with win32 libs, but I'm a bit out of my depth when it comes to bazel. I suppose it can always be fixed later.

Copy link
Member Author

Choose a reason for hiding this comment

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

I see. I was copying the pattern from win32

def envoy_cc_win32_library(name, srcs = [], hdrs = [], **kargs):
. Yeah, I agree, if there is a reported problem we can fix later.

source/common/common/base_logger.h Outdated Show resolved Hide resolved
source/common/common/standard/logger_impl.h Show resolved Hide resolved
Signed-off-by: Jose Nino <jnino@lyft.com>
@junr03 junr03 merged commit c26d1a7 into envoyproxy:master Jan 28, 2020
junr03 added a commit to envoyproxy/envoy-mobile that referenced this pull request Jan 29, 2020
Description: update the envoy ref. This bump includes envoyproxy/envoy#9767 which will enable us to turn on process logs for Android devices in a subsequent PR.
Risk Level: med, as always with a ref update.
Testing: CI

Signed-off-by: Jose Nino <jnino@lyft.com>
junr03 added a commit to envoyproxy/envoy-mobile that referenced this pull request Feb 13, 2020
Description: envoyproxy/envoy#9767 introduced the bazel option and #663 brought it into envoy mobile. This PR changes the bazel config for android to turn on the logger by default when building on android. It also updates a couple other stale flags and docs.
Risk Level: low
Testing: tested locally and saw logs

Fixes #34

Signed-off-by: Jose Nino <jnino@lyft.com>
jpsim pushed a commit that referenced this pull request Nov 28, 2022
Description: update the envoy ref. This bump includes #9767 which will enable us to turn on process logs for Android devices in a subsequent PR.
Risk Level: med, as always with a ref update.
Testing: CI

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 28, 2022
Description: #9767 introduced the bazel option and #663 brought it into envoy mobile. This PR changes the bazel config for android to turn on the logger by default when building on android. It also updates a couple other stale flags and docs.
Risk Level: low
Testing: tested locally and saw logs

Fixes #34

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: update the envoy ref. This bump includes #9767 which will enable us to turn on process logs for Android devices in a subsequent PR.
Risk Level: med, as always with a ref update.
Testing: CI

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: #9767 introduced the bazel option and #663 brought it into envoy mobile. This PR changes the bazel config for android to turn on the logger by default when building on android. It also updates a couple other stale flags and docs.
Risk Level: low
Testing: tested locally and saw logs

Fixes #34

Signed-off-by: Jose Nino <jnino@lyft.com>
Signed-off-by: JP Simard <jp@jpsim.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.

3 participants