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

Log splits by '\n' in the message when using StructuredLogHandler to write logs in Cloud Run #318

Closed
kwsz opened this issue Jun 7, 2021 · 1 comment
Assignees
Labels
api: logging Issues related to the googleapis/python-logging API. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Milestone

Comments

@kwsz
Copy link

kwsz commented Jun 7, 2021

Thanks for stopping by to let us know something could be better!

PLEASE READ: If you have a support contract with Google, please create an issue in the support console instead of filing on GitHub. This will ensure a timely response.

Please run down the following list and make sure you've tried the usual "quick fixes":

If you are still having issues, please be sure to include as much information as possible:

Environment details

  • OS type and version: Cloud Run
  • Python version: 3.7
  • pip version:
  • google-cloud-logging version: 2.4.0

Steps to reproduce

  1. Set up StructuredLogHandler to write logs
  2. Write logs containing a '\n'
  3. Build the image and run it on Cloud Run
  4. See the Cloud Logging dashboard

Code example

def prep_structured_logging():
    logger = logging.getLogger()
    logger.setLevel(logging.INFO)
    # Delete unused handlers
    logger.handlers = []

    client = google.cloud.logging.Client()
    cloud_handler = StructuredLogHandler()
    setup_logging(cloud_handler)


@app.route('/test_structured', methods=['POST'])
def test_structured():
    prep_structured_logging()

    text = request.values.get('text', 'logging text')

    logging.error(text + "\n" + text)

    return "Success!"

Stack trace

Making sure to follow these steps will guarantee the quickest resolution possible.

Thanks!

@product-auto-label product-auto-label bot added the api: logging Issues related to the googleapis/python-logging API. label Jun 7, 2021
@daniel-sanche daniel-sanche added the type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. label Jun 7, 2021
@daniel-sanche daniel-sanche added this to the v2 Update 4 milestone Jun 7, 2021
@yoshi-automation yoshi-automation added the triage me I really want to be triaged. label Jun 8, 2021
@daniel-sanche daniel-sanche added the priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. label Jun 8, 2021
@yoshi-automation yoshi-automation removed the triage me I really want to be triaged. label Jun 9, 2021
@daniel-sanche
Copy link
Contributor

Good catch. We had tests around this, but it turns out our tests were re-encoding the message string, so this slipped though. I fixed this (and improved the tests) in #319, and will release it in v2.5.0 next week

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: logging Issues related to the googleapis/python-logging API. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

3 participants