1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
7 // Some of this code is cut-and-pasted from nICEr. Copyright is:
10 Copyright (c) 2007, Adobe Systems, Incorporated
13 Redistribution and use in source and binary forms, with or without
14 modification, are permitted provided that the following conditions are
17 * Redistributions of source code must retain the above copyright
18 notice, this list of conditions and the following disclaimer.
20 * Redistributions in binary form must reproduce the above copyright
21 notice, this list of conditions and the following disclaimer in the
22 documentation and/or other materials provided with the distribution.
24 * Neither the name of Adobe Systems, Network Resonance nor the names of its
25 contributors may be used to endorse or promote products derived from
26 this software without specific prior written permission.
28 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
29 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
30 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
31 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
33 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
34 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 /* This Source Code Form is subject to the terms of the Mozilla Public
42 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
43 * You can obtain one at http://mozilla.org/MPL/2.0/. */
45 /* Original author: bcampen@mozilla.com */
48 This file defines an r_dest_vlog that can be used to accumulate log messages
49 for later inspection/filtering. The intent is to use this for interactive
50 debug purposes on an about:webrtc page or similar.
53 #ifndef rlogconnector_h__
54 #define rlogconnector_h__
62 #include "mozilla/Mutex.h"
64 #include "m_cpp_utils.h"
71 NB: These are not threadsafe, nor are they safe to call during static
74 static RLogConnector
* CreateInstance();
75 static RLogConnector
* GetInstance();
76 static void DestroyInstance();
79 Retrieves log statements that match a given substring, subject to a
80 limit. |matching_logs| will be filled in chronological order (front()
81 is oldest, back() is newest). |limit| == 0 will be interpreted as no
84 void Filter(const std::string
& substring
, uint32_t limit
,
85 std::deque
<std::string
>* matching_logs
);
87 void FilterAny(const std::vector
<std::string
>& substrings
, uint32_t limit
,
88 std::deque
<std::string
>* matching_logs
);
90 inline void GetAny(uint32_t limit
, std::deque
<std::string
>* matching_logs
) {
91 Filter("", limit
, matching_logs
);
94 void SetLogLimit(uint32_t new_limit
);
95 bool ShouldLog(int level
) const;
96 void Log(int level
, std::string
&& log
);
99 // Methods to signal when a PeerConnection exists in a Private Window.
100 void EnterPrivateMode();
101 void ExitPrivateMode();
107 void AddMsg(std::string
&& msg
);
109 static RLogConnector
* instance
;
112 * Might be worthwhile making this a circular buffer, but I think it is
113 * preferable to take up as little space as possible if no logging is
114 * happening/the ringbuffer is not being used.
116 std::deque
<std::string
> log_messages_
;
117 /* Max size of log buffer (should we use time-depth instead/also?) */
119 OffTheBooksMutex mutex_
;
120 uint32_t disableCount_
;
122 DISALLOW_COPY_ASSIGN(RLogConnector
);
123 }; // class RLogConnector
125 } // namespace mozilla
127 #endif // rlogconnector_h__