Skip to content

Commit

Permalink
logging: update tags for samples (#3560)
Browse files Browse the repository at this point in the history
  • Loading branch information
SurferJeffAtGoogle authored and pongad committed Aug 14, 2018
1 parent 1ecbe07 commit d76486f
Showing 1 changed file with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ public LoggingSnippets(Logging logging) {
// [VARIABLE "my_sink_name"]
// [VARIABLE "my_dataset"]
public Sink createSink(String sinkName, String datasetName) {
// [START createSink]
// [START logging_create_sink]
SinkInfo sinkInfo = SinkInfo.of(sinkName, DatasetDestination.of(datasetName));
Sink sink = logging.create(sinkInfo);
// [END createSink]
// [END logging_create_sink]
return sink;
}

Expand Down Expand Up @@ -96,13 +96,13 @@ public Sink createSinkAsync(String sinkName, String datasetName)
// [VARIABLE "my_sink_name"]
// [VARIABLE "my_dataset"]
public Sink updateSink(String sinkName, String datasetName) {
// [START updateSink]
// [START logging_update_sink]
SinkInfo sinkInfo = SinkInfo.newBuilder(sinkName, DatasetDestination.of(datasetName))
.setVersionFormat(SinkInfo.VersionFormat.V2)
.setFilter("severity>=ERROR")
.build();
Sink sink = logging.update(sinkInfo);
// [END updateSink]
// [END logging_update_sink]
return sink;
}

Expand Down Expand Up @@ -163,12 +163,12 @@ public Sink getSinkAsync(String sinkName) throws ExecutionException, Interrupted
*/
// [TARGET listSinks(ListOption...)]
public Page<Sink> listSinks() {
// [START listSinks]
// [START logging_list_sinks]
Page<Sink> sinks = logging.listSinks(ListOption.pageSize(100));
for (Sink sink : sinks.iterateAll()) {
// do something with the sink
}
// [END listSinks]
// [END logging_list_sinks]
return sinks;
}

Expand All @@ -194,14 +194,14 @@ public Page<Sink> listSinksAsync() throws ExecutionException, InterruptedExcepti
// [TARGET deleteSink(String)]
// [VARIABLE "my_sink_name"]
public boolean deleteSink(String sinkName) {
// [START deleteSink]
// [START logging_delete_sink]
boolean deleted = logging.deleteSink(sinkName);
if (deleted) {
// the sink was deleted
} else {
// the sink was not found
}
// [END deleteSink]
// [END logging_delete_sink]
return deleted;
}

Expand Down Expand Up @@ -230,14 +230,14 @@ public boolean deleteSinkAsync(String sinkName) throws ExecutionException, Inter
// [TARGET deleteLog(String)]
// [VARIABLE "my_log_name"]
public boolean deleteLog(String logName) {
// [START deleteLog]
// [START logging_delete_log]
boolean deleted = logging.deleteLog(logName);
if (deleted) {
// the log was deleted
} else {
// the log was not found
}
// [END deleteLog]
// [END logging_delete_log]
return deleted;
}

Expand Down Expand Up @@ -463,7 +463,7 @@ public boolean deleteMetricAsync(String metricName)
// [TARGET write(Iterable, WriteOption...)]
// [VARIABLE "my_log_name"]
public void write(String logName) {
// [START write]
// [START logging_write_log_entry]
List<LogEntry> entries = new ArrayList<>();
entries.add(LogEntry.of(StringPayload.of("Entry payload")));
Map<String, Object> jsonMap = new HashMap<>();
Expand All @@ -473,7 +473,7 @@ public void write(String logName) {
entries,
WriteOption.logName(logName),
WriteOption.resource(MonitoredResource.newBuilder("global").build()));
// [END write]
// [END logging_write_log_entry]
}

/**
Expand All @@ -482,12 +482,12 @@ public void write(String logName) {
// [TARGET listLogEntries(EntryListOption...)]
// [VARIABLE "logName=projects/my_project_id/logs/my_log_name"]
public Page<LogEntry> listLogEntries(String filter) {
// [START listLogEntries]
// [START logging_list_log_entries]
Page<LogEntry> entries = logging.listLogEntries(EntryListOption.filter(filter));
for (LogEntry entry : entries.iterateAll()) {
// do something with the entry
}
// [END listLogEntries]
// [END logging_list_log_entries]
return entries;
}

Expand Down

0 comments on commit d76486f

Please sign in to comment.