Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

Logging.conf not working #14

Open
shubhamitc opened this issue Aug 27, 2018 · 0 comments
Open

Logging.conf not working #14

shubhamitc opened this issue Aug 27, 2018 · 0 comments

Comments

@shubhamitc
Copy link

I have a Django project and trying to use this module to push application logs to pubsub asynchronously. I am trying to test with below configuration and it is failing. At the same time creating handler object and registering is working as expected.

from __future__ import print_function
import logging
import os


import argparse
import logging
import logging.config
import logging.handlers
import time

from pubsub_logging import AsyncPubsubHandler
from pubsub_logging import PubsubHandler
from pubsub_logging import utils


os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "../../vrm/Premium-POC-108be31ed325.json"
logging.config.fileConfig(os.path.join('.','logging.conf'))
logger = logging.getLogger('root')
logger.setLevel(logging.DEBUG)


num=3
for i in range(num):
    logger.info('pubsub %03d.', i)
print("done")



publish_body = utils.publish_body
pubsub_handler = AsyncPubsubHandler('projects/nextgenxcoding/topics/vm-response', 10,
                                            publish_body=publish_body)
logger = logging.getLogger('root')
logger.setLevel(logging.DEBUG)
logger.addHandler(pubsub_handler)



before = time.time()
for i in range(num):
    logger.info('log message %03d.', i)
elapsed = time.time() - before
print('Took %f secs for buffering %d messages: %f mps.\n' %
        (elapsed, num, num/elapsed))
pubsub_handler.flush()
elapsed = time.time() - before
print('Took %f secs for sending %d messages: %f mps.\n' %
        (elapsed, num, num/elapsed))

from gcloud command

gcloud beta pubsub subscriptions pull projects/nextgenxcoding/subscriptions/logging --limit 20                       127 ↵  676  18:16:31
┌──────────────────┬─────────────────┬────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│       DATA       │    MESSAGE_ID   │ ATTRIBUTES │                                                                              ACK_ID                                                                              │
├──────────────────┼─────────────────┼────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
│ log message 000. │ 188430423430049 │            │ QV5AEkw9CURJUytDCypYEU4EISE-MD5FU0RQBhYsXUZIUTcZCGhRDk9eIz81IChFEAtTE1FcdhhCEGszXHUHUQ0YdHhmJ2xZRwFREVl-VVsJPGh-Y3QPWQkacnljdm5ZEwEGTHuJ84PRzbNGZhg9XBJLLD5-NjxF │
│ log message 001. │ 188430423430050 │            │ QV5AEkw9CURJUytDCypYEU4EISE-MD5FU0RQBhYsXUZIUTcZCGhRDk9eIz81IChFEAtTE1FcdhhCEGszXHUHUQ0YdHhmJ2xZRwFREVl-VVoJPGh-Y3QPWQkacnljdm5ZEwEHRXuJ84PRzbNGZhg9XBJLLD5-NjxF │
│ log message 002. │ 188430423430051 │            │ QV5AEkw9CURJUytDCypYEU4EISE-MD5FU0RQBhYsXUZIUTcZCGhRDk9eIz81IChFEAtTE1FcdhhCEGszXHUHUQ0YdHhmJ2xZRwFREVl-VVkJPGh-Y3QPWQkacnljdm5ZEwEHRHuJ84PRzbNGZhg9XBJLLD5-NjxF │
│ log message 003. │ 188430423430052 │            │ QV5AEkw9CURJUytDCypYEU4EISE-MD5FU0RQBhYsXUZIUTcZCGhRDk9eIz81IChFEAtTE1FcdhhCEGszXHUHUQ0YdHhmJ2xZRwFREVl-VVgJPGh-Y3QPWQkacnljdm5ZEwEHR3uJ84PRzbNGZhg9XBJLLD5-NjxF │
│ log message 004. │ 188430423430053 │            │ QV5AEkw9CURJUytDCypYEU4EISE-MD5FU0RQBhYsXUZIUTcZCGhRDk9eIz81IChFEAtTE1FcdhhCEGszXHUHUQ0YdHhmJ2xZRwFREVl-VV8JPGh-Y3QPWQkacnljdm5ZEwEHRnuJ84PRzbNGZhg9XBJLLD5-NjxF │
│ log message 005. │ 188430423430054 │            │ QV5AEkw9CURJUytDCypYEU4EISE-MD5FU0RQBhYsXUZIUTcZCGhRDk9eIz81IChFEAtTE1FcdhhCEGszXHUHUQ0YdHhmJ2xZRwFREVl-VV4JPGh-Y3QPWQkacnljdm5ZEwEHQXuJ84PRzbNGZhg9XBJLLD5-NjxF │
│ log message 006. │ 188430423430055 │            │ QV5AEkw9CURJUytDCypYEU4EISE-MD5FU0RQBhYsXUZIUTcZCGhRDk9eIz81IChFEAtTE1FcdhhCEGszXHUHUQ0YdHhmJ2xZRwFREVl-VV0JPGh-Y3QPWQkacnljdm5ZEwEHQHuJ84PRzbNGZhg9XBJLLD5-NjxF │
│ log message 007. │ 188430423430056 │            │ QV5AEkw9CURJUytDCypYEU4EISE-MD5FU0RQBhYsXUZIUTcZCGhRDk9eIz81IChFEAtTE1FcdhhCEGszXHUHUQ0YdHhmJ2xZRwFREVl-VVwJPGh-Y3QPWQkacnljdm5ZEwEHQ3uJ84PRzbNGZhg9XBJLLD5-NjxF │
│ log message 008. │ 188430423430057 │            │ QV5AEkw9CURJUytDCypYEU4EISE-MD5FU0RQBhYsXUZIUTcZCGhRDk9eIz81IChFEAtTE1FcdhhCEGszXHUHUQ0YdHhmJ2xZRwFREVl-VVMJPGh-Y3QPWQkacnljdm5ZEwEHQnuJ84PRzbNGZhg9XBJLLD5-NjxF │
│ log message 009. │ 188430423430058 │            │ QV5AEkw9CURJUytDCypYEU4EISE-MD5FU0RQBhYsXUZIUTcZCGhRDk9eIz81IChFEAtTE1FcdhhCEGszXHUHUQ0YdHhmJ2xZRwFREVl-VVIJPGh-Y3QPWQkacnljdm5ZEwEHTXuJ84PRzbNGZhg9XBJLLD5-NjxF │
└──────────────────┴─────────────────┴────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant