Batch(logger, client, *, resource=None)
Context manager: collect entries to log via a single API call.
Helper returned by Logger.batch
Parameters | |
---|---|
Name | Description |
logger |
logging_v2.logger.Logger
the logger to which entries will be logged. |
client |
The client to use. |
resource |
Optional[
Monitored resource of the batch, defaults to None, which requires that every entry should have a resource specified. Since the methods used to write entries default the entry's resource to the global resource type, this parameter is only required if explicitly set to None. If no entries' resource are set to None, this parameter will be ignored on the server. |
Methods
commit
commit(*, client=None, partial_success=True)
Send saved log entries as a single API call.
Parameters | |
---|---|
Name | Description |
client |
Optional[
The client to use. If not passed, falls back to the |
partial_success |
Optional[bool]
Whether a batch's valid entries should be written even if some other entry failed due to a permanent error such as INVALID_ARGUMENT or PERMISSION_DENIED. |
log
log(message=None, **kw)
Add an arbitrary message to be logged during commit
.
Type will be inferred based on the input message.
Parameters | |
---|---|
Name | Description |
kw |
Optional[dict]
Additional keyword arguments for the entry. See |
message |
Optional[str or dict or google.protobuf.Message]
The message. to log |
log_empty
log_empty(**kw)
Add a entry without payload to be logged during commit
.
Parameter | |
---|---|
Name | Description |
kw |
Optional[dict]
Additional keyword arguments for the entry. See |
log_proto
log_proto(message, **kw)
Add a protobuf entry to be logged during commit
.
Parameters | |
---|---|
Name | Description |
kw |
Optional[dict]
Additional keyword arguments for the entry. See |
message |
google.protobuf.Message
The protobuf entry. |
log_struct
log_struct(info, **kw)
Add a struct entry to be logged during commit
.
Parameters | |
---|---|
Name | Description |
kw |
Optional[dict]
Additional keyword arguments for the entry. See |
info |
dict
The struct entry, |
log_text
log_text(text, **kw)
Add a text entry to be logged during commit
.
Parameters | |
---|---|
Name | Description |
kw |
Optional[dict]
Additional keyword arguments for the entry. See |
text |
str
the text entry |