1// Copyright 2012 The Chromium Authors 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5#include "base/apple/osstatus_logging.h" 6 7#import <Foundation/Foundation.h> 8 9#include <iomanip> 10 11namespace logging { 12 13std::string DescriptionFromOSStatus(OSStatus err) { 14 NSError* error = [NSError errorWithDomain:NSOSStatusErrorDomain 15 code:err 16 userInfo:nil]; 17 return error.description.UTF8String; 18} 19 20OSStatusLogMessage::OSStatusLogMessage(const char* file_path, 21 int line, 22 LogSeverity severity, 23 OSStatus status) 24 : LogMessage(file_path, line, severity), status_(status) {} 25 26OSStatusLogMessage::~OSStatusLogMessage() { 27 stream() << ": " << DescriptionFromOSStatus(status_) << " (" << status_ 28 << ")"; 29} 30 31} // namespace logging 32