proxygen
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
main.cpp
Go to the documentation of this file.
1
/*
2
* Copyright 2017-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
#include <
folly/init/Init.h
>
17
#include <
folly/logging/Init.h
>
18
#include <
folly/logging/xlog.h
>
19
20
#include <
folly/logging/example/lib.h
>
21
22
using namespace
example
;
23
24
// Invoking code that uses XLOG() statements before main() is safe.
25
// This will use default log settings defined by folly::initializeLoggerDB().
26
static
ExampleObject
staticInitialized
(
"static"
);
27
28
// Configure folly to enable INFO+ messages, and everything else to
29
// enable WARNING+.
30
//
31
// Set the default log handler to log asynchronously by default
32
// (except log messages with level WARNING and above synchronously)
33
FOLLY_INIT_LOGGING_CONFIG
(
34
".=WARNING,folly=INFO; default:async=true,sync_level=WARNING"
);
35
36
int
main
(
int
argc,
char
*
argv
[]) {
37
// Using log macros before calling folly::initLogging() will use the default
38
// log settings defined by folly::initializeLoggerDB(). The default behavior
39
// is to log WARNING+ messages to stderr.
40
XLOG
(INFO) <<
"log messages less than WARNING will be ignored"
;
41
XLOG
(ERR) <<
"error messages before initLogging() will be logged to stderr"
;
42
43
// folly::Init() will automatically initialize the logging settings based on
44
// the FOLLY_INIT_LOGGING_CONFIG declaration above and the --logging command
45
// line flag.
46
auto
init
=
folly::Init
(&argc, &argv);
47
48
// All XLOG() statements in this file will log to the category
49
// folly.logging.example.main
50
XLOG
(INFO,
"now the normal log settings have been applied"
);
51
52
XLOG
(DBG1,
"log arguments are concatenated: "
, 12345,
", "
, 92.0);
53
XLOGF
(DBG1,
"XLOGF supports {}-style formatting: {:.3f}"
,
"python"
, 1.0 / 3);
54
XLOG
(DBG2) <<
"streaming syntax is also supported: "
<< 1234;
55
XLOG
(DBG2,
"if you really want, "
,
"you can even"
)
56
<<
" mix function-style and streaming syntax: "
<< 42;
57
XLOGF
(DBG3,
"and {} can mix {} style"
,
"you"
,
"format"
) <<
" and streaming"
;
58
59
ExampleObject
(
"foo"
);
60
XLOG
(INFO) <<
"main returning"
;
61
return
0;
62
}
folly::Init
Definition:
Init.h:47
FOLLY_INIT_LOGGING_CONFIG
FOLLY_INIT_LOGGING_CONFIG(".=WARNING,folly=INFO; default:async=true,sync_level=WARNING")
lib.h
example
Definition:
lib.cpp:18
bm::init
void init()
Definition:
BitVectorCodingTest.cpp:80
argv
char ** argv
Definition:
SmallLocksBenchmark.cpp:430
staticInitialized
static ExampleObject staticInitialized("static")
example::ExampleObject
Definition:
lib.h:23
main
int main(int argc, char **argv)
Definition:
main.cpp:18
XLOGF
#define XLOGF(level, fmt, arg1,...)
Definition:
xlog.h:77
Init.h
XLOG
#define XLOG(level,...)
Definition:
xlog.h:57
xlog.h
Init.h
proxygen
folly
folly
logging
example
main.cpp
Generated by
1.8.11