Files
nearby/internal/platform/implementation/apple/Log/GNCLogger.mm
T
Guogang Li d7a688f415 Create GNCLogger for apple platform
PiperOrigin-RevId: 766393388
2025-06-02 16:45:00 -07:00

48 lines
1.7 KiB
Plaintext

// Copyright 2025 Google LLC
//
// 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
//
// https://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.
#import "internal/platform/implementation/apple/Log/GNCLogger.h"
#import <Foundation/Foundation.h>
#include "internal/platform/logging.h"
NS_ASSUME_NONNULL_BEGIN
void GNCLog(const char *fileName, int lineNumber, GNCLogSeverity severity, NSString *format, ...) {
va_list arguments;
va_start(arguments, format);
NSString *messageString = [[NSString alloc] initWithFormat:format arguments:arguments];
switch (severity) {
case GNCLogSeverityDebug:
VLOG(1).AtLocation(fileName, lineNumber).WithVerbosity(1)
<< std::string([messageString UTF8String]);
break;
case GNCLogSeverityInfo:
LOG(INFO).AtLocation(fileName, lineNumber) << std::string([messageString UTF8String]);
break;
case GNCLogSeverityWarning:
LOG(WARNING).AtLocation(fileName, lineNumber) << std::string([messageString UTF8String]);
break;
case GNCLogSeverityError:
LOG(ERROR).AtLocation(fileName, lineNumber) << std::string([messageString UTF8String]);
break;
case GNCLogSeverityFatal:
LOG(FATAL).AtLocation(fileName, lineNumber) << std::string([messageString UTF8String]);
break;
}
}
NS_ASSUME_NONNULL_END