• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 The Android Open Source Project
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 #ifdef CHRE_TOKENIZED_LOGGING_ENABLED
18 #include "chre/platform/log.h"
19 #include "pw_tokenizer/encode_args.h"
20 #include "pw_tokenizer/tokenize.h"
21 
22 // The callback function that must be defined to handle an encoded
23 // tokenizer message.
24 
EncodeTokenizedMessage(uint32_t level,pw_tokenizer_Token token,pw_tokenizer_ArgTypes types,...)25 void EncodeTokenizedMessage(uint32_t level, pw_tokenizer_Token token,
26                             pw_tokenizer_ArgTypes types, ...) {
27   va_list args;
28   va_start(args, types);
29   pw::tokenizer::EncodedMessage encodedMessage(token, types, args);
30   va_end(args);
31 
32   chrePlatformEncodedLogToBuffer(static_cast<chreLogLevel>(level),
33                                  encodedMessage.data_as_uint8(),
34                                  encodedMessage.size());
35 }
36 
37 #endif  // CHRE_TOKENIZED_LOGGING_ENABLED
38