vlog.h revision 3345a6884c488ff3a535c2c9acdd33d74b37e311
1// Copyright (c) 2010 The Chromium 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#ifndef BASE_VLOG_H_ 6#define BASE_VLOG_H_ 7#pragma once 8 9#include <cstddef> 10#include <string> 11#include <utility> 12#include <vector> 13 14#include "base/basictypes.h" 15#include "base/string_piece.h" 16 17namespace logging { 18 19// A helper class containing all the settings for vlogging. 20class VlogInfo { 21 public: 22 // |v_switch| gives the default maximal active V-logging level; 0 is 23 // the default. Normally positive values are used for V-logging 24 // levels. 25 // 26 // |vmodule_switch| gives the per-module maximal V-logging levels to 27 // override the value given by |v_switch|. 28 // E.g. "my_module=2,foo*=3" would change the logging level for all 29 // code in source files "my_module.*" and "foo*.*" ("-inl" suffixes 30 // are also disregarded for this matching). 31 VlogInfo(const std::string& v_switch, 32 const std::string& vmodule_switch); 33 34 // Returns the vlog level for a given file (usually taken from 35 // __FILE__). 36 int GetVlogLevel(const base::StringPiece& file); 37 38 static const int kDefaultVlogLevel; 39 40 private: 41 typedef std::pair<std::string, int> VmodulePattern; 42 43 int max_vlog_level_; 44 std::vector<VmodulePattern> vmodule_levels_; 45 46 DISALLOW_COPY_AND_ASSIGN(VlogInfo); 47}; 48 49} // namespace logging 50 51#endif // BASE_VLOG_H_ 52