examples/iot-nirvana/client/src/main/java/com/google/cloud/demo/iot/nirvana/client/LogUtils.java
/**
   * Write logs into Cloud Logging
   *
   * @param logger the object used to write logs into Cloud Logging
   * @param severity the severity of the log INFO, DEBUG, WARNING, ERROR
   * @param text the message that you want to log
   * @param gcpProjectId the name of the project where you want to write logs
   */
Write logs into Cloud Logging
@param logger the object used to write logs into Cloud Logging
@param severity the severity of the log INFO, DEBUG, WARNING, ERROR
@param text the message that you want to log
@param gcpProjectId the name of the project where you want to write logs
Write logs into Cloud Logging @param logger the object used to write logs into Cloud Logging @param severity the severity of the log INFO DEBUG WARNING ERROR @param text the message that you want to log @param gcpProjectId the name of the project where you want to write logs
static void writeLog(
      Logging logger,
      String text,
      Severity severity,
      String monitoredResourceName,
      String gcpProjectId) {
    LogEntry entry =
        LogEntry.newBuilder(StringPayload.of(text))
            .setSeverity(severity)
            .setLogName(CLOUD_LOGGING_DEVICE_SIMULATOR)
            .setResource(
                MonitoredResource.newBuilder("global")
                    .addLabel("project_id", gcpProjectId)
                    .addLabel("name", monitoredResourceName)
                    .build())
            .build();
    logger.write(Collections.singleton(entry));
  }
static void writeLog ( Logging logger , String text , Severity severity , String monitoredResourceName , String gcpProjectId ) { LogEntry entry = LogEntry . newBuilder ( StringPayload . of ( text ) ) . setSeverity ( severity ) . setLogName ( CLOUD_LOGGING_DEVICE_SIMULATOR ) . setResource ( MonitoredResource . newBuilder ( "global" ) . addLabel ( "project_id" , gcpProjectId ) . addLabel ( "name" , monitoredResourceName ) . build ( ) ) . build ( ) ; logger . write ( Collections . singleton ( entry ) ) ; }
Write logs into Cloud Logging
 @param logger the object used to write logs into Cloud Logging
 @param severity the severity of the log INFO, DEBUG, WARNING, ERROR
 @param text the message that you want to log
 @param gcpProjectId the name of the project where you want to write logs
Write logs into Cloud Logging @param logger the object used to write logs into Cloud Logging @param severity the severity of the log INFO DEBUG WARNING ERROR @param text the message that you want to log @param gcpProjectId the name of the project where you want to write logs
// Prepare entry // Write the log entry asynchronously