syntax = "proto3";

package golem.worker;

import "google/protobuf/timestamp.proto";
import "golem/worker/idempotency_key.proto";

message LogEvent {
  oneof event {
    StdOutLog stdout = 1;
    StdErrLog stderr = 2;
    Log log = 3;
    InvocationStarted invocation_started = 4;
    InvocationFinished invocation_finished = 5;
    ClientLagged client_lagged = 6;
  }
}

message StdOutLog {
  string message = 1;
  google.protobuf.Timestamp timestamp = 2;
}

message StdErrLog {
  string message = 1;
  google.protobuf.Timestamp timestamp = 2;
}

enum Level {
  TRACE = 0;
  DEBUG = 1;
  INFO = 2;
  WARN = 3;
  ERROR = 4;
  CRITICAL = 5;
}

message Log {
  Level level = 1;
  string context = 2;
  string message = 3;
  google.protobuf.Timestamp timestamp = 4;
}

message InvocationStarted {
  google.protobuf.Timestamp timestamp = 1;
  string function = 2;
  IdempotencyKey idempotency_key = 3;
}

message InvocationFinished {
  google.protobuf.Timestamp timestamp = 1;
  string function = 2;
  IdempotencyKey idempotency_key = 3;
}

/**
 * The client fell behind and the point it left of is no longer in our buffer.
 * {number_of_skipped_messages} is the number of messages between the client left of and the point it is now at.
 */
message ClientLagged {
  uint64 number_of_missed_messages = 1;
}
