sapling/eden/fs/monitor/LogFile.h
Adam Simpkins 4f7fd33e29 add a new process to monitor EdenFS
Summary:
Add a simple new wrapper daemon to manage the edenfs daemon.  This is intended
to provide a few different features:

- Perform log rotation for EdenFS's output and the output of any of its
  spawned children processes.
- Help schedule restarts of EdenFS when the system looks idle.
- Provide a single process for the system to manage across graceful EdenFS
  restarts, to make management slightly simpler.

This initial commit does not perform graceful restarts yet, but has the basic
daemon management and log rotation present.

Reviewed By: wez

Differential Revision: D19588700

fbshipit-source-id: bba41c9f7efeb4417753c1d48dd72cf6d191f0c3
2020-01-31 13:22:26 -08:00

44 lines
804 B
C++

/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
#pragma once
#include <memory>
#include <folly/File.h>
#include <folly/io/async/EventHandler.h>
#include "eden/fs/utils/PathFuncs.h"
namespace facebook {
namespace eden {
class LogFile {
public:
explicit LogFile(const AbsolutePath& path);
/**
* Write data to the log file.
*
* If the full buffer was successfully written 0 is returned.
* Returns an errno value on failure.
*/
int write(const void* buffer, size_t size);
int fd() const {
return log_.fd();
}
private:
static constexpr size_t kBufferSize = 64 * 1024;
folly::File log_;
};
} // namespace eden
} // namespace facebook