Skip to content

Commit 601c329

Browse files
Aman Sharmameta-codesync[bot]
authored andcommitted
Create an MLoggerFactory
Summary: Previously, we just had one `MLogger` for the whole `MoQServer`. Instead, we'd like to have one `MLogger` per `MoQSession`, which is similar to how we have one `QLogger` for each QUIC connection in mvfst. In order to do this, I'm creating an `MLoggerFactory` member of the `MoQServer` that would allow us to create a new `MLogger` whenever a new session is created. Reviewed By: sandarsh Differential Revision: D89325703 fbshipit-source-id: 0abfa5e980c238b73ca850210ad1a6e3edfc6b29
1 parent 395fc82 commit 601c329

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

moxygen/mlog/FileMLoggerFactory.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the LICENSE
5+
* file in the root directory of this source tree.
6+
*
7+
*/
8+
9+
#pragma once
10+
11+
#include <string>
12+
#include "moxygen/mlog/MLoggerFactory.h"
13+
14+
namespace moxygen {
15+
16+
// Creates an MLogger that writes to a file
17+
class FileMLoggerFactory : public MLoggerFactory {
18+
public:
19+
FileMLoggerFactory(const std::string& path, VantagePoint vantagePoint)
20+
: path_(path), vantagePoint_(vantagePoint) {}
21+
22+
std::shared_ptr<MLogger> createMLogger() override {
23+
auto logger = std::make_shared<MLogger>(vantagePoint_);
24+
logger->setPath(path_);
25+
return logger;
26+
}
27+
28+
private:
29+
std::string path_;
30+
VantagePoint vantagePoint_;
31+
};
32+
33+
} // namespace moxygen

moxygen/mlog/MLoggerFactory.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the LICENSE
5+
* file in the root directory of this source tree.
6+
*
7+
*/
8+
9+
#pragma once
10+
11+
#include <memory>
12+
#include "moxygen/mlog/MLogger.h"
13+
14+
namespace moxygen {
15+
16+
class MLoggerFactory {
17+
public:
18+
virtual ~MLoggerFactory() = default;
19+
20+
virtual std::shared_ptr<MLogger> createMLogger() = 0;
21+
};
22+
23+
} // namespace moxygen

0 commit comments

Comments
 (0)