1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "flutter/fml/log_settings.h"
6
7#include <fcntl.h>
8#include <string.h>
9
10#include <algorithm>
11#include <iostream>
12
13#include "flutter/fml/logging.h"
14
15namespace fml {
16namespace state {
17
18// Defined in log_settings_state.cc.
19extern LogSettings g_log_settings;
20
21} // namespace state
22
23void SetLogSettings(const LogSettings& settings) {
24 // Validate the new settings as we set them.
25 state::g_log_settings.min_log_level =
26 std::min(LOG_FATAL, settings.min_log_level);
27}
28
29LogSettings GetLogSettings() {
30 return state::g_log_settings;
31}
32
33int GetMinLogLevel() {
34 return std::min(state::g_log_settings.min_log_level, LOG_FATAL);
35}
36
37ScopedSetLogSettings::ScopedSetLogSettings(const LogSettings& settings) {
38 old_settings_ = GetLogSettings();
39 SetLogSettings(settings);
40}
41
42ScopedSetLogSettings::~ScopedSetLogSettings() {
43 SetLogSettings(old_settings_);
44}
45
46} // namespace fml
47