1// Copyright (c) 2012 The Chromium OS 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 LIBBRILLO_BRILLO_SYSLOG_LOGGING_H_ 6#define LIBBRILLO_BRILLO_SYSLOG_LOGGING_H_ 7 8#include <string> 9 10#include <brillo/brillo_export.h> 11 12namespace brillo { 13 14enum InitFlags { 15 kLogToSyslog = 1, 16 kLogToStderr = 2, 17 kLogHeader = 4, 18}; 19 20// Initialize logging subsystem. |init_flags| is a bitfield, with bits defined 21// in InitFlags above. 22BRILLO_EXPORT void InitLog(int init_flags); 23// Gets the current logging flags. 24BRILLO_EXPORT int GetLogFlags(); 25// Sets the current logging flags. 26BRILLO_EXPORT void SetLogFlags(int log_flags); 27// Convenience function for configuring syslog via openlog. Users 28// could call openlog directly except for naming collisions between 29// base/logging.h and syslog.h. Similarly users cannot pass the 30// normal parameters so we pick a representative set. |log_pid| 31// causes pid to be logged with |ident|. 32BRILLO_EXPORT void OpenLog(const char* ident, bool log_pid); 33// Start accumulating the logs to a string. This is inefficient, so 34// do not set to true if large numbers of log messages are coming. 35// Accumulated logs are only ever cleared when the clear function ings 36// called. 37BRILLO_EXPORT void LogToString(bool enabled); 38// Get the accumulated logs as a string. 39BRILLO_EXPORT std::string GetLog(); 40// Clear the accumulated logs. 41BRILLO_EXPORT void ClearLog(); 42// Returns true if the accumulated log contains the given string. Useful 43// for testing. 44BRILLO_EXPORT bool FindLog(const char* string); 45 46} // namespace brillo 47 48#endif // LIBBRILLO_BRILLO_SYSLOG_LOGGING_H_ 49