1 // Copyright 2013 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 CHROME_BROWSER_EXTENSIONS_API_LOG_PRIVATE_SYSLOG_PARSER_H_ 6 #define CHROME_BROWSER_EXTENSIONS_API_LOG_PRIVATE_SYSLOG_PARSER_H_ 7 8 #include <string> 9 #include <vector> 10 11 #include "base/memory/linked_ptr.h" 12 #include "chrome/browser/extensions/api/log_private/log_parser.h" 13 #include "chrome/common/extensions/api/log_private.h" 14 15 namespace extensions { 16 17 // A parser that parses syslog into LogEntry objects. 18 class SyslogParser : public LogParser { 19 public: 20 SyslogParser(); 21 virtual ~SyslogParser(); 22 23 protected: 24 // Parses one line log text into a LogEntry object. 25 virtual Error ParseEntry( 26 const std::string& input, 27 std::vector<linked_ptr<api::log_private::LogEntry> >* output, 28 FilterHandler* filter_handler) const 29 OVERRIDE; 30 31 private: 32 // Parses time token and get time in milliseconds. 33 Error ParseTime(const std::string& input, double* output) const; 34 // Parses process token and get process name and ID. 35 Error ParseProcess(const std::string& input, 36 api::log_private::LogEntry* entry) const; 37 // Parses level token and get log level. 38 void ParseLevel(const std::string& input, 39 api::log_private::LogEntry* entry) const; 40 41 DISALLOW_COPY_AND_ASSIGN(SyslogParser); 42 }; 43 44 } // namespace extensions 45 46 #endif // CHROME_BROWSER_EXTENSIONS_API_LOG_PRIVATE_SYSLOG_PARSER_H_ 47