-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
2,160 additions
and
736 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import 'dart:async'; | ||
|
||
import 'package:logger/logger.dart'; | ||
import 'package:viam_sdk/src/gen/google/protobuf/timestamp.pb.dart'; | ||
|
||
import '../gen/app/v1/robot.pbgrpc.dart'; | ||
import '../gen/common/v1/common.pb.dart'; | ||
|
||
/// gRPC client for connecting to app's RobotService. | ||
/// | ||
/// All calls must be authenticated. | ||
class AppRobotClient { | ||
final RobotServiceClient _client; | ||
|
||
AppRobotClient(this._client); | ||
|
||
/// Log the OutputEvent to app with the given partId. | ||
Future<void> log(String partId, host, loggerName, OutputEvent event) async { | ||
late String level; | ||
switch (event.level) { | ||
case Level.debug: | ||
level = 'debug'; | ||
case Level.warning: | ||
level = 'warning'; | ||
case Level.error: | ||
level = 'error'; | ||
default: | ||
// Assume info level if none of the above. | ||
level = 'info'; | ||
} | ||
|
||
// Assume log was just output (OutputEvent has no timestamp field). | ||
final Timestamp protoTs = Timestamp.fromDateTime(DateTime.now()); | ||
|
||
// Join lines with '\n' and suffix with '\n'. | ||
final String message = '${event.lines.join('\n')}\n'; | ||
|
||
final LogEntry entry = LogEntry(host: host, level: level, time: protoTs, loggerName: loggerName, message: message); | ||
final request = LogRequest(id: partId, logs: [entry]); | ||
await _client.log(request); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.