DDLogCategory.h (1577B)
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim:set ts=2 sw=2 sts=2 et cindent: */ 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 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef DDLogCategory_h_ 8 #define DDLogCategory_h_ 9 10 #include "mozilla/Assertions.h" 11 #include "mozilla/DefineEnum.h" 12 13 namespace mozilla { 14 15 // Enum used to categorize log messages. 16 // Those starting with '_' are for internal use only. 17 MOZ_DEFINE_ENUM_CLASS(DDLogCategory, 18 (_Construction, _DerivedConstruction, _Destruction, _Link, 19 _Unlink, Property, Event, API, Log, MozLogError, 20 MozLogWarning, MozLogInfo, MozLogDebug, MozLogVerbose)); 21 22 // Corresponding short strings, used as JSON property names when logs are 23 // retrieved. 24 extern const char* const kDDLogCategoryShortStrings[kDDLogCategoryCount]; 25 26 inline const char* ToShortString(DDLogCategory aCategory) { 27 MOZ_ASSERT(static_cast<size_t>(aCategory) < kDDLogCategoryCount); 28 return kDDLogCategoryShortStrings[static_cast<size_t>(aCategory)]; 29 } 30 31 // Corresponding long strings, for use in descriptive UI. 32 extern const char* const kDDLogCategoryLongStrings[kDDLogCategoryCount]; 33 34 inline const char* ToLongString(DDLogCategory aCategory) { 35 MOZ_ASSERT(static_cast<size_t>(aCategory) < kDDLogCategoryCount); 36 return kDDLogCategoryLongStrings[static_cast<size_t>(aCategory)]; 37 } 38 39 } // namespace mozilla 40 41 #endif // DDLogCategory_h_