2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
7 * Reserved. This file contains Original Code and/or Modifications of
8 * Original Code as defined in and that are subject to the Apple Public
9 * Source License Version 1.1 (the "License"). You may not use this file
10 * except in compliance with the License. Please obtain a copy of the
11 * License at http://www.apple.com/publicsource and read it before using
14 * The Original Code and all software distributed under the License are
15 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
19 * License for the specific language governing rights and limitations
22 * @APPLE_LICENSE_HEADER_END@
26 * Copyright 1988-2001, NeXT Software, Inc., Apple Computer, Inc.
33 #include <sys/fcntl.h>
36 #import "objc-private.h"
37 static int hasTerminal()
39 static char hasTerm = -1;
42 int fd = open("/dev/tty", O_RDWR, 0);
52 void _objc_syslog(const char *format, ...)
55 char bigBuffer[4*1024];
58 vsnprintf(bigBuffer, sizeof(bigBuffer), format, ap);
63 fwrite(bigBuffer, sizeof(char), strlen(bigBuffer), stderr);
64 if (bigBuffer[strlen(bigBuffer)-1] != '\n')
67 syslog(LOG_ERR, "%s", bigBuffer);
71 * this routine handles errors that involve an object (or class).
73 volatile void __objc_error(id rcv, const char *fmt, ...)
78 (*_error)(rcv, fmt, vp);
80 _objc_error (rcv, fmt, vp); /* In case (*_error)() returns. */
84 * this routine is never called directly...it is only called indirectly
85 * through "_error", which can be overriden by an application. It is
86 * not declared static because it needs to be referenced in
87 * "objc-globaldata.m" (this file organization simplifies the shlib
88 * maintenance problem...oh well). It is, however, a "private extern".
90 volatile void _objc_error(id self, const char *fmt, va_list ap)
92 char bigBuffer[4*1024];
94 vsnprintf (bigBuffer, sizeof(bigBuffer), fmt, ap);
95 _objc_syslog ("objc: %s: %s", object_getClassName (self), bigBuffer);
97 abort(); /* generates a core file */
101 * this routine handles severe runtime errors...like not being able
102 * to read the mach headers, allocate space, etc...very uncommon.
104 volatile void _objc_fatal(const char *msg)
106 _objc_syslog("objc: %s\n", msg);
111 * this routine handles soft runtime errors...like not being able
112 * add a category to a class (because it wasn't linked in).
114 void _objc_inform(const char *fmt, ...)
117 char bigBuffer[4*1024];
120 vsnprintf (bigBuffer, sizeof(bigBuffer), fmt, ap);
121 _objc_syslog ("objc: %s", bigBuffer);