proxygen
Init.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2016-present Facebook, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <folly/init/Init.h>
18 
19 #include <glog/logging.h>
20 
21 #include <folly/Singleton.h>
22 #include <folly/logging/Init.h>
24 
25 #if FOLLY_USE_SYMBOLIZER
27 #endif
29 
30 DEFINE_string(logging, "", "Logging configuration");
31 
32 namespace folly {
33 
34 void init(int* argc, char*** argv, bool removeFlags) {
35 #if FOLLY_USE_SYMBOLIZER
36  // Install the handler now, to trap errors received during startup.
37  // The callbacks, if any, can be installed later
39 #elif !defined(_WIN32)
40  google::InstallFailureSignalHandler();
41 #endif
42 
43  // Move from the registration phase to the "you can actually instantiate
44  // things now" phase.
46 
47  gflags::ParseCommandLineFlags(argc, argv, removeFlags);
48 
49  folly::initLoggingOrDie(FLAGS_logging);
50  auto programName = argc && argv && *argc > 0 ? (*argv)[0] : "unknown";
51  google::InitGoogleLogging(programName);
52 
53 #if FOLLY_USE_SYMBOLIZER
54  // Don't use glog's DumpStackTraceAndExit; rely on our signal handler.
55  google::InstallFailureFunction(abort);
56 
57  // Actually install the callbacks into the handler.
59 #endif
60 }
61 
62 Init::Init(int* argc, char*** argv, bool removeFlags) {
63  init(argc, argv, removeFlags);
64 }
65 
68 }
69 } // namespace folly
static SingletonVault * singleton()
Definition: Singleton.h:495
void installFatalSignalCallbacks()
FOLLY_NOINLINE Init(int *argc, char ***argv, bool removeFlags=true)
Definition: Init.cpp:62
DEFINE_string(logging,"","Logging configuration")
—— Concurrent Priority Queue Implementation ——
Definition: AtomicBitSet.h:29
void init(int *argc, char ***argv, bool removeFlags)
Definition: Init.cpp:34
char ** argv
FOLLY_NOINLINE ~Init()
Definition: Init.cpp:66
void installFatalSignalHandler()
void initLoggingOrDie(StringPiece configString)
Definition: Init.cpp:48