1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 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 LogCommandLineHandler_h 8 #define LogCommandLineHandler_h 9 10 #include <functional> 11 #include "nsString.h" 12 13 namespace mozilla { 14 15 /** 16 * A helper function parsing provided command line arguments and handling two 17 * specific args: 18 * 19 * -MOZ_LOG=modulelist 20 * -MOZ_LOG_FILE=file/path 21 * 22 * both expecting an argument, and corresponding to the same-name environment 23 * variables we use for logging setup. 24 * 25 * When an argument is found in the proper form, the consumer callback is called 26 * with a string in a follwing form, note that we do this for every occurence, 27 * and not just at the end of the parsing: 28 * 29 * "MOZ_LOG=modulelist" or "MOZ_LOG_FILE=file/path" 30 * 31 * All the following forms of arguments of the application are possible: 32 * 33 * --MOZ_LOG modulelist 34 * -MOZ_LOG modulelist 35 * --MOZ_LOG=modulelist 36 * -MOZ_LOG=modulelist 37 * 38 * The motivation for a separte function and not implementing a command line 39 * handler interface is that we need to process this very early during the 40 * application startup. Command line handlers are proccessed way later 41 * after logging has already been set up. 42 */ 43 void LoggingHandleCommandLineArgs( 44 int argc, char const* const* argv, 45 std::function<void(nsACString const&)> const& consumer); 46 47 } // namespace mozilla 48 49 #endif 50