mirror of
https://github.com/gnustep/libs-back.git
synced 2025-06-01 09:42:17 +00:00
* Tools/gpbs.m: Revert last change and correct the implementation
and usage of gpbs_log. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/back/trunk@37852 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
e4dd0c00e2
commit
8feb7e4701
2 changed files with 85 additions and 2 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2014-05-07 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
|
* Tools/gpbs.m: Revert last change and correct the implementation
|
||||||
|
and usage of gpbs_log.
|
||||||
|
|
||||||
2014-05-06 Ivan Vucica <ivan@vucica.net>
|
2014-05-06 Ivan Vucica <ivan@vucica.net>
|
||||||
|
|
||||||
* Tools/gpbs.m: Removed barely used, overly complex and almost
|
* Tools/gpbs.m: Removed barely used, overly complex and almost
|
||||||
|
|
80
Tools/gpbs.m
80
Tools/gpbs.m
|
@ -54,6 +54,77 @@ static BOOL auto_stop = NO; /* Stop when all connections closed. */
|
||||||
|
|
||||||
static NSMutableArray *connections = nil;
|
static NSMutableArray *connections = nil;
|
||||||
|
|
||||||
|
#if defined(HAVE_SYSLOG) || defined(HAVE_SLOGF)
|
||||||
|
# if defined(HAVE_SLOGF)
|
||||||
|
# include <sys/slogcodes.h>
|
||||||
|
# include <sys/slog.h>
|
||||||
|
# define LOG_CRIT _SLOG_CRITICAL
|
||||||
|
# define LOG_DEBUG _SLOG_DEBUG1
|
||||||
|
# define LOG_ERR _SLOG_ERROR
|
||||||
|
# define LOG_INFO _SLOG_INFO
|
||||||
|
# define LOG_WARNING _SLOG_WARNING
|
||||||
|
# define syslog(prio, msg,...) slogf(_SLOG_SETCODE(_SLOG_SYSLOG, 0), prio, msg, __VA_ARGS__)
|
||||||
|
# endif
|
||||||
|
static int log_priority = LOG_DEBUG;
|
||||||
|
|
||||||
|
static void
|
||||||
|
gpbs_log (int prio, const char *ebuf)
|
||||||
|
{
|
||||||
|
if (is_daemon)
|
||||||
|
{
|
||||||
|
# if defined(HAVE_SLOGF)
|
||||||
|
// Let's not have 0 as the value for prio. It means "shutdown" on QNX
|
||||||
|
syslog (prio ? prio : log_priority, "%s", ebuf);
|
||||||
|
# else
|
||||||
|
syslog (log_priority | prio, "%s", ebuf);
|
||||||
|
# endif
|
||||||
|
}
|
||||||
|
else if (prio == LOG_INFO)
|
||||||
|
{
|
||||||
|
write (1, ebuf, strlen (ebuf));
|
||||||
|
write (1, "\n", 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
write (2, ebuf, strlen (ebuf));
|
||||||
|
write (2, "\n", 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (prio == LOG_CRIT)
|
||||||
|
{
|
||||||
|
if (is_daemon)
|
||||||
|
{
|
||||||
|
syslog (LOG_CRIT, "%s", "exiting.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf (stderr, "exiting.\n");
|
||||||
|
fflush (stderr);
|
||||||
|
}
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
|
||||||
|
#define LOG_CRIT 2
|
||||||
|
#define LOG_DEBUG 0
|
||||||
|
#define LOG_ERR 1
|
||||||
|
#define LOG_INFO 0
|
||||||
|
#define LOG_WARNING 0
|
||||||
|
void
|
||||||
|
gpbs_log (int prio, const char *ebuf)
|
||||||
|
{
|
||||||
|
write (2, ebuf, strlen (ebuf));
|
||||||
|
write (2, "\n", 1);
|
||||||
|
if (prio == LOG_CRIT)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "exiting.\n");
|
||||||
|
fflush (stderr);
|
||||||
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
@class PasteboardServer;
|
@class PasteboardServer;
|
||||||
@class PasteboardObject;
|
@class PasteboardObject;
|
||||||
|
|
||||||
|
@ -1056,6 +1127,7 @@ if (beenHere == YES)
|
||||||
static void
|
static void
|
||||||
init(int argc, char** argv, char **env)
|
init(int argc, char** argv, char **env)
|
||||||
{
|
{
|
||||||
|
NSUserDefaults *defs;
|
||||||
NSProcessInfo *pInfo;
|
NSProcessInfo *pInfo;
|
||||||
NSMutableArray *args;
|
NSMutableArray *args;
|
||||||
unsigned count;
|
unsigned count;
|
||||||
|
@ -1150,13 +1222,19 @@ init(int argc, char** argv, char **env)
|
||||||
}
|
}
|
||||||
NS_HANDLER
|
NS_HANDLER
|
||||||
{
|
{
|
||||||
NSLog(@"An exception has ocurred.");
|
gpbs_log(LOG_CRIT, [[localException description] UTF8String]);
|
||||||
DESTROY(t);
|
DESTROY(t);
|
||||||
}
|
}
|
||||||
NS_ENDHANDLER
|
NS_ENDHANDLER
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Make gpbs logging go to syslog unless overridden by user.
|
||||||
|
*/
|
||||||
|
defs = [NSUserDefaults standardUserDefaults];
|
||||||
|
[defs registerDefaults: [NSDictionary dictionaryWithObjectsAndKeys:
|
||||||
|
@"YES", @"GSLogSyslog", nil]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue