forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
log_settings.cc
46 lines (33 loc) · 1.02 KB
/
log_settings.cc
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
45
46
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "flutter/fml/log_settings.h"
#include <fcntl.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include "flutter/fml/logging.h"
namespace fml {
namespace state {
// Defined in log_settings_state.cc.
extern LogSettings g_log_settings;
} // namespace state
void SetLogSettings(const LogSettings& settings) {
// Validate the new settings as we set them.
state::g_log_settings.min_log_level =
std::min(LOG_FATAL, settings.min_log_level);
}
LogSettings GetLogSettings() {
return state::g_log_settings;
}
int GetMinLogLevel() {
return std::min(state::g_log_settings.min_log_level, LOG_FATAL);
}
ScopedSetLogSettings::ScopedSetLogSettings(const LogSettings& settings) {
old_settings_ = GetLogSettings();
SetLogSettings(settings);
}
ScopedSetLogSettings::~ScopedSetLogSettings() {
SetLogSettings(old_settings_);
}
} // namespace fml