electron-log icon indicating copy to clipboard operation
electron-log copied to clipboard

Add gRPC as remote transport

Open tomaspiaggio opened this issue 3 years ago • 2 comments

For reasons that are inherent to my project, I need to implement gRPC transport instead of using http. I would like to contribute. My idea is the following (please note that this is pseudocode):

const service = /* grpcService */;
let hostAndPort;

function grpcTransport(electronLog) {
  if(hostAndPort) service.send(electronLog);
}

using the following proto

syntax = "proto3";

service RemoteLog {
  rpc Error(stream Message) returns (Empty) {}
  rpc Warn(stream Message) returns (Empty) {}
  rpc Info(stream Message) returns (Empty) {}
  rpc Verbose(stream Message) returns (Empty) {}
  rpc Debug(stream Message) returns (Empty) {}
  rpc Silly(stream Message) returns (Empty) {}
}

message Message {
  string content = 1;
}

message Empty {}

Do you have any suggestions?

Thank you.

tomaspiaggio avatar Apr 15 '21 17:04 tomaspiaggio

Thank you for the suggestion. I think it's pretty rare scenario when gRPC is used, so I it's better to keep such a module as a third-party library. I can add a link to such a transport to readme.

const log = require('electron-log');
const gRPCTransport = require('electron-log-grpc');

log.transports.grpc = gRPCTransport({ ...transportOptions });

megahertz avatar Apr 15 '21 18:04 megahertz

Ok. When I'm done, I'll let you know in case you want to update the documentation

tomaspiaggio avatar Apr 15 '21 22:04 tomaspiaggio

Please let me know if it's ready

megahertz avatar Nov 24 '22 12:11 megahertz