/
ball_recordjsonformatter.h
713 lines (656 loc) · 26.6 KB
/
ball_recordjsonformatter.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
// ball_recordjsonformatter.h -*-C++-*-
#ifndef INCLUDED_BALL_RECORDJSONFORMATTER
#define INCLUDED_BALL_RECORDJSONFORMATTER
#include <bsls_ident.h>
BSLS_IDENT("$Id: $")
//@PURPOSE: Provide a formatter for log records that renders output in JSON.
//
//@CLASSES:
// ball::RecordJsonFormatter: formatter for rendering log records in JSON
//
//@SEE_ALSO: ball_record, ball_recordattributes
//
//@DESCRIPTION: This component provides a function object class,
// 'ball::RecorJsonFormatter', that formats a log record as JSON text elements
// according to a format specification (see {'Record Format Specification'}).
// 'ball::RecordJsonFormatter' is designed to match the function signature
// expected by many concrete 'ball::Observer' implementations that publish log
// records (for example, see 'ball::FileObserver2::setLogFileFunctor').
//
// NOTE: 'ball::RecorJsonFormatter' renders individual log records as JSON,
// but, for example, a resulting log file would contain a sequence of JSON
// strings, which is not itself valid JSON text.
//
///Record Format Specification
///---------------------------
// A format specification is, itself, a JSON array, supplied to a
// 'RecordJsonFormatter' object by the 'setFormat' function. If no format is
// specified, the default format is used. Each array element specifies the
// format of a log record field or a user-defined attribute. Here is a simple
// example:
//..
// [{"timestamp":{"format":"iso8601"}}, "pid", "tid", "severity", "message"]
//..
// would a result in a log record like:
//..
// { "timestamp": "2020-08-28T14:43:50.375Z",
// "pid": 2313,
// "tid": 12349388604,
// "severity": "INFO",
// "message": "Hello, world!"
// }
//..
// Again, the format specification is a JSON array, each element of which can
// be one of the following:
//
//: o A string containing the name of the fixed record field or the name of the
//: user-defined attribute, in which case the field or attribute will be
//: published in the default format. For example, '[timestamp]', would
//: display the timestamp as: '{"timestamp": "2020-08-28T14:43:50.375Z"}'.
//:
//: o A JSON object having the name of the fixed field or user-defined
//: attribute and a set of key-values pairs used to customize the output
//: format. For example,
//: '[{"timestamp": {"name": "My Time", "format": "bdePrint"}}]', would
//: display the timestamp as: '{"My Time": "28AUG2020_14:43:50.375"}'.
//
///Field Format Specification
/// - - - - - - - - - - - - -
// The following table lists the predefined string values for each fixed field
// and user-defined attributes in the log record:
//..
// Tag Description Example
// -------------- ------------------------- -------------
// "timestamp" creation date and time ["timestamp"]
// "pid" process id of creator ["pid"]
// "tid" thread id of creator ["tid"]
// "file" file where created (__FILE__) ["file"]
// "line" line number in file (__LINE__) ["line"]
// "category" category of logged record ["category"]
// "severity" severity of logged record ["severity"]
// "message" log message text ["message"]
// "attributes" all user-defined attributes ["attributes"]
// <attribute name> specific user-defined attribute ["bas.uuid"]
//..
// The output format of each field can be customized by replacing a string
// value in the JSON array with a JSON object having the same name and a set of
// key-value pairs (attributes).
//
///Verifying the Format Specification for 'setFormat'
/// - - - - - - - - - - - - - - - - - - - - - - - - -
// The sections that follow describe the set of fields that can be provided in
// the format specification supplied to 'setFormat'.
// 'RecordJsonFormatter::setFormat' will ignore fields in the provided format
// specification that are unknown, but will report an error if a known field
// contains a property that is not supported. For example: a format
// specification '["pid", { "timestamp" : {"unknown field!": "value"} }] will
// be accepted, but '["pid", {"timestamp": {"format": "unknown format" }}]'
// will produce an error.
//
// Each key-value pair of a JSON object that specifies a format of an output of
// a fixed record field or a user-defined attribute has the following
// constrains:
//
//: o The key is a string of known value listed in the column "Key" in the
//: tables below. Any string that does not match the listed values is
//: ignored.
//:
//: o The value is a string of known value (except for the "name" key) in the
//: column "Value Constraint" in the tables below. If the value does not
//: match the string values specified in the tables, the format specification
//: is considered to be inconsistent with the expected schema, and is
//: rejected by the 'RecordJsonFormatter::setFormat' method.
//
///The "timestamp" field format
///- - - - - - - - - -
// The format attributes of the "timestamp" object are given in the following
// table:
//..
// Value Default
// Key Description Constraint Value
// ------------------------ ---------------- ----------- ------------
// "name" name by which JSON string "timestamp"
// "timestamp" will
// be published
//
// "format" datetime format "iso8601", "iso8601"
// "bdePrint"
// (*Note*)
//
// "fractionalSecPrecision" second precision "none", "microseconds"
// "milliseconds",
// "microseconds"
//
// "timeZone" time zone "utc", "utc"
// "local"
//..
// *Note*: The default "bdePrint" format denotes the following datetime format:
//..
// DDMonYYYY_HH:MM:SS.mmm
//..
// For example, the following record format specification:
//..
// [ { "timestamp": { "name": "Time",
// "fractionalSecPrecision": "microseconds",
// "timeZone": "local" } }
// ]
//..
// would a result in a log record like:
//..
// { "Time": "28AUG2020_17:43:50.375345" }
//..
//
///The "pid" (process Id) field format
/// - - - - - - - - - - - -
// The format attributes of the process Id field are given in the following
// table:
//..
// Value Default
// Key Description Constraint Value
// ------ ------------------------------------- ----------- -------
// "name" name by which "pid" will be published JSON string "pid"
//..
// For example, the following record format specification:
//..
// [ { "pid": { "name": "Process Id" } } ]
//..
// would a result in a log record like:
//..
// { "Process Id": 2313 }
//..
//
///The "tid" (thread Id) field format
///- - - - - - - - - - - -
// The format attributes of the thread Id field are given in the following
// table:
//..
// Value Default
// Key Description Constraint Value
// -------- ------------------------------------- ----------- ---------
// "name" name by which "tid" will be published JSON string "tid"
//
// "format" output format "decimal", "decimal"
// "hex"
//..
// For example, the following record format specification:
//..
// [ { "tid": { "name": "Thread Id",
// "format": "hex" } }
// ]
//..
// would a result in a log record like:
//..
// { "Thread Id": 0xA7654EFF3540 }
//..
//
///The "file" field format
/// - - - - - - - - - - - -
// The format attributes of the "file" field are given in the following
// table:
//..
// Default
// Key Description Value Constraint Value
// ------ -------------------- ----------------------------- -------
// "name" name by which "file" JSON string "file"
// will be published
//
// "path" file path "full" (__FILE__), "full"
// "file" (basename of __FILE__)
//..
// For example, the following record format specification:
//..
// [ { "file": { "name": "File",
// "path": "file" } }
// ]
//..
// would a result in a log record like:
//..
// { "File": "test.cpp" }
//..
//
///The "line" field format
/// - - - - - - - -
// The format attributes of the "line" field are given in the following
// table:
//..
// Value Default
// Key Description Constraint Value
// ------ --------------------------------------- ----------- -------
// "name" name by which "line" will be published JSON string "line"
//..
// For example, the following record format specification:
//..
// [ { "line": { "name": "Line" } } ]
//..
// would a result in a log record like:
//..
// { "Line": 512 }
//..
//
///The "category" field format
/// - - - - - - - - -
// The format attributes of the "category" field are given in the following
// table:
//..
// Value Default
// Key Description Constraint Value
// ------ ------------------------------------------ ----------- ----------
// "name" name by which "category" will be published JSON string "category"
//..
// For example, the following record format specification:
//..
// [ { "category": { "name": "Category" } } ]
//..
// would a result in a log record like:
//..
// { "category": "Server" }
//..
//
///The "severity" field format
/// - - - - - - - - -
// The format attributes of the "severity" field are given in the following
// table:
//..
// Value Default
// Key Description Constraint Value
// ------ ------------------------------------------ ----------- ----------
// "name" name by which "severity" will be published JSON string "severity"
//..
// For example, the following record format specification:
//..
// [ { "severity": { "name": "severity" } } ]
//..
// would a result in a log record like:
//..
// { "Severity": "ERROR" }
//..
//
///The "message" field format
/// - - - - - - - - -
// A message is a JSON string which is a sequence of zero or more Unicode
// characters, wrapped in double quotes, using backslash escapes: (\", \\, \/,
// \b, \f, \n, \r, \t, \u{4 hex digits}).
//
// The format attributes of the "message" field are given in the following
// table:
//..
// Value Default
// Key Description Constraint Value
// ------ ----------------------------------------- ----------- ---------
// "name" name by which "message" will be published JSON string "message"
//..
// For example, the following record format specification:
//..
// [ { "message": { "name": "msg" } } ]
//..
// would a result in a log record like:
//..
// { "msg": "Log message" }
//..
//
///The "attributes" format
///- - - - - - - - - - -
// The "attributes" JSON object has no attributes. For example, the following
// record format specification:
//..
// [ "attributes" ]
//..
// would (assuming their are two attributes "bas.requestid" and
// "mylib.security") result in a log record like:
//..
// { "bas.requestid": 12345, "mylib.security": "My Security" }
//..
//
///A user-defined attribute format
///- - - - - - - - - - -
// Each user-defined attribute has a single "name" attribute that can be used
// to rename the user-defined attribute:
//..
// Value Default
// Key Description Constraint Value
// ------ ---------------------------- ----------- -------
// "name" name by which a user-defined JSON string none
// attribute will be published
//..
// For example, the following record format specification:
//..
// [ { "bas.uuid": { "name": "BAS.UUID" } } ]
//..
// would a result in a log record like:
//..
// { "BAS.UUID": 3593 }
//..
//
///The Record Separator
///--------------------
// The record separator is a string that is printed after each formatted
// record. The default value of the record separator is a single newline, but
// it can be set to any string of the user's choice using the
// 'RecordJsonFormatter::setRecordSeparator' function.
//
///Usage
///-----
// This section illustrates intended use of this component.
//
///Example: Format log records as JSON and render them to 'stdout'
///- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Suppose an application needs to format log records as JSON and output them
// to 'stdout'.
//
// First we instantiate a JSON record formatter:
//..
// ball::RecordJsonFormatter formatter;
//..
// Next we set a format specification to the newly created 'formatter':
//..
// int rc = formatter.setFormat("[\"tid\",\"message\"]");
// assert(0 == rc); (void)rc;
//..
// The chosen format specification indicates that, when a record is formatted
// using 'formatter', the thread Id attribute of the record will be output
// followed by the message attribute of the record.
//
// Then we create a default 'ball::Record' and set the thread Id and message
// attributes of the record to dummy values:
//..
// ball::Record record;
//
// record.fixedFields().setThreadID(6);
// record.fixedFields().setMessage("Hello, World!");
//..
// Next, invocation of the 'formatter' function object to format 'record' to
// 'bsl::cout':
//..
// formatter(bsl::cout, record);
//..
// yields this output, which is terminated by a single newline:
//..
// {"tid":6,"message":"Hello, World!"}
//..
// Finally, we change the record separator and format the same record again:
//..
// formatter.setFormat("\n\n");
// formatter(bsl::cout, record);
//..
// The record is printed in the same format, but now terminated by two
// newlines:
//..
// {"tid":6,"message":"Hello, World!"}
//
//..
#include <balscm_version.h>
#include <bslma_allocator.h>
#include <bslma_bslallocator.h>
#include <bslma_usesbslmaallocator.h>
#include <bslmf_isbitwisemoveable.h>
#include <bslmf_movableref.h>
#include <bslmf_nestedtraitdeclaration.h>
#include <bsls_keyword.h>
#include <bsl_functional.h>
#include <bsl_iosfwd.h>
#include <bsl_string.h>
#include <bsl_vector.h>
#include <bsl_ostream.h>
namespace BloombergLP {
namespace baljsn { class SimpleFormatter; }
namespace ball {
class Record;
class RecordAttributes;
class RecordJsonFormatter_FieldFormatter;
// =========================
// class RecordJsonFormatter
// =========================
class RecordJsonFormatter {
// This class provides a function object that formats a log record as JSON
// text elements and renders them to an output stream. The overloaded
// 'operator()' provided by the class formats log record according to JSON
// message format specification supplied at construction (either by the
// 'setFormat' manipulator or by default) and outputs the result to the
// stream. This functor type is designed to match the function signature
// expected by many concrete 'ball::Observer' implementations that publish
// log records (for example, see 'ball::FileObserver2::setLogFileFunctor').
// PRIVATE TYPES
typedef bslmf::MovableRefUtil MoveUtil;
// 'MoveUtil' is an alias for 'bslmf::MovableRefUtil'.
public:
// TYPES
typedef bsl::vector<RecordJsonFormatter_FieldFormatter*> FieldFormatters;
// 'FieldFormatters' is an alias for a vector of the
// 'RecordJsonFormatter_FieldFormatter' objects, each of which is
// initialized from the format specification and responsible for
// rendering one field of a 'ball::Record' to the output JSON stream.
typedef bsl::allocator<> allocator_type;
private:
// DATA
bsl::string d_formatSpec; // format specification (in JSON)
bsl::string d_recordSeparator; // string to print after each record
FieldFormatters d_fieldFormatters; // field formatters configured
// according to the format
// specification
// CLASS METHODS
static
void releaseFieldFormatters(FieldFormatters *formatters);
// Destroy the field formatters contained in the specified
// 'formatters'.
public:
// CREATORS
explicit RecordJsonFormatter(
const allocator_type& allocator = allocator_type());
// Create a record JSON formatter having a default format specification
// and record separator. Optionally specify an 'allocator' (e.g., the
// address of a 'bslma::Allocator' object) to supply memory; otherwise,
// the allocator is used. The default format specification is:
//..
// ["timestamp", "processId", "threadId", "severity", "file", "line",
// "category", "message", "attributes"]
//..
// The default record separator is "\n".
RecordJsonFormatter(
const RecordJsonFormatter& original,
const allocator_type& allocator = allocator_type());
// Create a record JSON formatter initialized to the value of the
// specified 'original' record formatter. Optionally specify an
// 'allocator' (e.g., the address of a 'bslma::Allocator' object) to
// supply memory; otherwise, the default allocator is used.
RecordJsonFormatter(bslmf::MovableRef<RecordJsonFormatter> original)
BSLS_KEYWORD_NOEXCEPT;
// Create a record JSON formatter having the same format specification
// and record separator as in the specified 'original' formatter, and
// adopting all outstanding memory allocations and the allocator
// associated with the 'original' formatter. 'original' is left in a
// valid but unspecified state.
RecordJsonFormatter(bslmf::MovableRef<RecordJsonFormatter> original,
const allocator_type& allocator);
// Create a record JSON formatter, having the same format specification
// and record separator as in the specified 'original' formatter. The
// format specification of 'original' is moved to the new object, and
// all outstanding memory allocations and the specified 'allocator' are
// adopted if 'allocator == original.get_allocator()'. 'original' is
// left in a valid but unspecified state.
~RecordJsonFormatter();
// Destroy this object.
// MANIPULATORS
RecordJsonFormatter& operator=(const RecordJsonFormatter& rhs);
// Assign to this object the value of the specified 'rhs' object, and
// return a reference providing modifiable access to this object.
RecordJsonFormatter& operator=(bslmf::MovableRef<RecordJsonFormatter> rhs);
// Assign to this object the format specification and record separator
// of the specified 'rhs' object, and return a reference providing
// modifiable access to this object. The format specification and
// record separator of 'rhs' are moved to this object, and all
// outstanding memory allocations and the allocator associated with
// 'rhs' are adopted if 'get_allocator() == rhs.get_allocator()'.
// 'rhs' is left in a valid but unspecified state.
int setFormat(const bsl::string_view& format);
// Set the message format specification (see
// {'Record Format Specification'}) of this record JSON formatter to
// the specified 'format'. Return 0 on success, and a non-zero value
// otherwise (if 'format' is not valid JSON *or* not a JSON conforming
// to the expected schema).
void setRecordSeparator(const bsl::string_view& recordSeparator);
// Set the record separator for this record JSON formatter to the
// specified 'recordSeparator'. The 'recordSeparator' will be printed
// by each invocation of 'operator()' after the formatted record. The
// default is a single newline character, "\n".
// ACCESSORS
void operator()(bsl::ostream& stream, const Record& record) const;
// Format the specified 'record' according to the current 'format' and
// 'recordSeparator' to the specified 'stream'.
const bsl::string& format() const;
// Return the message format specification of this record JSON
// formatter. See {'Record Format Specification'}.
const bsl::string& recordSeparator() const;
// Return the record separator of this record JSON formatter.
// Aspects
BSLS_DEPRECATE
bslma::Allocator *allocator() const;
// DEPRECATED: Use 'get_allocator().mechanism()' instead.
allocator_type get_allocator() const;
// Return the allocator used by this object to supply memory.
};
// FREE OPERATORS
bool operator==(const RecordJsonFormatter& lhs,
const RecordJsonFormatter& rhs);
// Return 'true' if the specified 'lhs' and 'rhs' record formatters have
// the same value, and 'false' otherwise. Two record formatters have the
// same value if they have the same format specification and record
// separator.
bool operator!=(const RecordJsonFormatter& lhs,
const RecordJsonFormatter& rhs);
// Return 'true' if the specified 'lhs' and 'rhs' record formatters do not
// have the same value, and 'false' otherwise. Two record formatters
// differ in value if their format specifications or record separators
// differ.
// ============================================================================
// INLINE DEFINITIONS
// ============================================================================
// -------------------------
// class RecordJsonFormatter
// -------------------------
// CREATORS
inline
RecordJsonFormatter::RecordJsonFormatter(const RecordJsonFormatter& original,
const allocator_type& allocator)
: d_formatSpec(original.d_formatSpec, allocator)
, d_recordSeparator(original.d_recordSeparator, allocator)
, d_fieldFormatters(allocator)
{
int rc = setFormat(d_formatSpec);
(void) rc;
BSLS_ASSERT(0 == rc);
}
inline
RecordJsonFormatter::RecordJsonFormatter(
bslmf::MovableRef<RecordJsonFormatter> original) BSLS_KEYWORD_NOEXCEPT
: d_formatSpec(MoveUtil::move(MoveUtil::access(original).d_formatSpec)),
d_recordSeparator(
MoveUtil::move(MoveUtil::access(original).d_recordSeparator)),
d_fieldFormatters(
MoveUtil::move(MoveUtil::access(original).d_fieldFormatters))
{
}
inline
RecordJsonFormatter::RecordJsonFormatter(
bslmf::MovableRef<RecordJsonFormatter> original,
const allocator_type& allocator)
: d_formatSpec(MoveUtil::move(MoveUtil::access(original).d_formatSpec),
allocator)
, d_recordSeparator(
MoveUtil::move(MoveUtil::access(original).d_recordSeparator),
allocator)
, d_fieldFormatters(allocator)
{
if (MoveUtil::access(original).get_allocator() == allocator) {
d_fieldFormatters = MoveUtil::move(
MoveUtil::access(original).d_fieldFormatters);
}
else {
int rc = setFormat(d_formatSpec);
(void) rc;
BSLS_ASSERT(0 == rc);
}
}
// MANIPULATORS
inline
RecordJsonFormatter& RecordJsonFormatter::operator=(
bslmf::MovableRef<RecordJsonFormatter> rhs)
{
if (this != &MoveUtil::access(rhs)) {
d_recordSeparator = MoveUtil::move(
MoveUtil::access(rhs).d_recordSeparator);
if (MoveUtil::access(rhs).get_allocator() == get_allocator()) {
releaseFieldFormatters(&d_fieldFormatters);
d_formatSpec = MoveUtil::move(
MoveUtil::access(rhs).d_formatSpec);
d_fieldFormatters = MoveUtil::move(
MoveUtil::access(rhs).d_fieldFormatters);
}
else {
int rc = setFormat(MoveUtil::access(rhs).d_formatSpec);
(void) rc;
BSLS_ASSERT(0 == rc);
}
}
return *this;
}
inline
void RecordJsonFormatter::setRecordSeparator(
const bsl::string_view& recordSeparator)
{
d_recordSeparator = recordSeparator;
}
// ACCESSORS
inline
const bsl::string& RecordJsonFormatter::format() const
{
return d_formatSpec;
}
inline
const bsl::string& RecordJsonFormatter::recordSeparator() const
{
return d_recordSeparator;
}
// Aspects
inline
bslma::Allocator *RecordJsonFormatter::allocator() const
{
return d_formatSpec.get_allocator().mechanism();
}
inline
RecordJsonFormatter::allocator_type
RecordJsonFormatter::get_allocator() const
{
return d_formatSpec.get_allocator();
}
} // close package namespace
// FREE OPERATORS
inline
bool ball::operator==(const RecordJsonFormatter& lhs,
const RecordJsonFormatter& rhs)
{
return lhs.format() == rhs.format() &&
lhs.recordSeparator() == rhs.recordSeparator();
}
inline
bool ball::operator!=(const RecordJsonFormatter& lhs,
const RecordJsonFormatter& rhs)
{
return !(lhs == rhs);
}
} // close enterprise namespace
#endif
// ----------------------------------------------------------------------------
// Copyright 2020 Bloomberg Finance L.P.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------- END-OF-FILE ----------------------------------