New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

stacklogging

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stacklogging - pypi Package Compare versions

Comparing version
0.1.2
to
0.1.4
+1
-1
PKG-INFO
Metadata-Version: 1.0
Name: stacklogging
Version: 0.1.2
Version: 0.1.4
Summary: Python structured logging with Google Cloud Stackdriver API integration

@@ -5,0 +5,0 @@ Home-page: https://github.com/bufferapp/stacklogging

@@ -43,3 +43,4 @@ # Stacklogging

"file": "test.py",
"function": "sum"
"function": "sum",
"line": 6
}

@@ -49,4 +50,31 @@ }

It is also possible to log extra fields at runtime using the `extra` parameter.
```python
logger.info("message", extra={"from": "Alice", "to": "Bob"})
```
Stacklogging will add the extra keys to the final JSON:
```json
{
"message": "Email sent",
"timestamp": {
"seconds": 1548260191,
"nanos": 256482124
},
"thread": 140166127678976,
"severity": "INFO",
"sourceLocation": {
"file": "test.py",
"function": "sum",
"line": 9
},
"from": "Alice",
"to": "Bob"
}
```
## License
MIT © Buffer

@@ -8,3 +8,3 @@ # !/usr/bin/env python

packages=find_packages(),
version="0.1.2",
version="0.1.4",
description="Python structured logging with Google Cloud Stackdriver API integration",

@@ -11,0 +11,0 @@ author="David Gasquez",

Metadata-Version: 1.0
Name: stacklogging
Version: 0.1.2
Version: 0.1.4
Summary: Python structured logging with Google Cloud Stackdriver API integration

@@ -5,0 +5,0 @@ Home-page: https://github.com/bufferapp/stacklogging

@@ -5,3 +5,39 @@ import logging

RESERVED = frozenset(
(
"args",
"asctime",
"created",
"exc_info",
"exc_text",
"filename",
"funcName",
"id",
"levelname",
"levelno",
"lineno",
"module",
"msecs",
"message",
"msg",
"name",
"pathname",
"process",
"processName",
"relativeCreated",
"stack_info",
"thread",
"threadName",
)
)
def get_extra_keys(record, reserved=RESERVED):
extra_keys = []
for key, value in record.__dict__.items():
if key not in reserved and not key.startswith("_"):
extra_keys.append(key)
return extra_keys
def format_stackdriver_json(record, message):

@@ -15,5 +51,14 @@ subsecond, second = math.modf(record.created)

"severity": record.levelname,
"sourceLocation": {"file": record.filename, "function": record.funcName},
"sourceLocation": {
"file": record.filename,
"function": record.funcName,
"line": record.lineno,
},
}
extra_keys = get_extra_keys(record)
for key in extra_keys:
payload[key] = record.__dict__[key]
return json.dumps(payload)

@@ -20,0 +65,0 @@