Logger(name, client, *, labels=None, resource=None)
Loggers represent named targets for log entries.
See https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.logs
Properties
client
Clent bound to the logger.
full_name
Fully-qualified name used in logging APIs
path
URI path for use in logging APIs
project
Project bound to the logger.
Methods
Logger
Logger(name, client, *, labels=None, resource=None)
Parameters | |
---|---|
Name | Description |
name |
str
The name of the logger. |
client |
A client which holds credentials and project configuration for the logger (which requires a project). |
resource |
Optional[
a monitored resource object representing the resource the code was run on. If not given, will be inferred from the environment. |
labels |
Optional[dict]
Mapping of default labels for entries written via this logger. |
batch
batch(*, client=None)
Return a batch to use as a context manager.
Parameter | |
---|---|
Name | Description |
client |
Union[None,
The client to use. If not passed, falls back to the |
Returns | |
---|---|
Type | Description |
Batch |
A batch to use as a context manager. |
delete
delete(logger_name=None, *, client=None)
Delete all entries in a logger via a DELETE request
See https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.logs/delete
Parameters | |
---|---|
Name | Description |
logger_name |
Optional[str]
The resource name of the log to delete: :: "projects/[PROJECT_ID]/logs/[LOG_ID]" "organizations/[ORGANIZATION_ID]/logs/[LOG_ID]" "billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]" "folders/[FOLDER_ID]/logs/[LOG_ID]" |
client |
Optional[
The client to use. If not passed, falls back to the |
list_entries
list_entries(
*,
resource_names=None,
filter_=None,
order_by=None,
max_results=None,
page_size=None,
page_token=None
)
Return a generator of log entry resources.
See https://cloud.google.com/logging/docs/reference/v2/rest/v2/entries/list
Parameters | |
---|---|
Name | Description |
resource_names |
Optional[Sequence[str]]
Names of one or more parent resources from which to retrieve log entries: :: "projects/[PROJECT_ID]" "organizations/[ORGANIZATION_ID]" "billingAccounts/[BILLING_ACCOUNT_ID]" "folders/[FOLDER_ID]" If not passed, defaults to the project bound to the client. |
filter_ |
Optional[str]
a filter expression. See https://cloud.google.com/logging/docs/view/advanced_filters By default, a 24 hour filter is applied. |
order_by |
Optional[str]
One of :data: |
max_results |
Optional[int]
Optional. The maximum number of entries to return. Non-positive values are treated as 0. If None, uses API defaults. |
page_size |
int
number of entries to fetch in each API call. Although requests are paged internally, logs are returned by the generator one at a time. If not passed, defaults to a value set by the API. |
page_token |
str
opaque marker for the starting "page" of entries. If not passed, the API will return the first page of entries. |
log
log(message=None, *, client=None, **kw)
Log an arbitrary message. Type will be inferred based on the input.
See https://cloud.google.com/logging/docs/reference/v2/rest/v2/entries/list
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 |
client |
Optional[
The client to use. If not passed, falls back to the |
log_empty
log_empty(*, client=None, **kw)
Log an empty message
See https://cloud.google.com/logging/docs/reference/v2/rest/v2/entries/write
Parameters | |
---|---|
Name | Description |
client |
Optional[
The client to use. If not passed, falls back to the |
kw |
Optional[dict]
additional keyword arguments for the entry. See |
log_proto
log_proto(message, *, client=None, **kw)
Log a protobuf message
See https://cloud.google.com/logging/docs/reference/v2/rest/v2/entries/list
Parameters | |
---|---|
Name | Description |
message |
google.protobuf.message.Message
The protobuf message to be logged. |
client |
Optional[
The client to use. If not passed, falls back to the |
kw |
Optional[dict]
additional keyword arguments for the entry. See |
log_struct
log_struct(info, *, client=None, **kw)
Log a dictionary message
See https://cloud.google.com/logging/docs/reference/v2/rest/v2/entries/write
Parameters | |
---|---|
Name | Description |
info |
dict
the log entry information |
client |
Optional[
The client to use. If not passed, falls back to the |
kw |
Optional[dict]
additional keyword arguments for the entry. See |
log_text
log_text(text, *, client=None, **kw)
Log a text message
See https://cloud.google.com/logging/docs/reference/v2/rest/v2/entries/write
Parameters | |
---|---|
Name | Description |
text |
str
the log message |
client |
Optional[
The client to use. If not passed, falls back to the |
kw |
Optional[dict]
additional keyword arguments for the entry. See |