1 | /* |
2 | * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. |
3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 | * |
5 | * This code is free software; you can redistribute it and/or modify it |
6 | * under the terms of the GNU General Public License version 2 only, as |
7 | * published by the Free Software Foundation. |
8 | * |
9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
12 | * version 2 for more details (a copy is included in the LICENSE file that |
13 | * accompanied this code). |
14 | * |
15 | * You should have received a copy of the GNU General Public License version |
16 | * 2 along with this work; if not, write to the Free Software Foundation, |
17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
18 | * |
19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 | * or visit www.oracle.com if you need additional information or have any |
21 | * questions. |
22 | * |
23 | */ |
24 | #ifndef SHARE_LOGGING_LOGSELECTION_HPP |
25 | #define SHARE_LOGGING_LOGSELECTION_HPP |
26 | |
27 | #include "logging/logLevel.hpp" |
28 | #include "logging/logTag.hpp" |
29 | #include "memory/allocation.hpp" |
30 | |
31 | class LogTagSet; |
32 | |
33 | // Class representing a selection of tags with for a given level. |
34 | // Consists of a set of tags, an optional wildcard flag, and a level, e.g. "tag1+tag2*=level". |
35 | class LogSelection : public StackObj { |
36 | friend class LogSelectionList; |
37 | |
38 | private: |
39 | size_t _ntags; |
40 | LogTagType _tags[LogTag::MaxTags]; |
41 | bool _wildcard; |
42 | LogLevelType _level; |
43 | size_t _tag_sets_selected; |
44 | |
45 | LogSelection(); |
46 | |
47 | public: |
48 | static const LogSelection Invalid; |
49 | |
50 | static LogSelection parse(const char* str, outputStream* error_stream = NULL); |
51 | |
52 | LogSelection(const LogTagType tags[LogTag::MaxTags], bool wildcard, LogLevelType level); |
53 | |
54 | bool operator==(const LogSelection& ref) const; |
55 | bool operator!=(const LogSelection& ref) const; |
56 | |
57 | size_t ntags() const; |
58 | LogLevelType level() const; |
59 | size_t tag_sets_selected() const; |
60 | |
61 | bool selects(const LogTagSet& ts) const; |
62 | bool consists_of(const LogTagType tags[LogTag::MaxTags]) const; |
63 | |
64 | int describe_tags(char* buf, size_t bufsize) const; |
65 | int describe(char* buf, size_t bufsize) const; |
66 | |
67 | // List similar selections that matches existing tag sets on the given outputstream |
68 | void suggest_similar_matching(outputStream* out) const; |
69 | |
70 | // Compute a similarity measure in the range [0, 1], where higher means more similar |
71 | double similarity(const LogSelection& other) const; |
72 | }; |
73 | |
74 | #endif // SHARE_LOGGING_LOGSELECTION_HPP |
75 | |