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

Introduce default internal logger #313

Merged
merged 2 commits into from
Nov 12, 2018
Merged

Introduce default internal logger #313

merged 2 commits into from
Nov 12, 2018

Conversation

axw
Copy link
Member

@axw axw commented Nov 9, 2018

Tracer is now initialized with an internal logger
implementation if ELASTIC_APM_LOG_FILE is specified.
Without setting this environment variable, logging
is disabled as before.

Setting ELASTIC_APM_LOG_FILE to stdout or stderr will
cause logging to write to stdout/stderr respectively.
Otherwise, specifying a file path will cause that file
to be created/truncated and written to.

By default, only errors will be logged. Setting
ELASTIC_APM_LOG_LEVEL to "debug" will cause debug
messages to be printed in addition.

Closes #278

@codecov-io
Copy link

codecov-io commented Nov 9, 2018

Codecov Report

Merging #313 into master will decrease coverage by 0.04%.
The diff coverage is 9.75%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #313      +/-   ##
==========================================
- Coverage   80.77%   80.73%   -0.05%     
==========================================
  Files          96       96              
  Lines        5624     5627       +3     
==========================================
  Hits         4543     4543              
- Misses        826      829       +3     
  Partials      255      255
Impacted Files Coverage Δ
tracer.go 84.16% <0%> (+0.37%) ⬆️
internal/apmlog/logger.go 11.42% <11.42%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6b002a5...5a8cb51. Read the comment docs.

Copy link
Member

@graphaelli graphaelli left a comment

Choose a reason for hiding this comment

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

Feels natural and code looks good.

  • Is the log guaranteed to be flushed before the process exits?
  • Any plans to promote 404s to apm-server to error? Had to turn on debug to find those.

case "stderr":
logWriter = os.Stderr
default:
f, err := os.Create(fileStr)
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 this is the right call

@axw
Copy link
Member Author

axw commented Nov 12, 2018

Is the log guaranteed to be flushed before the process exits?

This is just meant for debugging, so I don't expect that's necessary. We'd have to either flush after every log message (maybe OK given the expected low volume, but preferable not to), or say flush when the tracer is closed. The user would then be responsible for closing the tracer before exiting the process. I'm going to leave this for now.

Any plans to promote 404s to apm-server to error? Had to turn on debug to find those.

That would be sensible wouldn't it? I'll fix that before landing.

axw added 2 commits November 12, 2018 12:15
Tracer is now initialized with an internal logger
implementation if ELASTIC_APM_LOG_FILE is specified.
Without setting this environment variable, logging
is disabled as before.

Setting ELASTIC_APM_LOG_FILE to stdout or stderr will
cause logging to write to stdout/stderr respectively.
Otherwise, specifying a file path will cause that file
to be created/truncated and written to.

By default, only errors will be logged. Setting
ELASTIC_APM_LOG_LEVEL to "debug" will cause debug
messages to be printed in addition.
@axw axw merged commit d882f69 into elastic:master Nov 12, 2018
@axw axw deleted the default-logger branch November 12, 2018 04:30
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