-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHttpStatusLogStream.cc
More file actions
44 lines (36 loc) · 1.08 KB
/
HttpStatusLogStream.cc
File metadata and controls
44 lines (36 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
* Copyright (C) 2021 Frank Mertens.
*
* Distribution and use is allowed under the terms of the GNU General Public License version 3
* (see CoreComponents/LICENSE-gpl-3.0).
*
*/
#include <cc/HttpStatusLogStream>
namespace cc {
struct HttpStatusLogStream::State: public Stream::State
{
State(HttpLoggingServiceInstance::State &sink, LoggingLevel level):
sink_{sink},
level_{level}
{}
void write(const Bytes &buffer, long fill) override
{
String message{buffer, 0, fill < 0 ? buffer.count() : fill}; // \todo inefficient
if (message.endsWith('\n')) {
sink_.logMessage(message, level_);
}
}
void write(const List<Bytes> &buffers) override
{
String message{buffers};
if (message.endsWith('\n')) {
sink_.logMessage(message, level_);
}
}
HttpLoggingServiceInstance::State &sink_;
LoggingLevel level_;
};
HttpStatusLogStream::HttpStatusLogStream(HttpLoggingServiceInstance::State &sink, LoggingLevel level):
Stream{new State{sink, level}}
{}
} // namespace cc