1998-06-11 01:21:14 +02:00
|
|
|
|
/* GLIB - Library of useful routines for C programming
|
|
|
|
|
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
|
|
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or
|
2000-07-26 13:02:02 +02:00
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
1998-06-11 01:21:14 +02:00
|
|
|
|
* License as published by the Free Software Foundation; either
|
2017-01-05 12:47:07 +01:00
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
1998-06-11 01:21:14 +02:00
|
|
|
|
*
|
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2000-07-26 13:02:02 +02:00
|
|
|
|
* Lesser General Public License for more details.
|
1998-06-11 01:21:14 +02:00
|
|
|
|
*
|
2000-07-26 13:02:02 +02:00
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2014-01-23 12:58:29 +01:00
|
|
|
|
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
1998-06-11 01:21:14 +02:00
|
|
|
|
*/
|
1998-11-01 05:19:54 +01:00
|
|
|
|
|
1999-02-24 07:14:27 +01:00
|
|
|
|
/*
|
2000-07-26 13:02:02 +02:00
|
|
|
|
* Modified by the GLib Team and others 1997-2000. See the AUTHORS
|
1999-02-24 07:14:27 +01:00
|
|
|
|
* file for a list of people on the GLib Team. See the ChangeLog
|
|
|
|
|
* files for a list of changes. These files are distributed with
|
2010-09-04 02:51:08 +02:00
|
|
|
|
* GLib at ftp://ftp.gtk.org/pub/gtk/.
|
1999-02-24 07:14:27 +01:00
|
|
|
|
*/
|
|
|
|
|
|
2010-09-04 02:51:08 +02:00
|
|
|
|
/*
|
1998-12-15 06:28:02 +01:00
|
|
|
|
* MT safe
|
|
|
|
|
*/
|
|
|
|
|
|
2011-07-20 02:40:28 +02:00
|
|
|
|
/**
|
2016-08-12 11:05:07 +02:00
|
|
|
|
* SECTION:messages
|
2011-07-20 02:40:28 +02:00
|
|
|
|
* @Title: Message Output and Debugging Functions
|
|
|
|
|
* @Short_description: functions to output messages and help debug applications
|
|
|
|
|
*
|
|
|
|
|
* These functions provide support for outputting messages.
|
|
|
|
|
*
|
2014-02-02 02:49:21 +01:00
|
|
|
|
* The g_return family of macros (g_return_if_fail(),
|
2014-02-01 18:19:04 +01:00
|
|
|
|
* g_return_val_if_fail(), g_return_if_reached(),
|
|
|
|
|
* g_return_val_if_reached()) should only be used for programming
|
|
|
|
|
* errors, a typical use case is checking for invalid parameters at
|
|
|
|
|
* the beginning of a public function. They should not be used if
|
|
|
|
|
* you just mean "if (error) return", they should only be used if
|
|
|
|
|
* you mean "if (bug in program) return". The program behavior is
|
|
|
|
|
* generally considered undefined after one of these checks fails.
|
|
|
|
|
* They are not intended for normal control flow, only to give a
|
|
|
|
|
* perhaps-helpful warning before giving up.
|
2016-02-20 13:34:29 +01:00
|
|
|
|
*
|
|
|
|
|
* Structured logging output is supported using g_log_structured(). This differs
|
|
|
|
|
* from the traditional g_log() API in that log messages are handled as a
|
|
|
|
|
* collection of key–value pairs representing individual pieces of information,
|
|
|
|
|
* rather than as a single string containing all the information in an arbitrary
|
|
|
|
|
* format.
|
|
|
|
|
*
|
2016-07-21 20:52:46 +02:00
|
|
|
|
* The convenience macros g_info(), g_message(), g_debug(), g_warning() and g_error()
|
|
|
|
|
* will use the traditional g_log() API unless you define the symbol
|
2016-08-12 11:53:19 +02:00
|
|
|
|
* %G_LOG_USE_STRUCTURED before including `glib.h`. But note that even messages
|
2016-07-21 20:52:46 +02:00
|
|
|
|
* logged through the traditional g_log() API are ultimatively passed to
|
|
|
|
|
* g_log_structured(), so that all log messages end up in same destination.
|
2016-08-12 11:53:19 +02:00
|
|
|
|
* If %G_LOG_USE_STRUCTURED is defined, g_test_expect_message() will become
|
|
|
|
|
* ineffective for the wrapper macros g_warning() and friends (see
|
2016-08-03 22:55:53 +02:00
|
|
|
|
* [Testing for Messages][testing-for-messages]).
|
2016-07-21 20:52:46 +02:00
|
|
|
|
*
|
2016-02-20 13:34:29 +01:00
|
|
|
|
* The support for structured logging was motivated by the following needs (some
|
|
|
|
|
* of which were supported previously; others weren’t):
|
|
|
|
|
* * Support for multiple logging levels.
|
|
|
|
|
* * Structured log support with the ability to add `MESSAGE_ID`s (see
|
|
|
|
|
* g_log_structured()).
|
|
|
|
|
* * Moving the responsibility for filtering log messages from the program to
|
|
|
|
|
* the log viewer — instead of libraries and programs installing log handlers
|
|
|
|
|
* (with g_log_set_handler()) which filter messages before output, all log
|
|
|
|
|
* messages are outputted, and the log viewer program (such as `journalctl`)
|
|
|
|
|
* must filter them. This is based on the idea that bugs are sometimes hard
|
|
|
|
|
* to reproduce, so it is better to log everything possible and then use
|
|
|
|
|
* tools to analyse the logs than it is to not be able to reproduce a bug to
|
|
|
|
|
* get additional log data. Code which uses logging in performance-critical
|
|
|
|
|
* sections should compile out the g_log_structured() calls in
|
|
|
|
|
* release builds, and compile them in in debugging builds.
|
|
|
|
|
* * A single writer function which handles all log messages in a process, from
|
|
|
|
|
* all libraries and program code; rather than multiple log handlers with
|
|
|
|
|
* poorly defined interactions between them. This allows a program to easily
|
|
|
|
|
* change its logging policy by changing the writer function, for example to
|
|
|
|
|
* log to an additional location or to change what logging output fallbacks
|
|
|
|
|
* are used. The log writer functions provided by GLib are exposed publicly
|
|
|
|
|
* so they can be used from programs’ log writers. This allows log writer
|
|
|
|
|
* policy and implementation to be kept separate.
|
|
|
|
|
* * If a library wants to add standard information to all of its log messages
|
|
|
|
|
* (such as library state) or to redact private data (such as passwords or
|
|
|
|
|
* network credentials), it should use a wrapper function around its
|
|
|
|
|
* g_log_structured() calls or implement that in the single log writer
|
|
|
|
|
* function.
|
|
|
|
|
* * If a program wants to pass context data from a g_log_structured() call to
|
|
|
|
|
* its log writer function so that, for example, it can use the correct
|
|
|
|
|
* server connection to submit logs to, that user data can be passed as a
|
|
|
|
|
* zero-length #GLogField to g_log_structured_array().
|
2016-03-15 11:47:39 +01:00
|
|
|
|
* * Color output needed to be supported on the terminal, to make reading
|
2016-02-20 13:34:29 +01:00
|
|
|
|
* through logs easier.
|
2016-08-03 22:55:53 +02:00
|
|
|
|
*
|
2017-09-13 18:07:29 +02:00
|
|
|
|
* ## Using Structured Logging ## {#using-structured-logging}
|
2016-08-12 11:53:19 +02:00
|
|
|
|
*
|
|
|
|
|
* To use structured logging (rather than the old-style logging), either use
|
|
|
|
|
* the g_log_structured() and g_log_structured_array() functions; or define
|
|
|
|
|
* `G_LOG_USE_STRUCTURED` before including any GLib header, and use the
|
|
|
|
|
* g_message(), g_debug(), g_error() (etc.) macros.
|
|
|
|
|
*
|
|
|
|
|
* You do not need to define `G_LOG_USE_STRUCTURED` to use g_log_structured(),
|
|
|
|
|
* but it is a good idea to avoid confusion.
|
|
|
|
|
*
|
2017-09-13 18:07:29 +02:00
|
|
|
|
* ## Log Domains ## {#log-domains}
|
2016-08-03 23:11:57 +02:00
|
|
|
|
*
|
|
|
|
|
* Log domains may be used to broadly split up the origins of log messages.
|
|
|
|
|
* Typically, there are one or a few log domains per application or library.
|
|
|
|
|
* %G_LOG_DOMAIN should be used to define the default log domain for the current
|
|
|
|
|
* compilation unit — it is typically defined at the top of a source file, or in
|
|
|
|
|
* the preprocessor flags for a group of source files.
|
|
|
|
|
*
|
|
|
|
|
* Log domains must be unique, and it is recommended that they are the
|
|
|
|
|
* application or library name, optionally followed by a hyphen and a sub-domain
|
|
|
|
|
* name. For example, `bloatpad` or `bloatpad-io`.
|
|
|
|
|
*
|
2017-09-13 18:07:29 +02:00
|
|
|
|
* ## Debug Message Output ## {#debug-message-output}
|
2016-08-03 23:11:57 +02:00
|
|
|
|
*
|
|
|
|
|
* The default log functions (g_log_default_handler() for the old-style API and
|
|
|
|
|
* g_log_writer_default() for the structured API) both drop debug and
|
|
|
|
|
* informational messages by default, unless the log domains of those messages
|
|
|
|
|
* are listed in the `G_MESSAGES_DEBUG` environment variable (or it is set to
|
|
|
|
|
* `all`).
|
|
|
|
|
*
|
|
|
|
|
* It is recommended that custom log writer functions re-use the
|
|
|
|
|
* `G_MESSAGES_DEBUG` environment variable, rather than inventing a custom one,
|
|
|
|
|
* so that developers can re-use the same debugging techniques and tools across
|
|
|
|
|
* projects.
|
|
|
|
|
*
|
2017-09-13 18:07:29 +02:00
|
|
|
|
* ## Testing for Messages ## {#testing-for-messages}
|
2016-08-03 22:55:53 +02:00
|
|
|
|
*
|
|
|
|
|
* With the old g_log() API, g_test_expect_message() and
|
|
|
|
|
* g_test_assert_expected_messages() could be used in simple cases to check
|
|
|
|
|
* whether some code under test had emitted a given log message. These
|
|
|
|
|
* functions have been deprecated with the structured logging API, for several
|
|
|
|
|
* reasons:
|
|
|
|
|
* * They relied on an internal queue which was too inflexible for many use
|
|
|
|
|
* cases, where messages might be emitted in several orders, some
|
|
|
|
|
* messages might not be emitted deterministically, or messages might be
|
|
|
|
|
* emitted by unrelated log domains.
|
|
|
|
|
* * They do not support structured log fields.
|
|
|
|
|
* * Examining the log output of code is a bad approach to testing it, and
|
|
|
|
|
* while it might be necessary for legacy code which uses g_log(), it should
|
|
|
|
|
* be avoided for new code using g_log_structured().
|
|
|
|
|
*
|
|
|
|
|
* They will continue to work as before if g_log() is in use (and
|
|
|
|
|
* %G_LOG_USE_STRUCTURED is not defined). They will do nothing if used with the
|
|
|
|
|
* structured logging API.
|
|
|
|
|
*
|
|
|
|
|
* Examining the log output of code is discouraged: libraries should not emit to
|
|
|
|
|
* `stderr` during defined behaviour, and hence this should not be tested. If
|
|
|
|
|
* the log emissions of a library during undefined behaviour need to be tested,
|
|
|
|
|
* they should be limited to asserting that the library aborts and prints a
|
|
|
|
|
* suitable error message before aborting. This should be done with
|
|
|
|
|
* g_test_trap_assert_stderr().
|
|
|
|
|
*
|
|
|
|
|
* If it is really necessary to test the structured log messages emitted by a
|
|
|
|
|
* particular piece of code – and the code cannot be restructured to be more
|
|
|
|
|
* suitable to more conventional unit testing – you should write a custom log
|
|
|
|
|
* writer function (see g_log_set_writer_func()) which appends all log messages
|
|
|
|
|
* to a queue. When you want to check the log messages, examine and clear the
|
|
|
|
|
* queue, ignoring irrelevant log messages (for example, from log domains other
|
|
|
|
|
* than the one under test).
|
2011-07-20 02:40:28 +02:00
|
|
|
|
*/
|
|
|
|
|
|
2002-12-04 02:27:44 +01:00
|
|
|
|
#include "config.h"
|
1998-11-01 05:19:54 +01:00
|
|
|
|
|
1998-09-07 11:43:54 +02:00
|
|
|
|
#include <stdlib.h>
|
1998-06-11 01:21:14 +02:00
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <string.h>
|
1999-09-14 00:17:27 +02:00
|
|
|
|
#include <signal.h>
|
1999-10-12 14:08:13 +02:00
|
|
|
|
#include <locale.h>
|
|
|
|
|
#include <errno.h>
|
2016-07-26 06:32:42 +02:00
|
|
|
|
|
2016-12-05 11:10:48 +01:00
|
|
|
|
#if defined(__linux__) && !defined(__BIONIC__)
|
2016-07-21 01:27:17 +02:00
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
#include <sys/socket.h>
|
|
|
|
|
#include <sys/un.h>
|
2016-07-23 04:56:26 +02:00
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
#include <sys/uio.h>
|
2016-07-26 06:32:42 +02:00
|
|
|
|
#endif
|
2002-12-04 02:27:44 +01:00
|
|
|
|
|
2011-10-17 00:43:22 +02:00
|
|
|
|
#include "glib-init.h"
|
2016-02-20 13:34:29 +01:00
|
|
|
|
#include "galloca.h"
|
2010-09-04 02:51:08 +02:00
|
|
|
|
#include "gbacktrace.h"
|
2011-10-17 00:43:22 +02:00
|
|
|
|
#include "gcharset.h"
|
2010-09-04 02:51:08 +02:00
|
|
|
|
#include "gconvert.h"
|
2011-11-03 06:48:54 +01:00
|
|
|
|
#include "genviron.h"
|
2016-08-13 17:34:58 +02:00
|
|
|
|
#include "gmain.h"
|
2010-09-04 02:51:08 +02:00
|
|
|
|
#include "gmem.h"
|
|
|
|
|
#include "gprintfint.h"
|
|
|
|
|
#include "gtestutils.h"
|
|
|
|
|
#include "gthread.h"
|
|
|
|
|
#include "gstrfuncs.h"
|
|
|
|
|
#include "gstring.h"
|
2012-07-30 22:05:08 +02:00
|
|
|
|
#include "gpattern.h"
|
2010-09-04 02:51:08 +02:00
|
|
|
|
|
Replace #ifdef HAVE_UNISTD_H checks with #ifdef G_OS_UNIX
In Windows development environments that have it, <unistd.h> is mostly
just a wrapper around several other native headers (in particular,
<io.h>, which contains read(), close(), etc, and <process.h>, which
contains getpid()). But given that some Windows dev environments don't
have <unistd.h>, everything that uses those functions on Windows
already needed to include the correct Windows header as well, and so
there is never any point to including <unistd.h> on Windows.
Also, remove some <unistd.h> includes (and a few others) that were
unnecessary even on unix.
https://bugzilla.gnome.org/show_bug.cgi?id=710519
2013-10-19 19:04:00 +02:00
|
|
|
|
#ifdef G_OS_UNIX
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
2010-11-09 02:53:12 +01:00
|
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
|
#include <process.h> /* For getpid() */
|
|
|
|
|
#include <io.h>
|
|
|
|
|
# include <windows.h>
|
2016-12-02 06:45:38 +01:00
|
|
|
|
|
|
|
|
|
#ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING
|
|
|
|
|
#define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004
|
|
|
|
|
#endif
|
|
|
|
|
|
2016-12-07 12:32:54 +01:00
|
|
|
|
/* XXX: Remove once XP support really dropped */
|
|
|
|
|
#if _WIN32_WINNT < 0x0600
|
|
|
|
|
|
|
|
|
|
typedef enum _FILE_INFO_BY_HANDLE_CLASS
|
|
|
|
|
{
|
|
|
|
|
FileBasicInfo = 0,
|
|
|
|
|
FileStandardInfo = 1,
|
|
|
|
|
FileNameInfo = 2,
|
|
|
|
|
FileRenameInfo = 3,
|
|
|
|
|
FileDispositionInfo = 4,
|
|
|
|
|
FileAllocationInfo = 5,
|
|
|
|
|
FileEndOfFileInfo = 6,
|
|
|
|
|
FileStreamInfo = 7,
|
|
|
|
|
FileCompressionInfo = 8,
|
|
|
|
|
FileAttributeTagInfo = 9,
|
|
|
|
|
FileIdBothDirectoryInfo = 10,
|
|
|
|
|
FileIdBothDirectoryRestartInfo = 11,
|
|
|
|
|
FileIoPriorityHintInfo = 12,
|
|
|
|
|
FileRemoteProtocolInfo = 13,
|
|
|
|
|
FileFullDirectoryInfo = 14,
|
|
|
|
|
FileFullDirectoryRestartInfo = 15,
|
|
|
|
|
FileStorageInfo = 16,
|
|
|
|
|
FileAlignmentInfo = 17,
|
|
|
|
|
FileIdInfo = 18,
|
|
|
|
|
FileIdExtdDirectoryInfo = 19,
|
|
|
|
|
FileIdExtdDirectoryRestartInfo = 20,
|
|
|
|
|
MaximumFileInfoByHandlesClass
|
|
|
|
|
} FILE_INFO_BY_HANDLE_CLASS;
|
|
|
|
|
|
|
|
|
|
typedef struct _FILE_NAME_INFO
|
|
|
|
|
{
|
|
|
|
|
DWORD FileNameLength;
|
|
|
|
|
WCHAR FileName[1];
|
|
|
|
|
} FILE_NAME_INFO;
|
|
|
|
|
|
|
|
|
|
typedef BOOL (WINAPI fGetFileInformationByHandleEx) (HANDLE,
|
|
|
|
|
FILE_INFO_BY_HANDLE_CLASS,
|
|
|
|
|
LPVOID,
|
|
|
|
|
DWORD);
|
|
|
|
|
#endif
|
|
|
|
|
|
2016-12-02 06:45:38 +01:00
|
|
|
|
#if defined (_MSC_VER) && (_MSC_VER >=1400)
|
|
|
|
|
/* This is ugly, but we need it for isatty() in case we have bad fd's,
|
|
|
|
|
* otherwise Windows will abort() the program on msvcrt80.dll and later
|
|
|
|
|
*/
|
|
|
|
|
#include <crtdbg.h>
|
|
|
|
|
|
|
|
|
|
_GLIB_EXTERN void
|
|
|
|
|
myInvalidParameterHandler(const wchar_t *expression,
|
|
|
|
|
const wchar_t *function,
|
|
|
|
|
const wchar_t *file,
|
|
|
|
|
unsigned int line,
|
|
|
|
|
uintptr_t pReserved)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include "gwin32.h"
|
2010-11-09 02:53:12 +01:00
|
|
|
|
#endif
|
|
|
|
|
|
2011-10-13 04:29:18 +02:00
|
|
|
|
/**
|
|
|
|
|
* G_LOG_DOMAIN:
|
|
|
|
|
*
|
2017-01-30 23:50:00 +01:00
|
|
|
|
* Defines the log domain. See [Log Domains](#log-domains).
|
2011-10-13 04:29:18 +02:00
|
|
|
|
*
|
2017-07-20 18:57:01 +02:00
|
|
|
|
* Libraries should define this so that any messages
|
2011-10-13 04:29:18 +02:00
|
|
|
|
* which they log can be differentiated from messages from other
|
|
|
|
|
* libraries and application code. But be careful not to define
|
|
|
|
|
* it in any public header files.
|
|
|
|
|
*
|
2017-01-30 23:50:00 +01:00
|
|
|
|
* Log domains must be unique, and it is recommended that they are the
|
|
|
|
|
* application or library name, optionally followed by a hyphen and a sub-domain
|
|
|
|
|
* name. For example, `bloatpad` or `bloatpad-io`.
|
|
|
|
|
*
|
|
|
|
|
* If undefined, it defaults to the default %NULL (or `""`) log domain; this is
|
|
|
|
|
* not advisable, as it cannot be filtered against using the `G_MESSAGES_DEBUG`
|
|
|
|
|
* environment variable.
|
|
|
|
|
*
|
|
|
|
|
* For example, GTK+ uses this in its `Makefile.am`:
|
2011-10-13 04:29:18 +02:00
|
|
|
|
* |[
|
2015-05-13 16:22:57 +02:00
|
|
|
|
* AM_CPPFLAGS = -DG_LOG_DOMAIN=\"Gtk\"
|
2011-10-13 04:29:18 +02:00
|
|
|
|
* ]|
|
2017-07-20 18:57:01 +02:00
|
|
|
|
*
|
2017-01-30 23:50:00 +01:00
|
|
|
|
* Applications can choose to leave it as the default %NULL (or `""`)
|
2017-07-20 18:57:01 +02:00
|
|
|
|
* domain. However, defining the domain offers the same advantages as
|
|
|
|
|
* above.
|
|
|
|
|
*
|
|
|
|
|
|
2011-10-13 04:29:18 +02:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* G_LOG_FATAL_MASK:
|
|
|
|
|
*
|
|
|
|
|
* GLib log levels that are considered fatal by default.
|
2016-08-12 11:53:19 +02:00
|
|
|
|
*
|
|
|
|
|
* This is not used if structured logging is enabled; see
|
|
|
|
|
* [Using Structured Logging][using-structured-logging].
|
2011-10-13 04:29:18 +02:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GLogFunc:
|
|
|
|
|
* @log_domain: the log domain of the message
|
|
|
|
|
* @log_level: the log level of the message (including the
|
|
|
|
|
* fatal and recursion flags)
|
|
|
|
|
* @message: the message to process
|
|
|
|
|
* @user_data: user data, set in g_log_set_handler()
|
|
|
|
|
*
|
|
|
|
|
* Specifies the prototype of log handler functions.
|
2013-10-21 16:09:13 +02:00
|
|
|
|
*
|
|
|
|
|
* The default log handler, g_log_default_handler(), automatically appends a
|
|
|
|
|
* new-line character to @message when printing it. It is advised that any
|
|
|
|
|
* custom log handler functions behave similarly, so that logging calls in user
|
|
|
|
|
* code do not need modifying to add a new-line character to the message if the
|
|
|
|
|
* log handler is changed.
|
2016-08-12 11:53:19 +02:00
|
|
|
|
*
|
|
|
|
|
* This is not used if structured logging is enabled; see
|
|
|
|
|
* [Using Structured Logging][using-structured-logging].
|
2011-10-13 04:29:18 +02:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GLogLevelFlags:
|
|
|
|
|
* @G_LOG_FLAG_RECURSION: internal flag
|
|
|
|
|
* @G_LOG_FLAG_FATAL: internal flag
|
|
|
|
|
* @G_LOG_LEVEL_ERROR: log level for errors, see g_error().
|
|
|
|
|
* This level is also used for messages produced by g_assert().
|
2016-03-15 13:28:10 +01:00
|
|
|
|
* @G_LOG_LEVEL_CRITICAL: log level for critical warning messages, see
|
|
|
|
|
* g_critical().
|
2011-10-13 04:29:18 +02:00
|
|
|
|
* This level is also used for messages produced by g_return_if_fail()
|
|
|
|
|
* and g_return_val_if_fail().
|
|
|
|
|
* @G_LOG_LEVEL_WARNING: log level for warnings, see g_warning()
|
|
|
|
|
* @G_LOG_LEVEL_MESSAGE: log level for messages, see g_message()
|
2013-10-29 21:30:06 +01:00
|
|
|
|
* @G_LOG_LEVEL_INFO: log level for informational messages, see g_info()
|
2011-10-13 04:29:18 +02:00
|
|
|
|
* @G_LOG_LEVEL_DEBUG: log level for debug messages, see g_debug()
|
|
|
|
|
* @G_LOG_LEVEL_MASK: a mask including all log levels
|
|
|
|
|
*
|
|
|
|
|
* Flags specifying the level of log messages.
|
|
|
|
|
*
|
|
|
|
|
* It is possible to change how GLib treats messages of the various
|
|
|
|
|
* levels using g_log_set_handler() and g_log_set_fatal_mask().
|
|
|
|
|
*/
|
|
|
|
|
|
2014-05-31 15:04:11 +02:00
|
|
|
|
/**
|
|
|
|
|
* G_LOG_LEVEL_USER_SHIFT:
|
|
|
|
|
*
|
|
|
|
|
* Log levels below 1<<G_LOG_LEVEL_USER_SHIFT are used by GLib.
|
|
|
|
|
* Higher bits can be used for user-defined log levels.
|
|
|
|
|
*/
|
|
|
|
|
|
2011-10-13 04:29:18 +02:00
|
|
|
|
/**
|
|
|
|
|
* g_message:
|
|
|
|
|
* @...: format string, followed by parameters to insert
|
|
|
|
|
* into the format string (as with printf())
|
|
|
|
|
*
|
|
|
|
|
* A convenience function/macro to log a normal message.
|
2013-10-21 16:09:13 +02:00
|
|
|
|
*
|
|
|
|
|
* If g_log_default_handler() is used as the log handler function, a new-line
|
|
|
|
|
* character will automatically be appended to @..., and need not be entered
|
|
|
|
|
* manually.
|
2016-08-12 11:53:19 +02:00
|
|
|
|
*
|
|
|
|
|
* If structured logging is enabled, this will use g_log_structured();
|
|
|
|
|
* otherwise it will use g_log(). See
|
|
|
|
|
* [Using Structured Logging][using-structured-logging].
|
2011-10-13 04:29:18 +02:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* g_warning:
|
|
|
|
|
* @...: format string, followed by parameters to insert
|
|
|
|
|
* into the format string (as with printf())
|
|
|
|
|
*
|
2012-07-05 21:32:19 +02:00
|
|
|
|
* A convenience function/macro to log a warning message. The message should
|
|
|
|
|
* typically *not* be translated to the user's language.
|
2011-10-13 04:29:18 +02:00
|
|
|
|
*
|
2014-12-19 16:27:03 +01:00
|
|
|
|
* This is not intended for end user error reporting. Use of #GError is
|
|
|
|
|
* preferred for that instead, as it allows calling functions to perform actions
|
|
|
|
|
* conditional on the type of error.
|
|
|
|
|
*
|
2014-02-06 01:32:41 +01:00
|
|
|
|
* You can make warnings fatal at runtime by setting the `G_DEBUG`
|
2014-02-06 03:23:28 +01:00
|
|
|
|
* environment variable (see
|
2017-11-10 11:26:01 +01:00
|
|
|
|
* [Running GLib Applications](glib-running.html)):
|
|
|
|
|
*
|
|
|
|
|
* |[
|
|
|
|
|
* G_DEBUG=fatal-warnings gdb ./my-program
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* Any unrelated failures can be skipped over in
|
|
|
|
|
* [gdb](https://www.gnu.org/software/gdb/) using the `continue` command.
|
2013-10-21 16:09:13 +02:00
|
|
|
|
*
|
2014-02-06 01:32:41 +01:00
|
|
|
|
* If g_log_default_handler() is used as the log handler function,
|
|
|
|
|
* a newline character will automatically be appended to @..., and
|
|
|
|
|
* need not be entered manually.
|
2016-08-12 11:53:19 +02:00
|
|
|
|
*
|
|
|
|
|
* If structured logging is enabled, this will use g_log_structured();
|
|
|
|
|
* otherwise it will use g_log(). See
|
|
|
|
|
* [Using Structured Logging][using-structured-logging].
|
2011-10-13 04:29:18 +02:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* g_critical:
|
|
|
|
|
* @...: format string, followed by parameters to insert
|
|
|
|
|
* into the format string (as with printf())
|
|
|
|
|
*
|
|
|
|
|
* Logs a "critical warning" (#G_LOG_LEVEL_CRITICAL).
|
|
|
|
|
* It's more or less application-defined what constitutes
|
|
|
|
|
* a critical vs. a regular warning. You could call
|
|
|
|
|
* g_log_set_always_fatal() to make critical warnings exit
|
|
|
|
|
* the program, then use g_critical() for fatal errors, for
|
|
|
|
|
* example.
|
|
|
|
|
*
|
|
|
|
|
* You can also make critical warnings fatal at runtime by
|
2014-02-06 01:32:41 +01:00
|
|
|
|
* setting the `G_DEBUG` environment variable (see
|
2017-11-10 11:26:01 +01:00
|
|
|
|
* [Running GLib Applications](glib-running.html)):
|
|
|
|
|
*
|
|
|
|
|
* |[
|
|
|
|
|
* G_DEBUG=fatal-warnings gdb ./my-program
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* Any unrelated failures can be skipped over in
|
|
|
|
|
* [gdb](https://www.gnu.org/software/gdb/) using the `continue` command.
|
2013-10-21 16:09:13 +02:00
|
|
|
|
*
|
2012-07-05 21:32:19 +02:00
|
|
|
|
* The message should typically *not* be translated to the
|
|
|
|
|
* user's language.
|
|
|
|
|
*
|
2013-10-21 16:09:13 +02:00
|
|
|
|
* If g_log_default_handler() is used as the log handler function, a new-line
|
|
|
|
|
* character will automatically be appended to @..., and need not be entered
|
|
|
|
|
* manually.
|
2016-08-12 11:53:19 +02:00
|
|
|
|
*
|
|
|
|
|
* If structured logging is enabled, this will use g_log_structured();
|
|
|
|
|
* otherwise it will use g_log(). See
|
|
|
|
|
* [Using Structured Logging][using-structured-logging].
|
2011-10-13 04:29:18 +02:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* g_error:
|
|
|
|
|
* @...: format string, followed by parameters to insert
|
|
|
|
|
* into the format string (as with printf())
|
|
|
|
|
*
|
2012-07-05 21:32:19 +02:00
|
|
|
|
* A convenience function/macro to log an error message. The message should
|
|
|
|
|
* typically *not* be translated to the user's language.
|
2011-10-13 04:29:18 +02:00
|
|
|
|
*
|
2014-12-19 16:27:03 +01:00
|
|
|
|
* This is not intended for end user error reporting. Use of #GError is
|
|
|
|
|
* preferred for that instead, as it allows calling functions to perform actions
|
|
|
|
|
* conditional on the type of error.
|
|
|
|
|
*
|
2011-10-13 04:29:18 +02:00
|
|
|
|
* Error messages are always fatal, resulting in a call to
|
|
|
|
|
* abort() to terminate the application. This function will
|
|
|
|
|
* result in a core dump; don't use it for errors you expect.
|
|
|
|
|
* Using this function indicates a bug in your program, i.e.
|
|
|
|
|
* an assertion failure.
|
|
|
|
|
*
|
2013-10-21 16:09:13 +02:00
|
|
|
|
* If g_log_default_handler() is used as the log handler function, a new-line
|
|
|
|
|
* character will automatically be appended to @..., and need not be entered
|
|
|
|
|
* manually.
|
|
|
|
|
*
|
2016-08-12 11:53:19 +02:00
|
|
|
|
* If structured logging is enabled, this will use g_log_structured();
|
|
|
|
|
* otherwise it will use g_log(). See
|
|
|
|
|
* [Using Structured Logging][using-structured-logging].
|
2011-10-13 04:29:18 +02:00
|
|
|
|
*/
|
|
|
|
|
|
2013-10-29 21:30:06 +01:00
|
|
|
|
/**
|
|
|
|
|
* g_info:
|
|
|
|
|
* @...: format string, followed by parameters to insert
|
|
|
|
|
* into the format string (as with printf())
|
|
|
|
|
*
|
|
|
|
|
* A convenience function/macro to log an informational message. Seldom used.
|
|
|
|
|
*
|
|
|
|
|
* If g_log_default_handler() is used as the log handler function, a new-line
|
|
|
|
|
* character will automatically be appended to @..., and need not be entered
|
|
|
|
|
* manually.
|
|
|
|
|
*
|
2016-08-03 23:11:57 +02:00
|
|
|
|
* Such messages are suppressed by the g_log_default_handler() and
|
|
|
|
|
* g_log_writer_default() unless the `G_MESSAGES_DEBUG` environment variable is
|
|
|
|
|
* set appropriately.
|
2013-10-29 21:30:06 +01:00
|
|
|
|
*
|
2016-08-12 11:53:19 +02:00
|
|
|
|
* If structured logging is enabled, this will use g_log_structured();
|
|
|
|
|
* otherwise it will use g_log(). See
|
|
|
|
|
* [Using Structured Logging][using-structured-logging].
|
|
|
|
|
*
|
2013-10-29 21:30:06 +01:00
|
|
|
|
* Since: 2.40
|
|
|
|
|
*/
|
|
|
|
|
|
2011-10-13 04:29:18 +02:00
|
|
|
|
/**
|
|
|
|
|
* g_debug:
|
|
|
|
|
* @...: format string, followed by parameters to insert
|
|
|
|
|
* into the format string (as with printf())
|
|
|
|
|
*
|
2012-07-05 21:32:19 +02:00
|
|
|
|
* A convenience function/macro to log a debug message. The message should
|
|
|
|
|
* typically *not* be translated to the user's language.
|
2011-10-13 04:29:18 +02:00
|
|
|
|
*
|
2013-10-21 16:09:13 +02:00
|
|
|
|
* If g_log_default_handler() is used as the log handler function, a new-line
|
|
|
|
|
* character will automatically be appended to @..., and need not be entered
|
|
|
|
|
* manually.
|
|
|
|
|
*
|
2016-08-03 23:11:57 +02:00
|
|
|
|
* Such messages are suppressed by the g_log_default_handler() and
|
|
|
|
|
* g_log_writer_default() unless the `G_MESSAGES_DEBUG` environment variable is
|
|
|
|
|
* set appropriately.
|
2013-10-29 21:30:06 +01:00
|
|
|
|
*
|
2016-08-12 11:53:19 +02:00
|
|
|
|
* If structured logging is enabled, this will use g_log_structured();
|
|
|
|
|
* otherwise it will use g_log(). See
|
|
|
|
|
* [Using Structured Logging][using-structured-logging].
|
|
|
|
|
*
|
2011-10-13 04:29:18 +02:00
|
|
|
|
* Since: 2.6
|
|
|
|
|
*/
|
|
|
|
|
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
/* --- structures --- */
|
|
|
|
|
typedef struct _GLogDomain GLogDomain;
|
|
|
|
|
typedef struct _GLogHandler GLogHandler;
|
|
|
|
|
struct _GLogDomain
|
1998-06-11 01:21:14 +02:00
|
|
|
|
{
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
gchar *log_domain;
|
|
|
|
|
GLogLevelFlags fatal_mask;
|
|
|
|
|
GLogHandler *handlers;
|
|
|
|
|
GLogDomain *next;
|
|
|
|
|
};
|
|
|
|
|
struct _GLogHandler
|
|
|
|
|
{
|
|
|
|
|
guint id;
|
|
|
|
|
GLogLevelFlags log_level;
|
|
|
|
|
GLogFunc log_func;
|
|
|
|
|
gpointer data;
|
2014-11-29 05:31:00 +01:00
|
|
|
|
GDestroyNotify destroy;
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
GLogHandler *next;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* --- variables --- */
|
2011-10-03 02:51:38 +02:00
|
|
|
|
static GMutex g_messages_lock;
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
static GLogDomain *g_log_domains = NULL;
|
|
|
|
|
static GPrintFunc glib_print_func = NULL;
|
|
|
|
|
static GPrintFunc glib_printerr_func = NULL;
|
2011-09-18 07:10:07 +02:00
|
|
|
|
static GPrivate g_log_depth;
|
2016-02-20 13:34:29 +01:00
|
|
|
|
static GPrivate g_log_structured_depth;
|
2004-09-05 07:46:33 +02:00
|
|
|
|
static GLogFunc default_log_func = g_log_default_handler;
|
|
|
|
|
static gpointer default_log_data = NULL;
|
2009-09-10 16:40:11 +02:00
|
|
|
|
static GTestLogFatalFunc fatal_log_func = NULL;
|
|
|
|
|
static gpointer fatal_log_data;
|
2016-02-20 13:34:29 +01:00
|
|
|
|
static GLogWriterFunc log_writer_func = g_log_writer_default;
|
|
|
|
|
static gpointer log_writer_user_data = NULL;
|
|
|
|
|
static GDestroyNotify log_writer_user_data_free = NULL;
|
1998-12-15 06:28:02 +01:00
|
|
|
|
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
/* --- functions --- */
|
2013-05-20 15:31:48 +02:00
|
|
|
|
|
2013-12-03 15:35:50 +01:00
|
|
|
|
static void _g_log_abort (gboolean breakpoint);
|
2013-11-23 18:06:05 +01:00
|
|
|
|
|
|
|
|
|
static void
|
2013-11-27 16:15:44 +01:00
|
|
|
|
_g_log_abort (gboolean breakpoint)
|
2013-05-20 15:31:48 +02:00
|
|
|
|
{
|
2016-03-15 13:28:37 +01:00
|
|
|
|
gboolean debugger_present;
|
|
|
|
|
|
2013-11-23 18:06:05 +01:00
|
|
|
|
if (g_test_subprocess ())
|
|
|
|
|
{
|
|
|
|
|
/* If this is a test case subprocess then it probably caused
|
|
|
|
|
* this error message on purpose, so just exit() rather than
|
|
|
|
|
* abort()ing, to avoid triggering any system crash-reporting
|
|
|
|
|
* daemon.
|
|
|
|
|
*/
|
|
|
|
|
_exit (1);
|
|
|
|
|
}
|
2013-11-27 16:15:44 +01:00
|
|
|
|
|
2016-03-15 13:28:37 +01:00
|
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
|
debugger_present = IsDebuggerPresent ();
|
|
|
|
|
#else
|
|
|
|
|
/* Assume GDB is attached. */
|
|
|
|
|
debugger_present = TRUE;
|
|
|
|
|
#endif /* !G_OS_WIN32 */
|
|
|
|
|
|
|
|
|
|
if (debugger_present && breakpoint)
|
2013-11-27 16:15:44 +01:00
|
|
|
|
G_BREAKPOINT ();
|
2013-12-03 15:35:50 +01:00
|
|
|
|
else
|
2016-03-30 16:01:30 +02:00
|
|
|
|
g_abort ();
|
2013-05-20 15:31:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
1999-10-12 14:08:13 +02:00
|
|
|
|
#ifdef G_OS_WIN32
|
2002-03-27 18:57:30 +01:00
|
|
|
|
static gboolean win32_keep_fatal_message = FALSE;
|
2000-12-25 23:07:01 +01:00
|
|
|
|
|
|
|
|
|
/* This default message will usually be overwritten. */
|
2004-09-22 23:15:35 +02:00
|
|
|
|
/* Yes, a fixed size buffer is bad. So sue me. But g_error() is never
|
|
|
|
|
* called with huge strings, is it?
|
2002-03-27 18:57:30 +01:00
|
|
|
|
*/
|
|
|
|
|
static gchar fatal_msg_buf[1000] = "Unspecified fatal error encountered, aborting.";
|
|
|
|
|
static gchar *fatal_msg_ptr = fatal_msg_buf;
|
2000-12-25 23:07:01 +01:00
|
|
|
|
|
1999-10-12 14:08:13 +02:00
|
|
|
|
#undef write
|
|
|
|
|
static inline int
|
2004-09-22 23:15:35 +02:00
|
|
|
|
dowrite (int fd,
|
Warn if no callback. Call callback correctly. (g_io_win32_create_watch):
2000-12-14 Tor Lillqvist <tml@iki.fi>
* giowin32.c (g_io_win32_dispatch): Warn if no callback. Call
callback correctly.
(g_io_win32_create_watch): Fix typo.
(g_io_win32_fd_create_watch): Ditto.
(g_io_channel_unix_new): If it is a file descriptor (i.e., a Unix
fd lookalike provided by the C library), call
g_io_channel_win32_new_fd(). If it is a socket (from WinSock),
call g_io_cahnnel_win32_new_stream_socket(). Hopefully sockets and
fds don't overlap. TODO: Implement also datagram sockets.
(g_io_channel_win32_poll): Call g_main_context_get_poll_func().
* gcompletion.h: Include <unistd.h> only on Unix. Is this
inclusion really needed here? OTOH, do include <stddef.h>, for
size_t.
* gmessages.c: (Win32) Don't define a function called "write" that
might clash with the prototype from <io.h>, use a #define.
* glib.def: Update.
* gmain.c (g_source_add_poll): Don't return a value from void
function.
(g_main_context_get_poll_func): Compile also for non-Win32, as
presumably was intended. The result var is a GPollFunc, not a
GPollFunc*. Return the result!
gobject:
2000-12-14 Tor Lillqvist <tml@iki.fi>
* makefile.mingw.in: Update, include parts from Makefile.am to
build gmarshal.[ch]. Some day, we won't need these separate
makefiles for Win32 compilation. I hope.
* makefile.msc.in: Update. No use trying to build gmarshal.[ch]
here, it would require Unixish tools. MSVC users building from CVS
sources are out of luck.
* gobject.def: Update.
2000-12-14 22:02:20 +01:00
|
|
|
|
const void *buf,
|
|
|
|
|
unsigned int len)
|
1999-10-12 14:08:13 +02:00
|
|
|
|
{
|
2002-03-27 18:57:30 +01:00
|
|
|
|
if (win32_keep_fatal_message)
|
2000-12-25 23:07:01 +01:00
|
|
|
|
{
|
|
|
|
|
memcpy (fatal_msg_ptr, buf, len);
|
|
|
|
|
fatal_msg_ptr += len;
|
|
|
|
|
*fatal_msg_ptr = 0;
|
|
|
|
|
return len;
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-22 23:15:35 +02:00
|
|
|
|
write (fd, buf, len);
|
1999-10-12 14:08:13 +02:00
|
|
|
|
|
|
|
|
|
return len;
|
|
|
|
|
}
|
Warn if no callback. Call callback correctly. (g_io_win32_create_watch):
2000-12-14 Tor Lillqvist <tml@iki.fi>
* giowin32.c (g_io_win32_dispatch): Warn if no callback. Call
callback correctly.
(g_io_win32_create_watch): Fix typo.
(g_io_win32_fd_create_watch): Ditto.
(g_io_channel_unix_new): If it is a file descriptor (i.e., a Unix
fd lookalike provided by the C library), call
g_io_channel_win32_new_fd(). If it is a socket (from WinSock),
call g_io_cahnnel_win32_new_stream_socket(). Hopefully sockets and
fds don't overlap. TODO: Implement also datagram sockets.
(g_io_channel_win32_poll): Call g_main_context_get_poll_func().
* gcompletion.h: Include <unistd.h> only on Unix. Is this
inclusion really needed here? OTOH, do include <stddef.h>, for
size_t.
* gmessages.c: (Win32) Don't define a function called "write" that
might clash with the prototype from <io.h>, use a #define.
* glib.def: Update.
* gmain.c (g_source_add_poll): Don't return a value from void
function.
(g_main_context_get_poll_func): Compile also for non-Win32, as
presumably was intended. The result var is a GPollFunc, not a
GPollFunc*. Return the result!
gobject:
2000-12-14 Tor Lillqvist <tml@iki.fi>
* makefile.mingw.in: Update, include parts from Makefile.am to
build gmarshal.[ch]. Some day, we won't need these separate
makefiles for Win32 compilation. I hope.
* makefile.msc.in: Update. No use trying to build gmarshal.[ch]
here, it would require Unixish tools. MSVC users building from CVS
sources are out of luck.
* gobject.def: Update.
2000-12-14 22:02:20 +01:00
|
|
|
|
#define write(fd, buf, len) dowrite(fd, buf, len)
|
|
|
|
|
|
1999-10-12 14:08:13 +02:00
|
|
|
|
#endif
|
2001-05-09 18:36:17 +02:00
|
|
|
|
|
2001-05-14 16:53:59 +02:00
|
|
|
|
static void
|
2015-04-09 18:05:18 +02:00
|
|
|
|
write_string (FILE *stream,
|
2004-09-22 23:15:35 +02:00
|
|
|
|
const gchar *string)
|
2001-05-14 16:53:59 +02:00
|
|
|
|
{
|
2015-04-09 18:05:18 +02:00
|
|
|
|
fputs (string, stream);
|
2001-05-14 16:53:59 +02:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-20 13:34:29 +01:00
|
|
|
|
static void
|
|
|
|
|
write_string_sized (FILE *stream,
|
|
|
|
|
const gchar *string,
|
|
|
|
|
gssize length)
|
|
|
|
|
{
|
|
|
|
|
/* Is it nul-terminated? */
|
|
|
|
|
if (length < 0)
|
|
|
|
|
write_string (stream, string);
|
|
|
|
|
else
|
|
|
|
|
fwrite (string, 1, length, stream);
|
|
|
|
|
}
|
|
|
|
|
|
2002-03-27 18:57:30 +01:00
|
|
|
|
static GLogDomain*
|
|
|
|
|
g_log_find_domain_L (const gchar *log_domain)
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
{
|
2014-05-25 12:18:14 +02:00
|
|
|
|
GLogDomain *domain;
|
1998-12-15 06:28:02 +01:00
|
|
|
|
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
domain = g_log_domains;
|
|
|
|
|
while (domain)
|
1998-06-11 01:21:14 +02:00
|
|
|
|
{
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
if (strcmp (domain->log_domain, log_domain) == 0)
|
2002-03-14 17:20:42 +01:00
|
|
|
|
return domain;
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
domain = domain->next;
|
1998-06-11 01:21:14 +02:00
|
|
|
|
}
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2002-03-27 18:57:30 +01:00
|
|
|
|
static GLogDomain*
|
|
|
|
|
g_log_domain_new_L (const gchar *log_domain)
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
{
|
2014-05-25 12:18:14 +02:00
|
|
|
|
GLogDomain *domain;
|
1998-08-17 02:00:51 +02:00
|
|
|
|
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
domain = g_new (GLogDomain, 1);
|
|
|
|
|
domain->log_domain = g_strdup (log_domain);
|
|
|
|
|
domain->fatal_mask = G_LOG_FATAL_MASK;
|
|
|
|
|
domain->handlers = NULL;
|
1998-12-15 06:28:02 +01:00
|
|
|
|
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
domain->next = g_log_domains;
|
|
|
|
|
g_log_domains = domain;
|
|
|
|
|
|
|
|
|
|
return domain;
|
|
|
|
|
}
|
1998-06-11 01:21:14 +02:00
|
|
|
|
|
2002-03-27 18:57:30 +01:00
|
|
|
|
static void
|
|
|
|
|
g_log_domain_check_free_L (GLogDomain *domain)
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
{
|
|
|
|
|
if (domain->fatal_mask == G_LOG_FATAL_MASK &&
|
|
|
|
|
domain->handlers == NULL)
|
1998-06-11 01:21:14 +02:00
|
|
|
|
{
|
2014-05-25 12:18:14 +02:00
|
|
|
|
GLogDomain *last, *work;
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
|
1998-12-15 06:28:02 +01:00
|
|
|
|
last = NULL;
|
|
|
|
|
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
work = g_log_domains;
|
|
|
|
|
while (work)
|
|
|
|
|
{
|
|
|
|
|
if (work == domain)
|
|
|
|
|
{
|
|
|
|
|
if (last)
|
|
|
|
|
last->next = domain->next;
|
|
|
|
|
else
|
|
|
|
|
g_log_domains = domain->next;
|
|
|
|
|
g_free (domain->log_domain);
|
|
|
|
|
g_free (domain);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2000-08-06 20:09:32 +02:00
|
|
|
|
last = work;
|
|
|
|
|
work = last->next;
|
1998-12-15 06:28:02 +01:00
|
|
|
|
}
|
1998-06-11 01:21:14 +02:00
|
|
|
|
}
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
}
|
|
|
|
|
|
2002-03-27 18:57:30 +01:00
|
|
|
|
static GLogFunc
|
|
|
|
|
g_log_domain_get_handler_L (GLogDomain *domain,
|
|
|
|
|
GLogLevelFlags log_level,
|
|
|
|
|
gpointer *data)
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
{
|
|
|
|
|
if (domain && log_level)
|
1998-06-11 01:21:14 +02:00
|
|
|
|
{
|
2014-05-25 12:18:14 +02:00
|
|
|
|
GLogHandler *handler;
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
|
|
|
|
|
handler = domain->handlers;
|
|
|
|
|
while (handler)
|
|
|
|
|
{
|
|
|
|
|
if ((handler->log_level & log_level) == log_level)
|
|
|
|
|
{
|
|
|
|
|
*data = handler->data;
|
|
|
|
|
return handler->log_func;
|
|
|
|
|
}
|
|
|
|
|
handler = handler->next;
|
|
|
|
|
}
|
1998-06-11 01:21:14 +02:00
|
|
|
|
}
|
2004-09-05 07:46:33 +02:00
|
|
|
|
|
|
|
|
|
*data = default_log_data;
|
|
|
|
|
return default_log_func;
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
}
|
|
|
|
|
|
2011-10-13 04:29:18 +02:00
|
|
|
|
/**
|
|
|
|
|
* g_log_set_always_fatal:
|
|
|
|
|
* @fatal_mask: the mask containing bits set for each level
|
|
|
|
|
* of error which is to be fatal
|
|
|
|
|
*
|
|
|
|
|
* Sets the message levels which are always fatal, in any log domain.
|
|
|
|
|
* When a message with any of these levels is logged the program terminates.
|
|
|
|
|
* You can only set the levels defined by GLib to be fatal.
|
|
|
|
|
* %G_LOG_LEVEL_ERROR is always fatal.
|
|
|
|
|
*
|
|
|
|
|
* You can also make some message levels fatal at runtime by setting
|
2014-02-06 01:32:41 +01:00
|
|
|
|
* the `G_DEBUG` environment variable (see
|
2014-02-06 03:23:28 +01:00
|
|
|
|
* [Running GLib Applications](glib-running.html)).
|
2011-10-13 04:29:18 +02:00
|
|
|
|
*
|
2016-02-20 13:34:29 +01:00
|
|
|
|
* Libraries should not call this function, as it affects all messages logged
|
|
|
|
|
* by a process, including those from other libraries.
|
|
|
|
|
*
|
|
|
|
|
* Structured log messages (using g_log_structured() and
|
|
|
|
|
* g_log_structured_array()) are fatal only if the default log writer is used;
|
|
|
|
|
* otherwise it is up to the writer function to determine which log messages
|
2016-08-12 11:53:19 +02:00
|
|
|
|
* are fatal. See [Using Structured Logging][using-structured-logging].
|
2016-02-20 13:34:29 +01:00
|
|
|
|
*
|
2011-10-13 04:29:18 +02:00
|
|
|
|
* Returns: the old fatal mask
|
|
|
|
|
*/
|
1998-08-18 05:50:35 +02:00
|
|
|
|
GLogLevelFlags
|
|
|
|
|
g_log_set_always_fatal (GLogLevelFlags fatal_mask)
|
|
|
|
|
{
|
|
|
|
|
GLogLevelFlags old_mask;
|
|
|
|
|
|
2002-03-27 18:57:30 +01:00
|
|
|
|
/* restrict the global mask to levels that are known to glib
|
|
|
|
|
* since this setting applies to all domains
|
|
|
|
|
*/
|
1998-08-18 05:50:35 +02:00
|
|
|
|
fatal_mask &= (1 << G_LOG_LEVEL_USER_SHIFT) - 1;
|
|
|
|
|
/* force errors to be fatal */
|
|
|
|
|
fatal_mask |= G_LOG_LEVEL_ERROR;
|
|
|
|
|
/* remove bogus flag */
|
|
|
|
|
fatal_mask &= ~G_LOG_FLAG_FATAL;
|
|
|
|
|
|
2011-09-17 23:56:33 +02:00
|
|
|
|
g_mutex_lock (&g_messages_lock);
|
1998-08-18 05:50:35 +02:00
|
|
|
|
old_mask = g_log_always_fatal;
|
|
|
|
|
g_log_always_fatal = fatal_mask;
|
2011-09-17 23:56:33 +02:00
|
|
|
|
g_mutex_unlock (&g_messages_lock);
|
1998-08-18 05:50:35 +02:00
|
|
|
|
|
|
|
|
|
return old_mask;
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-13 04:29:18 +02:00
|
|
|
|
/**
|
|
|
|
|
* g_log_set_fatal_mask:
|
|
|
|
|
* @log_domain: the log domain
|
|
|
|
|
* @fatal_mask: the new fatal mask
|
|
|
|
|
*
|
|
|
|
|
* Sets the log levels which are fatal in the given domain.
|
|
|
|
|
* %G_LOG_LEVEL_ERROR is always fatal.
|
|
|
|
|
*
|
2016-02-20 13:34:29 +01:00
|
|
|
|
* This has no effect on structured log messages (using g_log_structured() or
|
|
|
|
|
* g_log_structured_array()). To change the fatal behaviour for specific log
|
|
|
|
|
* messages, programs must install a custom log writer function using
|
2016-08-12 11:53:19 +02:00
|
|
|
|
* g_log_set_writer_func(). See
|
|
|
|
|
* [Using Structured Logging][using-structured-logging].
|
2016-02-20 13:34:29 +01:00
|
|
|
|
*
|
2011-10-13 04:29:18 +02:00
|
|
|
|
* Returns: the old fatal mask for the log domain
|
|
|
|
|
*/
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
GLogLevelFlags
|
2002-03-27 18:57:30 +01:00
|
|
|
|
g_log_set_fatal_mask (const gchar *log_domain,
|
|
|
|
|
GLogLevelFlags fatal_mask)
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
{
|
|
|
|
|
GLogLevelFlags old_flags;
|
2014-05-25 12:18:14 +02:00
|
|
|
|
GLogDomain *domain;
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
|
|
|
|
|
if (!log_domain)
|
|
|
|
|
log_domain = "";
|
2016-02-20 13:34:29 +01:00
|
|
|
|
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
/* force errors to be fatal */
|
|
|
|
|
fatal_mask |= G_LOG_LEVEL_ERROR;
|
|
|
|
|
/* remove bogus flag */
|
|
|
|
|
fatal_mask &= ~G_LOG_FLAG_FATAL;
|
|
|
|
|
|
2011-09-17 23:56:33 +02:00
|
|
|
|
g_mutex_lock (&g_messages_lock);
|
2002-03-14 17:20:42 +01:00
|
|
|
|
|
2002-03-27 18:57:30 +01:00
|
|
|
|
domain = g_log_find_domain_L (log_domain);
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
if (!domain)
|
2002-03-27 18:57:30 +01:00
|
|
|
|
domain = g_log_domain_new_L (log_domain);
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
old_flags = domain->fatal_mask;
|
|
|
|
|
|
|
|
|
|
domain->fatal_mask = fatal_mask;
|
2002-03-27 18:57:30 +01:00
|
|
|
|
g_log_domain_check_free_L (domain);
|
2002-03-14 17:20:42 +01:00
|
|
|
|
|
2011-09-17 23:56:33 +02:00
|
|
|
|
g_mutex_unlock (&g_messages_lock);
|
2002-03-14 17:20:42 +01:00
|
|
|
|
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
return old_flags;
|
|
|
|
|
}
|
1998-06-11 01:21:14 +02:00
|
|
|
|
|
2011-10-13 04:29:18 +02:00
|
|
|
|
/**
|
|
|
|
|
* g_log_set_handler:
|
2016-10-29 03:29:02 +02:00
|
|
|
|
* @log_domain: (nullable): the log domain, or %NULL for the default ""
|
2011-10-13 04:29:18 +02:00
|
|
|
|
* application domain
|
|
|
|
|
* @log_levels: the log levels to apply the log handler for.
|
|
|
|
|
* To handle fatal and recursive messages as well, combine
|
|
|
|
|
* the log levels with the #G_LOG_FLAG_FATAL and
|
|
|
|
|
* #G_LOG_FLAG_RECURSION bit flags.
|
|
|
|
|
* @log_func: the log handler function
|
|
|
|
|
* @user_data: data passed to the log handler
|
|
|
|
|
*
|
|
|
|
|
* Sets the log handler for a domain and a set of log levels.
|
|
|
|
|
* To handle fatal and recursive messages the @log_levels parameter
|
|
|
|
|
* must be combined with the #G_LOG_FLAG_FATAL and #G_LOG_FLAG_RECURSION
|
|
|
|
|
* bit flags.
|
|
|
|
|
*
|
|
|
|
|
* Note that since the #G_LOG_LEVEL_ERROR log level is always fatal, if
|
|
|
|
|
* you want to set a handler for this log level you must combine it with
|
|
|
|
|
* #G_LOG_FLAG_FATAL.
|
|
|
|
|
*
|
2016-08-12 11:53:19 +02:00
|
|
|
|
* This has no effect if structured logging is enabled; see
|
|
|
|
|
* [Using Structured Logging][using-structured-logging].
|
|
|
|
|
*
|
2014-02-01 03:56:33 +01:00
|
|
|
|
* Here is an example for adding a log handler for all warning messages
|
|
|
|
|
* in the default domain:
|
2014-02-01 21:11:49 +01:00
|
|
|
|
* |[<!-- language="C" -->
|
2011-10-13 04:29:18 +02:00
|
|
|
|
* g_log_set_handler (NULL, G_LOG_LEVEL_WARNING | G_LOG_FLAG_FATAL
|
|
|
|
|
* | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
|
2014-02-01 03:56:33 +01:00
|
|
|
|
* ]|
|
2011-10-13 04:29:18 +02:00
|
|
|
|
*
|
2014-02-01 03:56:33 +01:00
|
|
|
|
* This example adds a log handler for all critical messages from GTK+:
|
2014-02-01 21:11:49 +01:00
|
|
|
|
* |[<!-- language="C" -->
|
2011-10-13 04:29:18 +02:00
|
|
|
|
* g_log_set_handler ("Gtk", G_LOG_LEVEL_CRITICAL | G_LOG_FLAG_FATAL
|
|
|
|
|
* | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
|
2014-02-01 03:56:33 +01:00
|
|
|
|
* ]|
|
2011-10-13 04:29:18 +02:00
|
|
|
|
*
|
2014-02-01 03:56:33 +01:00
|
|
|
|
* This example adds a log handler for all messages from GLib:
|
2014-02-01 21:11:49 +01:00
|
|
|
|
* |[<!-- language="C" -->
|
2011-10-13 04:29:18 +02:00
|
|
|
|
* g_log_set_handler ("GLib", G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL
|
|
|
|
|
* | G_LOG_FLAG_RECURSION, my_log_handler, NULL);
|
2014-02-01 03:56:33 +01:00
|
|
|
|
* ]|
|
2011-10-13 04:29:18 +02:00
|
|
|
|
*
|
|
|
|
|
* Returns: the id of the new handler
|
|
|
|
|
*/
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
guint
|
2002-03-27 18:57:30 +01:00
|
|
|
|
g_log_set_handler (const gchar *log_domain,
|
2014-11-29 05:31:00 +01:00
|
|
|
|
GLogLevelFlags log_levels,
|
|
|
|
|
GLogFunc log_func,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
return g_log_set_handler_full (log_domain, log_levels, log_func, user_data, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* g_log_set_handler_full: (rename-to g_log_set_handler)
|
2016-10-29 03:29:02 +02:00
|
|
|
|
* @log_domain: (nullable): the log domain, or %NULL for the default ""
|
2014-11-29 05:31:00 +01:00
|
|
|
|
* application domain
|
|
|
|
|
* @log_levels: the log levels to apply the log handler for.
|
|
|
|
|
* To handle fatal and recursive messages as well, combine
|
|
|
|
|
* the log levels with the #G_LOG_FLAG_FATAL and
|
|
|
|
|
* #G_LOG_FLAG_RECURSION bit flags.
|
|
|
|
|
* @log_func: the log handler function
|
|
|
|
|
* @user_data: data passed to the log handler
|
|
|
|
|
* @destroy: destroy notify for @user_data, or %NULL
|
|
|
|
|
*
|
2017-09-22 14:34:19 +02:00
|
|
|
|
* Like g_log_set_handler(), but takes a destroy notify for the @user_data.
|
2014-11-29 05:31:00 +01:00
|
|
|
|
*
|
2016-08-12 11:53:19 +02:00
|
|
|
|
* This has no effect if structured logging is enabled; see
|
|
|
|
|
* [Using Structured Logging][using-structured-logging].
|
|
|
|
|
*
|
2014-11-29 05:31:00 +01:00
|
|
|
|
* Returns: the id of the new handler
|
|
|
|
|
*
|
2015-06-11 07:52:40 +02:00
|
|
|
|
* Since: 2.46
|
2014-11-29 05:31:00 +01:00
|
|
|
|
*/
|
|
|
|
|
guint
|
|
|
|
|
g_log_set_handler_full (const gchar *log_domain,
|
|
|
|
|
GLogLevelFlags log_levels,
|
|
|
|
|
GLogFunc log_func,
|
|
|
|
|
gpointer user_data,
|
|
|
|
|
GDestroyNotify destroy)
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
{
|
|
|
|
|
static guint handler_id = 0;
|
2002-03-27 18:57:30 +01:00
|
|
|
|
GLogDomain *domain;
|
|
|
|
|
GLogHandler *handler;
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
|
|
|
|
|
g_return_val_if_fail ((log_levels & G_LOG_LEVEL_MASK) != 0, 0);
|
|
|
|
|
g_return_val_if_fail (log_func != NULL, 0);
|
|
|
|
|
|
|
|
|
|
if (!log_domain)
|
|
|
|
|
log_domain = "";
|
2002-03-27 18:57:30 +01:00
|
|
|
|
|
|
|
|
|
handler = g_new (GLogHandler, 1);
|
|
|
|
|
|
2011-09-17 23:56:33 +02:00
|
|
|
|
g_mutex_lock (&g_messages_lock);
|
2002-03-14 17:20:42 +01:00
|
|
|
|
|
2002-03-27 18:57:30 +01:00
|
|
|
|
domain = g_log_find_domain_L (log_domain);
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
if (!domain)
|
2002-03-27 18:57:30 +01:00
|
|
|
|
domain = g_log_domain_new_L (log_domain);
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
|
|
|
|
|
handler->id = ++handler_id;
|
|
|
|
|
handler->log_level = log_levels;
|
|
|
|
|
handler->log_func = log_func;
|
|
|
|
|
handler->data = user_data;
|
2014-11-29 05:31:00 +01:00
|
|
|
|
handler->destroy = destroy;
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
handler->next = domain->handlers;
|
|
|
|
|
domain->handlers = handler;
|
2002-03-14 17:20:42 +01:00
|
|
|
|
|
2011-09-17 23:56:33 +02:00
|
|
|
|
g_mutex_unlock (&g_messages_lock);
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
|
|
|
|
|
return handler_id;
|
1998-06-11 01:21:14 +02:00
|
|
|
|
}
|
|
|
|
|
|
2011-10-13 04:29:18 +02:00
|
|
|
|
/**
|
|
|
|
|
* g_log_set_default_handler:
|
2011-10-19 21:07:22 +02:00
|
|
|
|
* @log_func: the log handler function
|
2011-10-13 04:29:18 +02:00
|
|
|
|
* @user_data: data passed to the log handler
|
|
|
|
|
*
|
|
|
|
|
* Installs a default log handler which is used if no
|
|
|
|
|
* log handler has been set for the particular log domain
|
|
|
|
|
* and log level combination. By default, GLib uses
|
|
|
|
|
* g_log_default_handler() as default log handler.
|
|
|
|
|
*
|
2016-08-12 11:53:19 +02:00
|
|
|
|
* This has no effect if structured logging is enabled; see
|
|
|
|
|
* [Using Structured Logging][using-structured-logging].
|
|
|
|
|
*
|
2011-10-13 04:29:18 +02:00
|
|
|
|
* Returns: the previous default log handler
|
|
|
|
|
*
|
|
|
|
|
* Since: 2.6
|
|
|
|
|
*/
|
2004-09-05 07:46:33 +02:00
|
|
|
|
GLogFunc
|
|
|
|
|
g_log_set_default_handler (GLogFunc log_func,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
GLogFunc old_log_func;
|
|
|
|
|
|
2011-09-17 23:56:33 +02:00
|
|
|
|
g_mutex_lock (&g_messages_lock);
|
2004-09-05 07:46:33 +02:00
|
|
|
|
old_log_func = default_log_func;
|
|
|
|
|
default_log_func = log_func;
|
|
|
|
|
default_log_data = user_data;
|
2011-09-17 23:56:33 +02:00
|
|
|
|
g_mutex_unlock (&g_messages_lock);
|
2004-09-05 07:46:33 +02:00
|
|
|
|
|
|
|
|
|
return old_log_func;
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-10 16:40:11 +02:00
|
|
|
|
/**
|
|
|
|
|
* g_test_log_set_fatal_handler:
|
|
|
|
|
* @log_func: the log handler function.
|
|
|
|
|
* @user_data: data passed to the log handler.
|
|
|
|
|
*
|
|
|
|
|
* Installs a non-error fatal log handler which can be
|
|
|
|
|
* used to decide whether log messages which are counted
|
|
|
|
|
* as fatal abort the program.
|
|
|
|
|
*
|
|
|
|
|
* The use case here is that you are running a test case
|
|
|
|
|
* that depends on particular libraries or circumstances
|
|
|
|
|
* and cannot prevent certain known critical or warning
|
|
|
|
|
* messages. So you install a handler that compares the
|
|
|
|
|
* domain and message to precisely not abort in such a case.
|
|
|
|
|
*
|
|
|
|
|
* Note that the handler is reset at the beginning of
|
|
|
|
|
* any test case, so you have to set it inside each test
|
|
|
|
|
* function which needs the special behavior.
|
|
|
|
|
*
|
|
|
|
|
* This handler has no effect on g_error messages.
|
|
|
|
|
*
|
2016-02-20 13:34:29 +01:00
|
|
|
|
* This handler also has no effect on structured log messages (using
|
|
|
|
|
* g_log_structured() or g_log_structured_array()). To change the fatal
|
|
|
|
|
* behaviour for specific log messages, programs must install a custom log
|
2016-08-12 11:53:19 +02:00
|
|
|
|
* writer function using g_log_set_writer_func().See
|
|
|
|
|
* [Using Structured Logging][using-structured-logging].
|
2016-02-20 13:34:29 +01:00
|
|
|
|
*
|
2009-09-10 16:40:11 +02:00
|
|
|
|
* Since: 2.22
|
|
|
|
|
**/
|
|
|
|
|
void
|
|
|
|
|
g_test_log_set_fatal_handler (GTestLogFatalFunc log_func,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
2011-09-17 23:56:33 +02:00
|
|
|
|
g_mutex_lock (&g_messages_lock);
|
2009-09-10 16:40:11 +02:00
|
|
|
|
fatal_log_func = log_func;
|
|
|
|
|
fatal_log_data = user_data;
|
2011-09-17 23:56:33 +02:00
|
|
|
|
g_mutex_unlock (&g_messages_lock);
|
2009-09-10 16:40:11 +02:00
|
|
|
|
}
|
|
|
|
|
|
2011-10-13 04:29:18 +02:00
|
|
|
|
/**
|
|
|
|
|
* g_log_remove_handler:
|
|
|
|
|
* @log_domain: the log domain
|
|
|
|
|
* @handler_id: the id of the handler, which was returned
|
|
|
|
|
* in g_log_set_handler()
|
|
|
|
|
*
|
|
|
|
|
* Removes the log handler.
|
2016-08-12 11:53:19 +02:00
|
|
|
|
*
|
|
|
|
|
* This has no effect if structured logging is enabled; see
|
|
|
|
|
* [Using Structured Logging][using-structured-logging].
|
2011-10-13 04:29:18 +02:00
|
|
|
|
*/
|
1998-06-11 01:21:14 +02:00
|
|
|
|
void
|
1999-10-12 14:08:13 +02:00
|
|
|
|
g_log_remove_handler (const gchar *log_domain,
|
|
|
|
|
guint handler_id)
|
1998-06-11 01:21:14 +02:00
|
|
|
|
{
|
2014-05-25 12:18:14 +02:00
|
|
|
|
GLogDomain *domain;
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
|
|
|
|
|
g_return_if_fail (handler_id > 0);
|
|
|
|
|
|
|
|
|
|
if (!log_domain)
|
|
|
|
|
log_domain = "";
|
|
|
|
|
|
2011-09-17 23:56:33 +02:00
|
|
|
|
g_mutex_lock (&g_messages_lock);
|
2002-03-27 18:57:30 +01:00
|
|
|
|
domain = g_log_find_domain_L (log_domain);
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
if (domain)
|
|
|
|
|
{
|
2002-03-27 18:57:30 +01:00
|
|
|
|
GLogHandler *work, *last;
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
|
|
|
|
|
last = NULL;
|
|
|
|
|
work = domain->handlers;
|
|
|
|
|
while (work)
|
|
|
|
|
{
|
|
|
|
|
if (work->id == handler_id)
|
|
|
|
|
{
|
|
|
|
|
if (last)
|
|
|
|
|
last->next = work->next;
|
|
|
|
|
else
|
|
|
|
|
domain->handlers = work->next;
|
2002-03-27 18:57:30 +01:00
|
|
|
|
g_log_domain_check_free_L (domain);
|
2011-09-17 23:56:33 +02:00
|
|
|
|
g_mutex_unlock (&g_messages_lock);
|
2014-11-29 05:31:00 +01:00
|
|
|
|
if (work->destroy)
|
|
|
|
|
work->destroy (work->data);
|
2002-03-27 18:57:30 +01:00
|
|
|
|
g_free (work);
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
return;
|
|
|
|
|
}
|
2000-08-06 20:09:32 +02:00
|
|
|
|
last = work;
|
|
|
|
|
work = last->next;
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
}
|
2002-03-14 17:20:42 +01:00
|
|
|
|
}
|
2011-09-17 23:56:33 +02:00
|
|
|
|
g_mutex_unlock (&g_messages_lock);
|
2013-05-20 22:54:48 +02:00
|
|
|
|
g_warning ("%s: could not find handler with id '%d' for domain \"%s\"",
|
2002-03-27 18:57:30 +01:00
|
|
|
|
G_STRLOC, handler_id, log_domain);
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
}
|
1998-06-11 01:21:14 +02:00
|
|
|
|
|
2012-07-30 22:05:08 +02:00
|
|
|
|
#define CHAR_IS_SAFE(wc) (!((wc < 0x20 && wc != '\t' && wc != '\n' && wc != '\r') || \
|
|
|
|
|
(wc == 0x7f) || \
|
|
|
|
|
(wc >= 0x80 && wc < 0xa0)))
|
|
|
|
|
|
|
|
|
|
static gchar*
|
|
|
|
|
strdup_convert (const gchar *string,
|
|
|
|
|
const gchar *charset)
|
|
|
|
|
{
|
|
|
|
|
if (!g_utf8_validate (string, -1, NULL))
|
|
|
|
|
{
|
|
|
|
|
GString *gstring = g_string_new ("[Invalid UTF-8] ");
|
|
|
|
|
guchar *p;
|
|
|
|
|
|
|
|
|
|
for (p = (guchar *)string; *p; p++)
|
|
|
|
|
{
|
|
|
|
|
if (CHAR_IS_SAFE(*p) &&
|
|
|
|
|
!(*p == '\r' && *(p + 1) != '\n') &&
|
|
|
|
|
*p < 0x80)
|
|
|
|
|
g_string_append_c (gstring, *p);
|
|
|
|
|
else
|
|
|
|
|
g_string_append_printf (gstring, "\\x%02x", (guint)(guchar)*p);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return g_string_free (gstring, FALSE);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
GError *err = NULL;
|
|
|
|
|
|
|
|
|
|
gchar *result = g_convert_with_fallback (string, -1, charset, "UTF-8", "?", NULL, NULL, &err);
|
|
|
|
|
if (result)
|
|
|
|
|
return result;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Not thread-safe, but doesn't matter if we print the warning twice
|
|
|
|
|
*/
|
|
|
|
|
static gboolean warned = FALSE;
|
|
|
|
|
if (!warned)
|
|
|
|
|
{
|
|
|
|
|
warned = TRUE;
|
|
|
|
|
_g_fprintf (stderr, "GLib: Cannot convert message: %s\n", err->message);
|
|
|
|
|
}
|
|
|
|
|
g_error_free (err);
|
|
|
|
|
|
|
|
|
|
return g_strdup (string);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* For a radix of 8 we need at most 3 output bytes for 1 input
|
|
|
|
|
* byte. Additionally we might need up to 2 output bytes for the
|
|
|
|
|
* readix prefix and 1 byte for the trailing NULL.
|
|
|
|
|
*/
|
|
|
|
|
#define FORMAT_UNSIGNED_BUFSIZE ((GLIB_SIZEOF_LONG * 3) + 3)
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
format_unsigned (gchar *buf,
|
|
|
|
|
gulong num,
|
|
|
|
|
guint radix)
|
|
|
|
|
{
|
|
|
|
|
gulong tmp;
|
|
|
|
|
gchar c;
|
|
|
|
|
gint i, n;
|
|
|
|
|
|
|
|
|
|
/* we may not call _any_ GLib functions here (or macros like g_return_if_fail()) */
|
|
|
|
|
|
|
|
|
|
if (radix != 8 && radix != 10 && radix != 16)
|
|
|
|
|
{
|
|
|
|
|
*buf = '\000';
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!num)
|
|
|
|
|
{
|
|
|
|
|
*buf++ = '0';
|
|
|
|
|
*buf = '\000';
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (radix == 16)
|
|
|
|
|
{
|
|
|
|
|
*buf++ = '0';
|
|
|
|
|
*buf++ = 'x';
|
|
|
|
|
}
|
|
|
|
|
else if (radix == 8)
|
|
|
|
|
{
|
|
|
|
|
*buf++ = '0';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
n = 0;
|
|
|
|
|
tmp = num;
|
|
|
|
|
while (tmp)
|
|
|
|
|
{
|
|
|
|
|
tmp /= radix;
|
|
|
|
|
n++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
i = n;
|
|
|
|
|
|
|
|
|
|
/* Again we can't use g_assert; actually this check should _never_ fail. */
|
|
|
|
|
if (n > FORMAT_UNSIGNED_BUFSIZE - 3)
|
|
|
|
|
{
|
|
|
|
|
*buf = '\000';
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while (num)
|
|
|
|
|
{
|
|
|
|
|
i--;
|
|
|
|
|
c = (num % radix);
|
|
|
|
|
if (c < 10)
|
|
|
|
|
buf[i] = c + '0';
|
|
|
|
|
else
|
|
|
|
|
buf[i] = c + 'a' - 10;
|
|
|
|
|
num /= radix;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
buf[n] = '\000';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* string size big enough to hold level prefix */
|
|
|
|
|
#define STRING_BUFFER_SIZE (FORMAT_UNSIGNED_BUFSIZE + 32)
|
|
|
|
|
|
|
|
|
|
#define ALERT_LEVELS (G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING)
|
|
|
|
|
|
|
|
|
|
/* these are emitted by the default log handler */
|
|
|
|
|
#define DEFAULT_LEVELS (G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING | G_LOG_LEVEL_MESSAGE)
|
|
|
|
|
/* these are filtered by G_MESSAGES_DEBUG by the default log handler */
|
|
|
|
|
#define INFO_LEVELS (G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG)
|
|
|
|
|
|
2016-03-15 11:47:39 +01:00
|
|
|
|
static const gchar *log_level_to_color (GLogLevelFlags log_level,
|
|
|
|
|
gboolean use_color);
|
|
|
|
|
static const gchar *color_reset (gboolean use_color);
|
|
|
|
|
|
2015-04-09 18:05:18 +02:00
|
|
|
|
static FILE *
|
2012-07-30 22:05:08 +02:00
|
|
|
|
mklevel_prefix (gchar level_prefix[STRING_BUFFER_SIZE],
|
2016-03-15 11:47:39 +01:00
|
|
|
|
GLogLevelFlags log_level,
|
|
|
|
|
gboolean use_color)
|
2012-07-30 22:05:08 +02:00
|
|
|
|
{
|
|
|
|
|
gboolean to_stdout = TRUE;
|
|
|
|
|
|
|
|
|
|
/* we may not call _any_ GLib functions here */
|
|
|
|
|
|
2016-03-15 11:47:39 +01:00
|
|
|
|
strcpy (level_prefix, log_level_to_color (log_level, use_color));
|
|
|
|
|
|
2012-07-30 22:05:08 +02:00
|
|
|
|
switch (log_level & G_LOG_LEVEL_MASK)
|
|
|
|
|
{
|
|
|
|
|
case G_LOG_LEVEL_ERROR:
|
2016-03-15 11:47:39 +01:00
|
|
|
|
strcat (level_prefix, "ERROR");
|
2012-07-30 22:05:08 +02:00
|
|
|
|
to_stdout = FALSE;
|
|
|
|
|
break;
|
|
|
|
|
case G_LOG_LEVEL_CRITICAL:
|
2016-03-15 11:47:39 +01:00
|
|
|
|
strcat (level_prefix, "CRITICAL");
|
2012-07-30 22:05:08 +02:00
|
|
|
|
to_stdout = FALSE;
|
|
|
|
|
break;
|
|
|
|
|
case G_LOG_LEVEL_WARNING:
|
2016-03-15 11:47:39 +01:00
|
|
|
|
strcat (level_prefix, "WARNING");
|
2012-07-30 22:05:08 +02:00
|
|
|
|
to_stdout = FALSE;
|
|
|
|
|
break;
|
|
|
|
|
case G_LOG_LEVEL_MESSAGE:
|
2016-03-15 11:47:39 +01:00
|
|
|
|
strcat (level_prefix, "Message");
|
2012-07-30 22:05:08 +02:00
|
|
|
|
to_stdout = FALSE;
|
|
|
|
|
break;
|
|
|
|
|
case G_LOG_LEVEL_INFO:
|
2016-03-15 11:47:39 +01:00
|
|
|
|
strcat (level_prefix, "INFO");
|
2012-07-30 22:05:08 +02:00
|
|
|
|
break;
|
|
|
|
|
case G_LOG_LEVEL_DEBUG:
|
2016-03-15 11:47:39 +01:00
|
|
|
|
strcat (level_prefix, "DEBUG");
|
2012-07-30 22:05:08 +02:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
if (log_level)
|
|
|
|
|
{
|
2016-03-15 11:47:39 +01:00
|
|
|
|
strcat (level_prefix, "LOG-");
|
2012-07-30 22:05:08 +02:00
|
|
|
|
format_unsigned (level_prefix + 4, log_level & G_LOG_LEVEL_MASK, 16);
|
|
|
|
|
}
|
|
|
|
|
else
|
2016-03-15 11:47:39 +01:00
|
|
|
|
strcat (level_prefix, "LOG");
|
2012-07-30 22:05:08 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
2016-03-15 11:47:39 +01:00
|
|
|
|
|
|
|
|
|
strcat (level_prefix, color_reset (use_color));
|
|
|
|
|
|
2012-07-30 22:05:08 +02:00
|
|
|
|
if (log_level & G_LOG_FLAG_RECURSION)
|
|
|
|
|
strcat (level_prefix, " (recursed)");
|
|
|
|
|
if (log_level & ALERT_LEVELS)
|
|
|
|
|
strcat (level_prefix, " **");
|
|
|
|
|
|
|
|
|
|
#ifdef G_OS_WIN32
|
2012-11-16 04:26:54 +01:00
|
|
|
|
if ((log_level & G_LOG_FLAG_FATAL) != 0 && !g_test_initialized ())
|
|
|
|
|
win32_keep_fatal_message = TRUE;
|
2012-07-30 22:05:08 +02:00
|
|
|
|
#endif
|
2015-04-09 18:05:18 +02:00
|
|
|
|
return to_stdout ? stdout : stderr;
|
2012-07-30 22:05:08 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
gchar *log_domain;
|
|
|
|
|
GLogLevelFlags log_level;
|
|
|
|
|
gchar *pattern;
|
|
|
|
|
} GTestExpectedMessage;
|
|
|
|
|
|
|
|
|
|
static GSList *expected_messages = NULL;
|
|
|
|
|
|
2011-10-13 04:29:18 +02:00
|
|
|
|
/**
|
|
|
|
|
* g_logv:
|
2013-12-06 13:23:09 +01:00
|
|
|
|
* @log_domain: (nullable): the log domain, or %NULL for the default ""
|
|
|
|
|
* application domain
|
2011-10-13 04:29:18 +02:00
|
|
|
|
* @log_level: the log level
|
|
|
|
|
* @format: the message format. See the printf() documentation
|
|
|
|
|
* @args: the parameters to insert into the format string
|
|
|
|
|
*
|
|
|
|
|
* Logs an error or debugging message.
|
|
|
|
|
*
|
|
|
|
|
* If the log level has been set as fatal, the abort()
|
|
|
|
|
* function is called to terminate the program.
|
2013-10-21 16:09:13 +02:00
|
|
|
|
*
|
|
|
|
|
* If g_log_default_handler() is used as the log handler function, a new-line
|
|
|
|
|
* character will automatically be appended to @..., and need not be entered
|
|
|
|
|
* manually.
|
2016-08-12 11:53:19 +02:00
|
|
|
|
*
|
|
|
|
|
* If [structured logging is enabled][using-structured-logging] this will
|
|
|
|
|
* output via the structured log writer function (see g_log_set_writer_func()).
|
2011-10-13 04:29:18 +02:00
|
|
|
|
*/
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
void
|
1999-10-12 14:08:13 +02:00
|
|
|
|
g_logv (const gchar *log_domain,
|
|
|
|
|
GLogLevelFlags log_level,
|
|
|
|
|
const gchar *format,
|
2012-07-30 21:32:31 +02:00
|
|
|
|
va_list args)
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
{
|
2002-03-27 18:57:30 +01:00
|
|
|
|
gboolean was_fatal = (log_level & G_LOG_FLAG_FATAL) != 0;
|
|
|
|
|
gboolean was_recursion = (log_level & G_LOG_FLAG_RECURSION) != 0;
|
2012-07-30 21:32:31 +02:00
|
|
|
|
gchar buffer[1025], *msg, *msg_alloc = NULL;
|
2002-03-27 18:57:30 +01:00
|
|
|
|
gint i;
|
2001-10-29 19:49:28 +01:00
|
|
|
|
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
log_level &= G_LOG_LEVEL_MASK;
|
|
|
|
|
if (!log_level)
|
|
|
|
|
return;
|
2009-09-30 02:45:26 +02:00
|
|
|
|
|
2012-07-30 21:32:31 +02:00
|
|
|
|
if (log_level & G_LOG_FLAG_RECURSION)
|
|
|
|
|
{
|
|
|
|
|
/* we use a stack buffer of fixed size, since we're likely
|
|
|
|
|
* in an out-of-memory situation
|
|
|
|
|
*/
|
|
|
|
|
gsize size G_GNUC_UNUSED;
|
|
|
|
|
|
|
|
|
|
size = _g_vsnprintf (buffer, 1024, format, args);
|
|
|
|
|
msg = buffer;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
msg = msg_alloc = g_strdup_vprintf (format, args);
|
|
|
|
|
|
2016-08-03 22:28:28 +02:00
|
|
|
|
if (expected_messages)
|
2012-07-30 22:05:08 +02:00
|
|
|
|
{
|
2016-08-03 22:28:28 +02:00
|
|
|
|
GTestExpectedMessage *expected = expected_messages->data;
|
|
|
|
|
|
|
|
|
|
if (g_strcmp0 (expected->log_domain, log_domain) == 0 &&
|
|
|
|
|
((log_level & expected->log_level) == expected->log_level) &&
|
|
|
|
|
g_pattern_match_simple (expected->pattern, msg))
|
|
|
|
|
{
|
|
|
|
|
expected_messages = g_slist_delete_link (expected_messages,
|
|
|
|
|
expected_messages);
|
|
|
|
|
g_free (expected->log_domain);
|
|
|
|
|
g_free (expected->pattern);
|
|
|
|
|
g_free (expected);
|
|
|
|
|
g_free (msg_alloc);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else if ((log_level & G_LOG_LEVEL_DEBUG) != G_LOG_LEVEL_DEBUG)
|
|
|
|
|
{
|
|
|
|
|
gchar level_prefix[STRING_BUFFER_SIZE];
|
|
|
|
|
gchar *expected_message;
|
|
|
|
|
|
|
|
|
|
mklevel_prefix (level_prefix, expected->log_level, FALSE);
|
|
|
|
|
expected_message = g_strdup_printf ("Did not see expected message %s-%s: %s",
|
|
|
|
|
expected->log_domain ? expected->log_domain : "**",
|
|
|
|
|
level_prefix, expected->pattern);
|
|
|
|
|
g_log_default_handler (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, expected_message, NULL);
|
|
|
|
|
g_free (expected_message);
|
|
|
|
|
|
|
|
|
|
log_level |= G_LOG_FLAG_FATAL;
|
|
|
|
|
}
|
2012-07-30 22:05:08 +02:00
|
|
|
|
}
|
|
|
|
|
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
for (i = g_bit_nth_msf (log_level, -1); i >= 0; i = g_bit_nth_msf (log_level, i))
|
1998-06-11 01:21:14 +02:00
|
|
|
|
{
|
2014-05-25 12:18:14 +02:00
|
|
|
|
GLogLevelFlags test_level;
|
2009-09-30 02:45:26 +02:00
|
|
|
|
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
test_level = 1 << i;
|
|
|
|
|
if (log_level & test_level)
|
|
|
|
|
{
|
|
|
|
|
GLogDomain *domain;
|
|
|
|
|
GLogFunc log_func;
|
2004-09-20 05:53:39 +02:00
|
|
|
|
GLogLevelFlags domain_fatal_mask;
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
gpointer data = NULL;
|
2009-09-30 02:45:26 +02:00
|
|
|
|
gboolean masquerade_fatal = FALSE;
|
2011-09-18 07:21:01 +02:00
|
|
|
|
guint depth;
|
2002-03-14 17:20:42 +01:00
|
|
|
|
|
2002-03-27 18:57:30 +01:00
|
|
|
|
if (was_fatal)
|
|
|
|
|
test_level |= G_LOG_FLAG_FATAL;
|
|
|
|
|
if (was_recursion)
|
|
|
|
|
test_level |= G_LOG_FLAG_RECURSION;
|
|
|
|
|
|
|
|
|
|
/* check recursion and lookup handler */
|
2011-09-17 23:56:33 +02:00
|
|
|
|
g_mutex_lock (&g_messages_lock);
|
2011-09-18 07:21:01 +02:00
|
|
|
|
depth = GPOINTER_TO_UINT (g_private_get (&g_log_depth));
|
2002-03-27 18:57:30 +01:00
|
|
|
|
domain = g_log_find_domain_L (log_domain ? log_domain : "");
|
1998-12-15 06:28:02 +01:00
|
|
|
|
if (depth)
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
test_level |= G_LOG_FLAG_RECURSION;
|
1998-12-15 06:28:02 +01:00
|
|
|
|
depth++;
|
2002-03-27 18:57:30 +01:00
|
|
|
|
domain_fatal_mask = domain ? domain->fatal_mask : G_LOG_FATAL_MASK;
|
|
|
|
|
if ((domain_fatal_mask | g_log_always_fatal) & test_level)
|
|
|
|
|
test_level |= G_LOG_FLAG_FATAL;
|
|
|
|
|
if (test_level & G_LOG_FLAG_RECURSION)
|
|
|
|
|
log_func = _g_log_fallback_handler;
|
|
|
|
|
else
|
|
|
|
|
log_func = g_log_domain_get_handler_L (domain, test_level, &data);
|
|
|
|
|
domain = NULL;
|
2011-09-17 23:56:33 +02:00
|
|
|
|
g_mutex_unlock (&g_messages_lock);
|
2002-03-27 18:57:30 +01:00
|
|
|
|
|
2011-09-18 07:10:07 +02:00
|
|
|
|
g_private_set (&g_log_depth, GUINT_TO_POINTER (depth));
|
1998-12-15 06:28:02 +01:00
|
|
|
|
|
2012-07-30 21:32:31 +02:00
|
|
|
|
log_func (log_domain, test_level, msg, data);
|
2002-03-14 17:20:42 +01:00
|
|
|
|
|
2012-07-30 21:32:31 +02:00
|
|
|
|
if ((test_level & G_LOG_FLAG_FATAL)
|
|
|
|
|
&& !(test_level & G_LOG_LEVEL_ERROR))
|
|
|
|
|
{
|
|
|
|
|
masquerade_fatal = fatal_log_func
|
|
|
|
|
&& !fatal_log_func (log_domain, test_level, msg, fatal_log_data);
|
|
|
|
|
}
|
2002-03-27 18:57:30 +01:00
|
|
|
|
|
2013-11-23 18:06:05 +01:00
|
|
|
|
if ((test_level & G_LOG_FLAG_FATAL) && !masquerade_fatal)
|
2009-09-10 16:40:11 +02:00
|
|
|
|
{
|
2002-02-14 08:06:56 +01:00
|
|
|
|
#ifdef G_OS_WIN32
|
2012-11-16 04:26:54 +01:00
|
|
|
|
if (win32_keep_fatal_message)
|
|
|
|
|
{
|
|
|
|
|
gchar *locale_msg = g_locale_from_utf8 (fatal_msg_buf, -1, NULL, NULL, NULL);
|
|
|
|
|
|
|
|
|
|
MessageBox (NULL, locale_msg, NULL,
|
|
|
|
|
MB_ICONERROR|MB_SETFOREGROUND);
|
|
|
|
|
}
|
2005-01-19 02:55:40 +01:00
|
|
|
|
#endif /* !G_OS_WIN32 */
|
2016-03-15 13:28:37 +01:00
|
|
|
|
|
|
|
|
|
_g_log_abort (!(test_level & G_LOG_FLAG_RECURSION));
|
1999-09-14 00:17:27 +02:00
|
|
|
|
}
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
|
1998-12-15 06:28:02 +01:00
|
|
|
|
depth--;
|
2011-09-18 07:10:07 +02:00
|
|
|
|
g_private_set (&g_log_depth, GUINT_TO_POINTER (depth));
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
}
|
1998-06-11 01:21:14 +02:00
|
|
|
|
}
|
2012-07-30 21:32:31 +02:00
|
|
|
|
|
|
|
|
|
g_free (msg_alloc);
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
}
|
|
|
|
|
|
2011-10-13 04:29:18 +02:00
|
|
|
|
/**
|
|
|
|
|
* g_log:
|
2013-12-06 13:23:09 +01:00
|
|
|
|
* @log_domain: (nullable): the log domain, usually #G_LOG_DOMAIN, or %NULL
|
|
|
|
|
* for the default
|
2011-10-13 04:29:18 +02:00
|
|
|
|
* @log_level: the log level, either from #GLogLevelFlags
|
|
|
|
|
* or a user-defined level
|
|
|
|
|
* @format: the message format. See the printf() documentation
|
|
|
|
|
* @...: the parameters to insert into the format string
|
|
|
|
|
*
|
|
|
|
|
* Logs an error or debugging message.
|
|
|
|
|
*
|
|
|
|
|
* If the log level has been set as fatal, the abort()
|
|
|
|
|
* function is called to terminate the program.
|
2013-10-21 16:09:13 +02:00
|
|
|
|
*
|
|
|
|
|
* If g_log_default_handler() is used as the log handler function, a new-line
|
|
|
|
|
* character will automatically be appended to @..., and need not be entered
|
|
|
|
|
* manually.
|
2016-08-12 11:53:19 +02:00
|
|
|
|
*
|
|
|
|
|
* If [structured logging is enabled][using-structured-logging] this will
|
|
|
|
|
* output via the structured log writer function (see g_log_set_writer_func()).
|
2011-10-13 04:29:18 +02:00
|
|
|
|
*/
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
void
|
2002-03-27 18:57:30 +01:00
|
|
|
|
g_log (const gchar *log_domain,
|
|
|
|
|
GLogLevelFlags log_level,
|
|
|
|
|
const gchar *format,
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
...)
|
|
|
|
|
{
|
removed this function which was not publically exported in glib.h. to
Mon Aug 24 02:08:56 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gstring.c:
* gstrfuncs.c:
(g_vsprintf): removed this function which was not publically
exported in glib.h. to export it, it should have been named
differently in the first place, since its semantics differ from
vsprintf(). apart from that, it was a possible cause for
problems since it worked on a previously allocated memory area and
was used in a lot places of glib. exporting it would have been a
guararant for problems with threaded programs.
(g_printf_string_upper_bound): exported this function to return
a string size, guarranteed to be big enough to hold the fully
expanded format+args string. added 'q', 'L' and 'll' flag handling.
in fact, the newly allocated area is in most cases much bigger than
required.
(g_strdup_vprintf()): new function returning a newly allocated string
containing the contents of *format and associated args (size is
calculated with g_printf_string_upper_bound()).
(g_strdup_printf): new function which wraps g_strdup_vprintf().
* configure.in: check for va_copy() or __va_copy() alternatively.
check whether va_lists can be copyied by value.
* glib.h: provide a definition for G_VA_COPY.
* glib.h:
* gmessages.c:
(g_logv):
(g_vsnprintf):
pass va_lists by value, not by reference, since this causes problems
on platforms that implement va_list as as arrays. internaly, use
G_VA_COPY (new_arg, org_arg); va_end (new_arg); to produce a second
va_list variable, if multiple passes are required. changed all
callers.
* glib.h:
* gerror.h:
renamed g_debug() to g_on_error_query(), cleaned up a bit.
renamed g_stack_trace() to g_on_error_stack_trace() since both
functions cluttered different namespaces.
there is an appropriate comment in glib.h now that explains the
unix and gdb specific dependencies of both functions.
removed g_attach_process().
g_on_error_stack_trace() should probably be handled with caution,
i've seem several different linux versions (2.0.x) become unstable
after invokation of this function.
1998-08-24 07:26:53 +02:00
|
|
|
|
va_list args;
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
|
removed this function which was not publically exported in glib.h. to
Mon Aug 24 02:08:56 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gstring.c:
* gstrfuncs.c:
(g_vsprintf): removed this function which was not publically
exported in glib.h. to export it, it should have been named
differently in the first place, since its semantics differ from
vsprintf(). apart from that, it was a possible cause for
problems since it worked on a previously allocated memory area and
was used in a lot places of glib. exporting it would have been a
guararant for problems with threaded programs.
(g_printf_string_upper_bound): exported this function to return
a string size, guarranteed to be big enough to hold the fully
expanded format+args string. added 'q', 'L' and 'll' flag handling.
in fact, the newly allocated area is in most cases much bigger than
required.
(g_strdup_vprintf()): new function returning a newly allocated string
containing the contents of *format and associated args (size is
calculated with g_printf_string_upper_bound()).
(g_strdup_printf): new function which wraps g_strdup_vprintf().
* configure.in: check for va_copy() or __va_copy() alternatively.
check whether va_lists can be copyied by value.
* glib.h: provide a definition for G_VA_COPY.
* glib.h:
* gmessages.c:
(g_logv):
(g_vsnprintf):
pass va_lists by value, not by reference, since this causes problems
on platforms that implement va_list as as arrays. internaly, use
G_VA_COPY (new_arg, org_arg); va_end (new_arg); to produce a second
va_list variable, if multiple passes are required. changed all
callers.
* glib.h:
* gerror.h:
renamed g_debug() to g_on_error_query(), cleaned up a bit.
renamed g_stack_trace() to g_on_error_stack_trace() since both
functions cluttered different namespaces.
there is an appropriate comment in glib.h now that explains the
unix and gdb specific dependencies of both functions.
removed g_attach_process().
g_on_error_stack_trace() should probably be handled with caution,
i've seem several different linux versions (2.0.x) become unstable
after invokation of this function.
1998-08-24 07:26:53 +02:00
|
|
|
|
va_start (args, format);
|
|
|
|
|
g_logv (log_domain, log_level, format, args);
|
|
|
|
|
va_end (args);
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-20 13:34:29 +01:00
|
|
|
|
/* Return value must be 1 byte long (plus nul byte).
|
|
|
|
|
* Reference: http://man7.org/linux/man-pages/man3/syslog.3.html#DESCRIPTION
|
|
|
|
|
*/
|
|
|
|
|
static const gchar *
|
|
|
|
|
log_level_to_priority (GLogLevelFlags log_level)
|
|
|
|
|
{
|
|
|
|
|
if (log_level & G_LOG_LEVEL_ERROR)
|
|
|
|
|
return "3";
|
|
|
|
|
else if (log_level & G_LOG_LEVEL_CRITICAL)
|
|
|
|
|
return "4";
|
|
|
|
|
else if (log_level & G_LOG_LEVEL_WARNING)
|
|
|
|
|
return "4";
|
|
|
|
|
else if (log_level & G_LOG_LEVEL_MESSAGE)
|
|
|
|
|
return "5";
|
|
|
|
|
else if (log_level & G_LOG_LEVEL_INFO)
|
|
|
|
|
return "6";
|
|
|
|
|
else if (log_level & G_LOG_LEVEL_DEBUG)
|
|
|
|
|
return "7";
|
|
|
|
|
|
|
|
|
|
/* Default to LOG_NOTICE for custom log levels. */
|
|
|
|
|
return "5";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static FILE *
|
|
|
|
|
log_level_to_file (GLogLevelFlags log_level)
|
|
|
|
|
{
|
|
|
|
|
if (log_level & (G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL |
|
|
|
|
|
G_LOG_LEVEL_WARNING | G_LOG_LEVEL_MESSAGE))
|
|
|
|
|
return stderr;
|
|
|
|
|
else
|
|
|
|
|
return stdout;
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-15 11:47:39 +01:00
|
|
|
|
static const gchar *
|
|
|
|
|
log_level_to_color (GLogLevelFlags log_level,
|
|
|
|
|
gboolean use_color)
|
|
|
|
|
{
|
|
|
|
|
/* we may not call _any_ GLib functions here */
|
|
|
|
|
|
|
|
|
|
if (!use_color)
|
|
|
|
|
return "";
|
|
|
|
|
|
|
|
|
|
if (log_level & G_LOG_LEVEL_ERROR)
|
|
|
|
|
return "\033[1;31m";
|
|
|
|
|
else if (log_level & G_LOG_LEVEL_CRITICAL)
|
|
|
|
|
return "\033[1;35m";
|
|
|
|
|
else if (log_level & G_LOG_LEVEL_WARNING)
|
|
|
|
|
return "\033[1;33m";
|
|
|
|
|
else if (log_level & G_LOG_LEVEL_MESSAGE)
|
|
|
|
|
return "\033[1;32m";
|
|
|
|
|
else if (log_level & G_LOG_LEVEL_INFO)
|
|
|
|
|
return "\033[1;32m";
|
|
|
|
|
else if (log_level & G_LOG_LEVEL_DEBUG)
|
|
|
|
|
return "\033[1;32m";
|
|
|
|
|
|
|
|
|
|
/* No color for custom log levels. */
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const gchar *
|
|
|
|
|
color_reset (gboolean use_color)
|
|
|
|
|
{
|
|
|
|
|
/* we may not call _any_ GLib functions here */
|
|
|
|
|
|
|
|
|
|
if (!use_color)
|
|
|
|
|
return "";
|
|
|
|
|
|
|
|
|
|
return "\033[0m";
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-07 12:32:54 +01:00
|
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
|
|
|
|
|
|
/* We might be using tty emulators such as mintty, so try to detect it, if we passed in a valid FD
|
|
|
|
|
* so we need to check the name of the pipe if _isatty (fd) == 0
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
win32_is_pipe_tty (int fd)
|
|
|
|
|
{
|
|
|
|
|
gboolean result = FALSE;
|
|
|
|
|
int error;
|
|
|
|
|
HANDLE h_fd;
|
|
|
|
|
FILE_NAME_INFO *info = NULL;
|
|
|
|
|
gint info_size = sizeof (FILE_NAME_INFO) + sizeof (WCHAR) * MAX_PATH;
|
|
|
|
|
wchar_t *name = NULL;
|
|
|
|
|
gint length;
|
|
|
|
|
|
|
|
|
|
/* XXX: Remove once XP support really dropped */
|
2017-03-02 01:17:35 +01:00
|
|
|
|
#if _WIN32_WINNT < 0x0600
|
2016-12-07 12:32:54 +01:00
|
|
|
|
HANDLE h_kerneldll = NULL;
|
|
|
|
|
fGetFileInformationByHandleEx *GetFileInformationByHandleEx;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
h_fd = (HANDLE) _get_osfhandle (fd);
|
|
|
|
|
|
|
|
|
|
if (h_fd == INVALID_HANDLE_VALUE || GetFileType (h_fd) != FILE_TYPE_PIPE)
|
|
|
|
|
goto done_query;
|
|
|
|
|
|
|
|
|
|
/* The following check is available on Vista or later, so on XP, no color support */
|
|
|
|
|
/* mintty uses a pipe, in the form of \{cygwin|msys}-xxxxxxxxxxxxxxxx-ptyN-{from|to}-master */
|
|
|
|
|
|
|
|
|
|
/* XXX: Remove once XP support really dropped */
|
2017-03-02 01:17:35 +01:00
|
|
|
|
#if _WIN32_WINNT < 0x0600
|
2016-12-07 12:32:54 +01:00
|
|
|
|
h_kerneldll = LoadLibraryW (L"kernel32.dll");
|
|
|
|
|
|
|
|
|
|
if (h_kerneldll == NULL)
|
|
|
|
|
goto done_query;
|
|
|
|
|
|
|
|
|
|
GetFileInformationByHandleEx =
|
|
|
|
|
(fGetFileInformationByHandleEx *) GetProcAddress (h_kerneldll, "GetFileInformationByHandleEx");
|
|
|
|
|
|
|
|
|
|
if (GetFileInformationByHandleEx == NULL)
|
|
|
|
|
goto done_query;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
info = g_try_malloc (info_size);
|
|
|
|
|
|
|
|
|
|
if (info == NULL ||
|
|
|
|
|
!GetFileInformationByHandleEx (h_fd, FileNameInfo, info, info_size))
|
|
|
|
|
goto done_query;
|
|
|
|
|
|
|
|
|
|
info->FileName[info->FileNameLength / sizeof (WCHAR)] = L'\0';
|
|
|
|
|
name = info->FileName;
|
|
|
|
|
|
|
|
|
|
length = wcslen (L"\\cygwin-");
|
|
|
|
|
if (wcsncmp (name, L"\\cygwin-", length))
|
|
|
|
|
{
|
|
|
|
|
length = wcslen (L"\\msys-");
|
|
|
|
|
if (wcsncmp (name, L"\\msys-", length))
|
|
|
|
|
goto done_query;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
name += length;
|
|
|
|
|
length = wcsspn (name, L"0123456789abcdefABCDEF");
|
|
|
|
|
if (length != 16)
|
|
|
|
|
goto done_query;
|
|
|
|
|
|
|
|
|
|
name += length;
|
|
|
|
|
length = wcslen (L"-pty");
|
|
|
|
|
if (wcsncmp (name, L"-pty", length))
|
|
|
|
|
goto done_query;
|
|
|
|
|
|
|
|
|
|
name += length;
|
|
|
|
|
length = wcsspn (name, L"0123456789");
|
|
|
|
|
if (length != 1)
|
|
|
|
|
goto done_query;
|
|
|
|
|
|
|
|
|
|
name += length;
|
|
|
|
|
length = wcslen (L"-to-master");
|
|
|
|
|
if (wcsncmp (name, L"-to-master", length))
|
|
|
|
|
{
|
|
|
|
|
length = wcslen (L"-from-master");
|
|
|
|
|
if (wcsncmp (name, L"-from-master", length))
|
|
|
|
|
goto done_query;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result = TRUE;
|
|
|
|
|
|
|
|
|
|
done_query:
|
|
|
|
|
if (info != NULL)
|
|
|
|
|
g_free (info);
|
|
|
|
|
|
|
|
|
|
/* XXX: Remove once XP support really dropped */
|
2017-03-02 01:17:35 +01:00
|
|
|
|
#if _WIN32_WINNT < 0x0600
|
2016-12-07 12:32:54 +01:00
|
|
|
|
if (h_kerneldll != NULL)
|
|
|
|
|
FreeLibrary (h_kerneldll);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2016-07-21 11:46:55 +02:00
|
|
|
|
#pragma GCC diagnostic push
|
|
|
|
|
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
|
|
|
|
|
|
2016-02-20 13:34:29 +01:00
|
|
|
|
/**
|
|
|
|
|
* g_log_structured:
|
|
|
|
|
* @log_domain: log domain, usually %G_LOG_DOMAIN
|
|
|
|
|
* @log_level: log level, either from #GLogLevelFlags, or a user-defined
|
|
|
|
|
* level
|
Redo structured logging API
It turns out that the current approach of parsing g_log_structured
varargs is unworkable, because vprintf is not guaranteed to advance
the passed-in va_list. So, we have to reshuffle the argument list
a bit; I've come up with this approach:
g_log_structured (domain, level,
key-value pairs...
"MESSAGE", format,
printf arguments);
This requires a "MESSAGE" key to always be present, and it requires
the "MESSAGE"-format pair to be last, but it avoids an extra NULL
as marker after the key-value pairs. And it can be parsed with a
single pass over the va_list, without any va_copy.
Since we have G_LOG_USE_STRUCTURED, the separate ...structured()
convenience macros are pretty pointless, and I have dropped them
for now.
2016-07-21 00:36:52 +02:00
|
|
|
|
* @...: key-value pairs of structured data to add to the log entry, followed
|
|
|
|
|
* by the key "MESSAGE", followed by a printf()-style message format,
|
|
|
|
|
* followed by parameters to insert in the format string
|
2016-02-20 13:34:29 +01:00
|
|
|
|
*
|
2016-07-21 02:38:46 +02:00
|
|
|
|
* Log a message with structured data. The message will be passed through to
|
|
|
|
|
* the log writer set by the application using g_log_set_writer_func(). If the
|
2016-02-20 13:34:29 +01:00
|
|
|
|
* message is fatal (i.e. its log level is %G_LOG_LEVEL_ERROR), the program will
|
2017-06-14 10:56:13 +02:00
|
|
|
|
* be aborted at the end of this function. If the log writer returns
|
|
|
|
|
* %G_LOG_WRITER_UNHANDLED (failure), no other fallback writers will be tried.
|
|
|
|
|
* See the documentation for #GLogWriterFunc for information on chaining
|
|
|
|
|
* writers.
|
2016-02-20 13:34:29 +01:00
|
|
|
|
*
|
|
|
|
|
* The structured data is provided as key–value pairs, where keys are UTF-8
|
|
|
|
|
* strings, and values are arbitrary pointers — typically pointing to UTF-8
|
|
|
|
|
* strings, but that is not a requirement. To pass binary (non-nul-terminated)
|
|
|
|
|
* structured data, use g_log_structured_array(). The keys for structured data
|
|
|
|
|
* should follow the [systemd journal
|
|
|
|
|
* fields](https://www.freedesktop.org/software/systemd/man/systemd.journal-fields.html)
|
2016-07-17 18:10:41 +02:00
|
|
|
|
* specification. It is suggested that custom keys are namespaced according to
|
|
|
|
|
* the code which sets them. For example, custom keys from GLib all have a
|
|
|
|
|
* `GLIB_` prefix.
|
2016-02-20 13:34:29 +01:00
|
|
|
|
*
|
|
|
|
|
* The @log_domain will be converted into a `GLIB_DOMAIN` field. @log_level will
|
2016-07-21 02:38:46 +02:00
|
|
|
|
* be converted into a
|
|
|
|
|
* [`PRIORITY`](https://www.freedesktop.org/software/systemd/man/systemd.journal-fields.html#PRIORITY=)
|
|
|
|
|
* field. The format string will have its placeholders substituted for the provided
|
|
|
|
|
* values and be converted into a
|
|
|
|
|
* [`MESSAGE`](https://www.freedesktop.org/software/systemd/man/systemd.journal-fields.html#MESSAGE=)
|
|
|
|
|
* field.
|
2016-02-20 13:34:29 +01:00
|
|
|
|
*
|
|
|
|
|
* Other fields you may commonly want to pass into this function:
|
|
|
|
|
*
|
|
|
|
|
* * [`MESSAGE_ID`](https://www.freedesktop.org/software/systemd/man/systemd.journal-fields.html#MESSAGE_ID=)
|
|
|
|
|
* * [`CODE_FILE`](https://www.freedesktop.org/software/systemd/man/systemd.journal-fields.html#CODE_FILE=)
|
|
|
|
|
* * [`CODE_LINE`](https://www.freedesktop.org/software/systemd/man/systemd.journal-fields.html#CODE_LINE=)
|
|
|
|
|
* * [`CODE_FUNC`](https://www.freedesktop.org/software/systemd/man/systemd.journal-fields.html#CODE_FUNC=)
|
|
|
|
|
* * [`ERRNO`](https://www.freedesktop.org/software/systemd/man/systemd.journal-fields.html#ERRNO=)
|
|
|
|
|
*
|
|
|
|
|
* Note that `CODE_FILE`, `CODE_LINE` and `CODE_FUNC` are automatically set by
|
2016-07-21 02:38:46 +02:00
|
|
|
|
* the logging macros, G_DEBUG_HERE(), g_message(), g_warning(), g_critical(),
|
|
|
|
|
* g_error(), etc, if the symbols `G_LOG_USE_STRUCTURED` is defined before including
|
|
|
|
|
* glib.h.
|
2016-02-20 13:34:29 +01:00
|
|
|
|
*
|
|
|
|
|
* For example:
|
2016-07-21 02:38:46 +02:00
|
|
|
|
* |[<!-- language="C" -->
|
2016-02-20 13:34:29 +01:00
|
|
|
|
* g_log_structured (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG,
|
|
|
|
|
* "MESSAGE_ID", "06d4df59e6c24647bfe69d2c27ef0b4e",
|
|
|
|
|
* "MY_APPLICATION_CUSTOM_FIELD", "some debug string",
|
Redo structured logging API
It turns out that the current approach of parsing g_log_structured
varargs is unworkable, because vprintf is not guaranteed to advance
the passed-in va_list. So, we have to reshuffle the argument list
a bit; I've come up with this approach:
g_log_structured (domain, level,
key-value pairs...
"MESSAGE", format,
printf arguments);
This requires a "MESSAGE" key to always be present, and it requires
the "MESSAGE"-format pair to be last, but it avoids an extra NULL
as marker after the key-value pairs. And it can be parsed with a
single pass over the va_list, without any va_copy.
Since we have G_LOG_USE_STRUCTURED, the separate ...structured()
convenience macros are pretty pointless, and I have dropped them
for now.
2016-07-21 00:36:52 +02:00
|
|
|
|
* "MESSAGE", "This is a debug message about pointer %p and integer %u.",
|
|
|
|
|
* some_pointer, some_integer);
|
2016-07-21 02:38:46 +02:00
|
|
|
|
* ]|
|
2016-02-20 13:34:29 +01:00
|
|
|
|
*
|
2016-07-21 02:38:46 +02:00
|
|
|
|
* Note that each `MESSAGE_ID` must be [uniquely and randomly
|
2016-02-20 13:34:29 +01:00
|
|
|
|
* generated](https://www.freedesktop.org/software/systemd/man/systemd.journal-fields.html#MESSAGE_ID=).
|
|
|
|
|
* If adding a `MESSAGE_ID`, consider shipping a [message
|
|
|
|
|
* catalog](https://www.freedesktop.org/wiki/Software/systemd/catalog/) with
|
|
|
|
|
* your software.
|
|
|
|
|
*
|
|
|
|
|
* To pass a user data pointer to the log writer function which is specific to
|
|
|
|
|
* this logging call, you must use g_log_structured_array() and pass the pointer
|
|
|
|
|
* as a field with #GLogField.length set to zero, otherwise it will be
|
|
|
|
|
* interpreted as a string.
|
|
|
|
|
*
|
|
|
|
|
* For example:
|
2016-07-21 02:38:46 +02:00
|
|
|
|
* |[<!-- language="C" -->
|
2016-02-20 13:34:29 +01:00
|
|
|
|
* const GLogField fields[] = {
|
|
|
|
|
* { "MESSAGE", "This is a debug message.", -1 },
|
|
|
|
|
* { "MESSAGE_ID", "fcfb2e1e65c3494386b74878f1abf893", -1 },
|
|
|
|
|
* { "MY_APPLICATION_CUSTOM_FIELD", "some debug string", -1 },
|
|
|
|
|
* { "MY_APPLICATION_STATE", state_object, 0 },
|
|
|
|
|
* };
|
|
|
|
|
* g_log_structured_array (G_LOG_LEVEL_DEBUG, fields, G_N_ELEMENTS (fields));
|
2016-07-21 02:38:46 +02:00
|
|
|
|
* ]|
|
2016-02-20 13:34:29 +01:00
|
|
|
|
*
|
2016-07-21 20:52:46 +02:00
|
|
|
|
* Note also that, even if no other structured fields are specified, there
|
2017-04-18 12:58:28 +02:00
|
|
|
|
* must always be a `MESSAGE` key before the format string. The `MESSAGE`-format
|
|
|
|
|
* pair has to be the last of the key-value pairs, and `MESSAGE` is the only
|
2016-07-21 20:52:46 +02:00
|
|
|
|
* field for which printf()-style formatting is supported.
|
2016-02-20 13:34:29 +01:00
|
|
|
|
*
|
|
|
|
|
* The default writer function for `stdout` and `stderr` will automatically
|
2016-07-21 02:38:46 +02:00
|
|
|
|
* append a new-line character after the message, so you should not add one
|
|
|
|
|
* manually to the format string.
|
2016-02-20 13:34:29 +01:00
|
|
|
|
*
|
|
|
|
|
* Since: 2.50
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
g_log_structured (const gchar *log_domain,
|
|
|
|
|
GLogLevelFlags log_level,
|
|
|
|
|
...)
|
|
|
|
|
{
|
Redo structured logging API
It turns out that the current approach of parsing g_log_structured
varargs is unworkable, because vprintf is not guaranteed to advance
the passed-in va_list. So, we have to reshuffle the argument list
a bit; I've come up with this approach:
g_log_structured (domain, level,
key-value pairs...
"MESSAGE", format,
printf arguments);
This requires a "MESSAGE" key to always be present, and it requires
the "MESSAGE"-format pair to be last, but it avoids an extra NULL
as marker after the key-value pairs. And it can be parsed with a
single pass over the va_list, without any va_copy.
Since we have G_LOG_USE_STRUCTURED, the separate ...structured()
convenience macros are pretty pointless, and I have dropped them
for now.
2016-07-21 00:36:52 +02:00
|
|
|
|
va_list args;
|
2016-02-20 13:34:29 +01:00
|
|
|
|
gchar buffer[1025], *message_allocated = NULL;
|
Redo structured logging API
It turns out that the current approach of parsing g_log_structured
varargs is unworkable, because vprintf is not guaranteed to advance
the passed-in va_list. So, we have to reshuffle the argument list
a bit; I've come up with this approach:
g_log_structured (domain, level,
key-value pairs...
"MESSAGE", format,
printf arguments);
This requires a "MESSAGE" key to always be present, and it requires
the "MESSAGE"-format pair to be last, but it avoids an extra NULL
as marker after the key-value pairs. And it can be parsed with a
single pass over the va_list, without any va_copy.
Since we have G_LOG_USE_STRUCTURED, the separate ...structured()
convenience macros are pretty pointless, and I have dropped them
for now.
2016-07-21 00:36:52 +02:00
|
|
|
|
const char *format;
|
|
|
|
|
const gchar *message;
|
2016-02-20 13:34:29 +01:00
|
|
|
|
gpointer p;
|
|
|
|
|
gsize n_fields, i;
|
Redo structured logging API
It turns out that the current approach of parsing g_log_structured
varargs is unworkable, because vprintf is not guaranteed to advance
the passed-in va_list. So, we have to reshuffle the argument list
a bit; I've come up with this approach:
g_log_structured (domain, level,
key-value pairs...
"MESSAGE", format,
printf arguments);
This requires a "MESSAGE" key to always be present, and it requires
the "MESSAGE"-format pair to be last, but it avoids an extra NULL
as marker after the key-value pairs. And it can be parsed with a
single pass over the va_list, without any va_copy.
Since we have G_LOG_USE_STRUCTURED, the separate ...structured()
convenience macros are pretty pointless, and I have dropped them
for now.
2016-07-21 00:36:52 +02:00
|
|
|
|
GLogField stack_fields[16];
|
|
|
|
|
GLogField *fields = stack_fields;
|
|
|
|
|
GLogField *fields_allocated = NULL;
|
|
|
|
|
GArray *array = NULL;
|
2016-02-20 13:34:29 +01:00
|
|
|
|
|
Redo structured logging API
It turns out that the current approach of parsing g_log_structured
varargs is unworkable, because vprintf is not guaranteed to advance
the passed-in va_list. So, we have to reshuffle the argument list
a bit; I've come up with this approach:
g_log_structured (domain, level,
key-value pairs...
"MESSAGE", format,
printf arguments);
This requires a "MESSAGE" key to always be present, and it requires
the "MESSAGE"-format pair to be last, but it avoids an extra NULL
as marker after the key-value pairs. And it can be parsed with a
single pass over the va_list, without any va_copy.
Since we have G_LOG_USE_STRUCTURED, the separate ...structured()
convenience macros are pretty pointless, and I have dropped them
for now.
2016-07-21 00:36:52 +02:00
|
|
|
|
va_start (args, log_level);
|
|
|
|
|
|
2016-07-22 17:01:39 +02:00
|
|
|
|
/* MESSAGE and PRIORITY are a given */
|
|
|
|
|
n_fields = 2;
|
|
|
|
|
|
|
|
|
|
if (log_domain)
|
|
|
|
|
n_fields++;
|
|
|
|
|
|
|
|
|
|
for (p = va_arg (args, gchar *), i = n_fields;
|
Redo structured logging API
It turns out that the current approach of parsing g_log_structured
varargs is unworkable, because vprintf is not guaranteed to advance
the passed-in va_list. So, we have to reshuffle the argument list
a bit; I've come up with this approach:
g_log_structured (domain, level,
key-value pairs...
"MESSAGE", format,
printf arguments);
This requires a "MESSAGE" key to always be present, and it requires
the "MESSAGE"-format pair to be last, but it avoids an extra NULL
as marker after the key-value pairs. And it can be parsed with a
single pass over the va_list, without any va_copy.
Since we have G_LOG_USE_STRUCTURED, the separate ...structured()
convenience macros are pretty pointless, and I have dropped them
for now.
2016-07-21 00:36:52 +02:00
|
|
|
|
strcmp (p, "MESSAGE") != 0;
|
|
|
|
|
p = va_arg (args, gchar *), i++)
|
|
|
|
|
{
|
|
|
|
|
GLogField field;
|
|
|
|
|
const gchar *key = p;
|
|
|
|
|
gconstpointer value = va_arg (args, gpointer);
|
|
|
|
|
|
|
|
|
|
field.key = key;
|
|
|
|
|
field.value = value;
|
|
|
|
|
field.length = -1;
|
|
|
|
|
|
|
|
|
|
if (i < 16)
|
|
|
|
|
stack_fields[i] = field;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* Don't allow dynamic allocation, since we're likely
|
|
|
|
|
* in an out-of-memory situation. For lack of a better solution,
|
|
|
|
|
* just ignore further key-value pairs.
|
|
|
|
|
*/
|
|
|
|
|
if (log_level & G_LOG_FLAG_RECURSION)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (i == 16)
|
|
|
|
|
{
|
|
|
|
|
array = g_array_sized_new (FALSE, FALSE, sizeof (GLogField), 32);
|
|
|
|
|
g_array_append_vals (array, stack_fields, 16);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_array_append_val (array, field);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
n_fields = i;
|
|
|
|
|
|
|
|
|
|
if (array)
|
|
|
|
|
fields = fields_allocated = (GLogField *) g_array_free (array, FALSE);
|
|
|
|
|
|
|
|
|
|
format = va_arg (args, gchar *);
|
2016-02-20 13:34:29 +01:00
|
|
|
|
|
|
|
|
|
if (log_level & G_LOG_FLAG_RECURSION)
|
|
|
|
|
{
|
|
|
|
|
/* we use a stack buffer of fixed size, since we're likely
|
|
|
|
|
* in an out-of-memory situation
|
|
|
|
|
*/
|
|
|
|
|
gsize size G_GNUC_UNUSED;
|
|
|
|
|
|
|
|
|
|
size = _g_vsnprintf (buffer, sizeof (buffer), format, args);
|
|
|
|
|
message = buffer;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
message = message_allocated = g_strdup_vprintf (format, args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Add MESSAGE, PRIORITY and GLIB_DOMAIN. */
|
|
|
|
|
fields[0].key = "MESSAGE";
|
|
|
|
|
fields[0].value = message;
|
|
|
|
|
fields[0].length = -1;
|
|
|
|
|
|
|
|
|
|
fields[1].key = "PRIORITY";
|
Redo structured logging API
It turns out that the current approach of parsing g_log_structured
varargs is unworkable, because vprintf is not guaranteed to advance
the passed-in va_list. So, we have to reshuffle the argument list
a bit; I've come up with this approach:
g_log_structured (domain, level,
key-value pairs...
"MESSAGE", format,
printf arguments);
This requires a "MESSAGE" key to always be present, and it requires
the "MESSAGE"-format pair to be last, but it avoids an extra NULL
as marker after the key-value pairs. And it can be parsed with a
single pass over the va_list, without any va_copy.
Since we have G_LOG_USE_STRUCTURED, the separate ...structured()
convenience macros are pretty pointless, and I have dropped them
for now.
2016-07-21 00:36:52 +02:00
|
|
|
|
fields[1].value = log_level_to_priority (log_level);
|
2016-07-23 04:56:26 +02:00
|
|
|
|
fields[1].length = -1;
|
2016-02-20 13:34:29 +01:00
|
|
|
|
|
2016-07-22 17:01:39 +02:00
|
|
|
|
if (log_domain)
|
|
|
|
|
{
|
|
|
|
|
fields[2].key = "GLIB_DOMAIN";
|
|
|
|
|
fields[2].value = log_domain;
|
|
|
|
|
fields[2].length = -1;
|
|
|
|
|
}
|
2016-02-20 13:34:29 +01:00
|
|
|
|
|
|
|
|
|
/* Log it. */
|
|
|
|
|
g_log_structured_array (log_level, fields, n_fields);
|
|
|
|
|
|
Redo structured logging API
It turns out that the current approach of parsing g_log_structured
varargs is unworkable, because vprintf is not guaranteed to advance
the passed-in va_list. So, we have to reshuffle the argument list
a bit; I've come up with this approach:
g_log_structured (domain, level,
key-value pairs...
"MESSAGE", format,
printf arguments);
This requires a "MESSAGE" key to always be present, and it requires
the "MESSAGE"-format pair to be last, but it avoids an extra NULL
as marker after the key-value pairs. And it can be parsed with a
single pass over the va_list, without any va_copy.
Since we have G_LOG_USE_STRUCTURED, the separate ...structured()
convenience macros are pretty pointless, and I have dropped them
for now.
2016-07-21 00:36:52 +02:00
|
|
|
|
g_free (fields_allocated);
|
2016-02-20 13:34:29 +01:00
|
|
|
|
g_free (message_allocated);
|
Redo structured logging API
It turns out that the current approach of parsing g_log_structured
varargs is unworkable, because vprintf is not guaranteed to advance
the passed-in va_list. So, we have to reshuffle the argument list
a bit; I've come up with this approach:
g_log_structured (domain, level,
key-value pairs...
"MESSAGE", format,
printf arguments);
This requires a "MESSAGE" key to always be present, and it requires
the "MESSAGE"-format pair to be last, but it avoids an extra NULL
as marker after the key-value pairs. And it can be parsed with a
single pass over the va_list, without any va_copy.
Since we have G_LOG_USE_STRUCTURED, the separate ...structured()
convenience macros are pretty pointless, and I have dropped them
for now.
2016-07-21 00:36:52 +02:00
|
|
|
|
|
2016-02-20 13:34:29 +01:00
|
|
|
|
va_end (args);
|
|
|
|
|
}
|
|
|
|
|
|
2016-09-09 14:06:05 +02:00
|
|
|
|
/**
|
|
|
|
|
* g_log_variant:
|
2016-10-29 03:29:02 +02:00
|
|
|
|
* @log_domain: (nullable): log domain, usually %G_LOG_DOMAIN
|
2016-09-09 14:06:05 +02:00
|
|
|
|
* @log_level: log level, either from #GLogLevelFlags, or a user-defined
|
|
|
|
|
* level
|
|
|
|
|
* @fields: a dictionary (#GVariant of the type %G_VARIANT_TYPE_VARDICT)
|
|
|
|
|
* containing the key-value pairs of message data.
|
|
|
|
|
*
|
|
|
|
|
* Log a message with structured data, accepting the data within a #GVariant. This
|
|
|
|
|
* version is especially useful for use in other languages, via introspection.
|
|
|
|
|
*
|
|
|
|
|
* The only mandatory item in the @fields dictionary is the "MESSAGE" which must
|
|
|
|
|
* contain the text shown to the user.
|
|
|
|
|
*
|
|
|
|
|
* The values in the @fields dictionary are likely to be of type String
|
|
|
|
|
* (#G_VARIANT_TYPE_STRING). Array of bytes (#G_VARIANT_TYPE_BYTESTRING) is also
|
|
|
|
|
* supported. In this case the message is handled as binary and will be forwarded
|
|
|
|
|
* to the log writer as such. The size of the array should not be higher than
|
|
|
|
|
* %G_MAXSSIZE. Otherwise it will be truncated to this size. For other types
|
|
|
|
|
* g_variant_print() will be used to convert the value into a string.
|
|
|
|
|
*
|
|
|
|
|
* For more details on its usage and about the parameters, see g_log_structured().
|
|
|
|
|
*
|
|
|
|
|
* Since: 2.50
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
g_log_variant (const gchar *log_domain,
|
|
|
|
|
GLogLevelFlags log_level,
|
|
|
|
|
GVariant *fields)
|
|
|
|
|
{
|
|
|
|
|
GVariantIter iter;
|
|
|
|
|
GVariant *value;
|
|
|
|
|
gchar *key;
|
|
|
|
|
GArray *fields_array;
|
|
|
|
|
GLogField field;
|
|
|
|
|
GSList *values_list, *print_list;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (g_variant_is_of_type (fields, G_VARIANT_TYPE_VARDICT));
|
|
|
|
|
|
|
|
|
|
values_list = print_list = NULL;
|
|
|
|
|
fields_array = g_array_new (FALSE, FALSE, sizeof (GLogField));
|
|
|
|
|
|
|
|
|
|
field.key = "PRIORITY";
|
|
|
|
|
field.value = log_level_to_priority (log_level);
|
|
|
|
|
field.length = -1;
|
|
|
|
|
g_array_append_val (fields_array, field);
|
|
|
|
|
|
|
|
|
|
if (log_domain)
|
|
|
|
|
{
|
|
|
|
|
field.key = "GLIB_DOMAIN";
|
|
|
|
|
field.value = log_domain;
|
|
|
|
|
field.length = -1;
|
|
|
|
|
g_array_append_val (fields_array, field);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_variant_iter_init (&iter, fields);
|
|
|
|
|
while (g_variant_iter_next (&iter, "{&sv}", &key, &value))
|
|
|
|
|
{
|
|
|
|
|
gboolean defer_unref = TRUE;
|
|
|
|
|
|
|
|
|
|
field.key = key;
|
|
|
|
|
field.length = -1;
|
|
|
|
|
|
|
|
|
|
if (g_variant_is_of_type (value, G_VARIANT_TYPE_STRING))
|
|
|
|
|
{
|
|
|
|
|
field.value = g_variant_get_string (value, NULL);
|
|
|
|
|
}
|
|
|
|
|
else if (g_variant_is_of_type (value, G_VARIANT_TYPE_BYTESTRING))
|
|
|
|
|
{
|
|
|
|
|
gsize s;
|
|
|
|
|
field.value = g_variant_get_fixed_array (value, &s, sizeof (guchar));
|
|
|
|
|
if (G_LIKELY (s <= G_MAXSSIZE))
|
|
|
|
|
{
|
|
|
|
|
field.length = s;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_g_fprintf (stderr,
|
|
|
|
|
"Byte array too large (%" G_GSIZE_FORMAT " bytes)"
|
|
|
|
|
" passed to g_log_variant(). Truncating to " G_STRINGIFY (G_MAXSSIZE)
|
|
|
|
|
" bytes.", s);
|
|
|
|
|
field.length = G_MAXSSIZE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
char *s = g_variant_print (value, FALSE);
|
|
|
|
|
field.value = s;
|
|
|
|
|
print_list = g_slist_prepend (print_list, s);
|
|
|
|
|
defer_unref = FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_array_append_val (fields_array, field);
|
|
|
|
|
|
|
|
|
|
if (G_LIKELY (defer_unref))
|
|
|
|
|
values_list = g_slist_prepend (values_list, value);
|
|
|
|
|
else
|
|
|
|
|
g_variant_unref (value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Log it. */
|
|
|
|
|
g_log_structured_array (log_level, (GLogField *) fields_array->data, fields_array->len);
|
|
|
|
|
|
|
|
|
|
g_array_free (fields_array, TRUE);
|
|
|
|
|
g_slist_free_full (values_list, (GDestroyNotify) g_variant_unref);
|
|
|
|
|
g_slist_free_full (print_list, g_free);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2016-07-21 11:46:55 +02:00
|
|
|
|
#pragma GCC diagnostic pop
|
|
|
|
|
|
2016-02-20 13:34:29 +01:00
|
|
|
|
static GLogWriterOutput _g_log_writer_fallback (GLogLevelFlags log_level,
|
|
|
|
|
const GLogField *fields,
|
|
|
|
|
gsize n_fields,
|
|
|
|
|
gpointer user_data);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* g_log_structured_array:
|
|
|
|
|
* @log_level: log level, either from #GLogLevelFlags, or a user-defined
|
|
|
|
|
* level
|
|
|
|
|
* @fields: (array length=n_fields): key–value pairs of structured data to add
|
|
|
|
|
* to the log message
|
|
|
|
|
* @n_fields: number of elements in the @fields array
|
|
|
|
|
*
|
|
|
|
|
* Log a message with structured data. The message will be passed through to the
|
|
|
|
|
* log writer set by the application using g_log_set_writer_func(). If the
|
|
|
|
|
* message is fatal (i.e. its log level is %G_LOG_LEVEL_ERROR), the program will
|
|
|
|
|
* be aborted at the end of this function.
|
|
|
|
|
*
|
|
|
|
|
* See g_log_structured() for more documentation.
|
|
|
|
|
*
|
|
|
|
|
* This assumes that @log_level is already present in @fields (typically as the
|
|
|
|
|
* `PRIORITY` field).
|
|
|
|
|
*
|
|
|
|
|
* Since: 2.50
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
g_log_structured_array (GLogLevelFlags log_level,
|
|
|
|
|
const GLogField *fields,
|
|
|
|
|
gsize n_fields)
|
|
|
|
|
{
|
|
|
|
|
GLogWriterFunc writer_func;
|
|
|
|
|
gpointer writer_user_data;
|
|
|
|
|
gboolean recursion;
|
|
|
|
|
guint depth;
|
|
|
|
|
|
|
|
|
|
if (n_fields == 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
/* Check for recursion and look up the writer function. */
|
|
|
|
|
depth = GPOINTER_TO_UINT (g_private_get (&g_log_structured_depth));
|
|
|
|
|
recursion = (depth > 0);
|
|
|
|
|
|
|
|
|
|
g_mutex_lock (&g_messages_lock);
|
|
|
|
|
|
|
|
|
|
writer_func = recursion ? _g_log_writer_fallback : log_writer_func;
|
|
|
|
|
writer_user_data = log_writer_user_data;
|
|
|
|
|
|
|
|
|
|
g_mutex_unlock (&g_messages_lock);
|
|
|
|
|
|
|
|
|
|
/* Write the log entry. */
|
|
|
|
|
g_private_set (&g_log_structured_depth, GUINT_TO_POINTER (++depth));
|
|
|
|
|
|
|
|
|
|
g_assert (writer_func != NULL);
|
|
|
|
|
writer_func (log_level, fields, n_fields, writer_user_data);
|
|
|
|
|
|
|
|
|
|
g_private_set (&g_log_structured_depth, GUINT_TO_POINTER (--depth));
|
|
|
|
|
|
|
|
|
|
/* Abort if the message was fatal. */
|
|
|
|
|
if (log_level & G_LOG_FATAL_MASK)
|
|
|
|
|
_g_log_abort (!(log_level & G_LOG_FLAG_RECURSION));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* g_log_set_writer_func:
|
|
|
|
|
* @func: log writer function, which must not be %NULL
|
|
|
|
|
* @user_data: (closure func): user data to pass to @func
|
|
|
|
|
* @user_data_free: (destroy func): function to free @user_data once it’s
|
|
|
|
|
* finished with, if non-%NULL
|
|
|
|
|
*
|
|
|
|
|
* Set a writer function which will be called to format and write out each log
|
|
|
|
|
* message. Each program should set a writer function, or the default writer
|
|
|
|
|
* (g_log_writer_default()) will be used.
|
|
|
|
|
*
|
|
|
|
|
* Libraries **must not** call this function — only programs are allowed to
|
|
|
|
|
* install a writer function, as there must be a single, central point where
|
|
|
|
|
* log messages are formatted and outputted.
|
|
|
|
|
*
|
|
|
|
|
* There can only be one writer function. It is an error to set more than one.
|
|
|
|
|
*
|
|
|
|
|
* Since: 2.50
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
g_log_set_writer_func (GLogWriterFunc func,
|
|
|
|
|
gpointer user_data,
|
|
|
|
|
GDestroyNotify user_data_free)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (func != NULL);
|
|
|
|
|
|
|
|
|
|
g_mutex_lock (&g_messages_lock);
|
|
|
|
|
log_writer_func = func;
|
|
|
|
|
log_writer_user_data = user_data;
|
|
|
|
|
log_writer_user_data_free = user_data_free;
|
|
|
|
|
g_mutex_unlock (&g_messages_lock);
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-15 11:47:39 +01:00
|
|
|
|
/**
|
|
|
|
|
* g_log_writer_supports_color:
|
|
|
|
|
* @output_fd: output file descriptor to check
|
|
|
|
|
*
|
|
|
|
|
* Check whether the given @output_fd file descriptor supports ANSI color
|
|
|
|
|
* escape sequences. If so, they can safely be used when formatting log
|
|
|
|
|
* messages.
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE if ANSI color escapes are supported, %FALSE otherwise
|
|
|
|
|
* Since: 2.50
|
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
g_log_writer_supports_color (gint output_fd)
|
|
|
|
|
{
|
2016-12-07 12:32:54 +01:00
|
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
|
gboolean result = FALSE;
|
|
|
|
|
|
|
|
|
|
#if (defined (_MSC_VER) && _MSC_VER >= 1400)
|
|
|
|
|
_invalid_parameter_handler oldHandler, newHandler;
|
|
|
|
|
int prev_report_mode = 0;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
2016-03-15 11:47:39 +01:00
|
|
|
|
g_return_val_if_fail (output_fd >= 0, FALSE);
|
|
|
|
|
|
|
|
|
|
/* FIXME: This check could easily be expanded in future to be more robust
|
|
|
|
|
* against different types of terminal, which still vary in their color
|
2016-12-02 06:45:38 +01:00
|
|
|
|
* support. cmd.exe on Windows, for example, supports ANSI colors only
|
|
|
|
|
* from Windows 10 onwards; bash on Windows has always supported ANSI colors.
|
|
|
|
|
* The Windows 10 color support is supported on:
|
|
|
|
|
* -Output in the cmd.exe, MSYS/Cygwin standard consoles.
|
|
|
|
|
* -Output in the cmd.exe, MSYS/Cygwin piped to the less program.
|
|
|
|
|
* but not:
|
|
|
|
|
* -Output in Cygwin via mintty (https://github.com/mintty/mintty/issues/482)
|
|
|
|
|
* -Color code output when output redirected to file (i.e. program 2> some.txt)
|
2016-03-15 11:47:39 +01:00
|
|
|
|
*
|
|
|
|
|
* On UNIX systems, we probably want to use the functions from terminfo to
|
|
|
|
|
* work out whether colors are supported.
|
|
|
|
|
*
|
|
|
|
|
* Some examples:
|
|
|
|
|
* - https://github.com/chalk/supports-color/blob/9434c93918301a6b47faa01999482adfbf1b715c/index.js#L61
|
|
|
|
|
* - http://stackoverflow.com/questions/16755142/how-to-make-win32-console-recognize-ansi-vt100-escape-sequences
|
|
|
|
|
* - http://blog.mmediasys.com/2010/11/24/we-all-love-colors/
|
|
|
|
|
* - http://unix.stackexchange.com/questions/198794/where-does-the-term-environment-variable-default-get-set
|
|
|
|
|
*/
|
2016-12-02 06:45:38 +01:00
|
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
|
|
|
|
|
|
#if (defined (_MSC_VER) && _MSC_VER >= 1400)
|
2016-12-07 12:32:54 +01:00
|
|
|
|
/* Set up our empty invalid parameter handler, for isatty(),
|
|
|
|
|
* in case of bad fd's passed in for isatty(), so that
|
|
|
|
|
* msvcrt80.dll+ won't abort the program
|
|
|
|
|
*/
|
|
|
|
|
newHandler = myInvalidParameterHandler;
|
|
|
|
|
oldHandler = _set_invalid_parameter_handler (newHandler);
|
2016-12-02 06:45:38 +01:00
|
|
|
|
|
2016-12-07 12:32:54 +01:00
|
|
|
|
/* Disable the message box for assertions. */
|
|
|
|
|
prev_report_mode = _CrtSetReportMode(_CRT_ASSERT, 0);
|
2016-12-02 06:45:38 +01:00
|
|
|
|
#endif
|
|
|
|
|
|
2016-12-07 12:32:54 +01:00
|
|
|
|
if (g_win32_check_windows_version (10, 0, 0, G_WIN32_OS_ANY))
|
|
|
|
|
{
|
|
|
|
|
HANDLE h_output;
|
|
|
|
|
DWORD dw_mode;
|
2016-12-02 06:45:38 +01:00
|
|
|
|
|
2016-12-07 12:32:54 +01:00
|
|
|
|
if (_isatty (output_fd))
|
|
|
|
|
{
|
|
|
|
|
h_output = (HANDLE) _get_osfhandle (output_fd);
|
2016-12-02 06:45:38 +01:00
|
|
|
|
|
2016-12-07 12:32:54 +01:00
|
|
|
|
if (!GetConsoleMode (h_output, &dw_mode))
|
|
|
|
|
goto reset_invalid_param_handler;
|
2016-12-02 06:45:38 +01:00
|
|
|
|
|
2016-12-07 12:32:54 +01:00
|
|
|
|
if (dw_mode & ENABLE_VIRTUAL_TERMINAL_PROCESSING)
|
|
|
|
|
result = TRUE;
|
2016-12-02 06:45:38 +01:00
|
|
|
|
|
2016-12-07 12:32:54 +01:00
|
|
|
|
if (!SetConsoleMode (h_output, dw_mode | ENABLE_VIRTUAL_TERMINAL_PROCESSING))
|
|
|
|
|
goto reset_invalid_param_handler;
|
2016-12-02 06:45:38 +01:00
|
|
|
|
|
2016-12-07 12:32:54 +01:00
|
|
|
|
result = TRUE;
|
|
|
|
|
}
|
2016-12-02 06:45:38 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* FIXME: Support colored outputs for structured logs for pre-Windows 10,
|
|
|
|
|
* perhaps using WriteConsoleOutput or SetConsoleTextAttribute
|
2016-12-07 12:32:54 +01:00
|
|
|
|
* (bug 775468), on standard Windows consoles, such as cmd.exe
|
2016-12-02 06:45:38 +01:00
|
|
|
|
*/
|
2016-12-07 12:32:54 +01:00
|
|
|
|
if (!result)
|
|
|
|
|
result = win32_is_pipe_tty (output_fd);
|
|
|
|
|
|
|
|
|
|
reset_invalid_param_handler:
|
|
|
|
|
#if defined (_MSC_VER) && (_MSC_VER >= 1400)
|
|
|
|
|
_CrtSetReportMode(_CRT_ASSERT, prev_report_mode);
|
|
|
|
|
_set_invalid_parameter_handler (oldHandler);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
return result;
|
2016-12-02 06:45:38 +01:00
|
|
|
|
#else
|
2016-03-15 11:47:39 +01:00
|
|
|
|
return isatty (output_fd);
|
2016-12-02 06:45:38 +01:00
|
|
|
|
#endif
|
2016-03-15 11:47:39 +01:00
|
|
|
|
}
|
|
|
|
|
|
2016-12-05 11:10:48 +01:00
|
|
|
|
#if defined(__linux__) && !defined(__BIONIC__)
|
2016-07-23 04:56:26 +02:00
|
|
|
|
static int journal_fd = -1;
|
|
|
|
|
|
2016-07-25 15:45:37 +02:00
|
|
|
|
#ifndef SOCK_CLOEXEC
|
|
|
|
|
#define SOCK_CLOEXEC 0
|
|
|
|
|
#else
|
|
|
|
|
#define HAVE_SOCK_CLOEXEC 1
|
|
|
|
|
#endif
|
|
|
|
|
|
2016-07-23 04:56:26 +02:00
|
|
|
|
static void
|
|
|
|
|
open_journal (void)
|
|
|
|
|
{
|
2016-07-25 15:45:37 +02:00
|
|
|
|
if ((journal_fd = socket (AF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC, 0)) < 0)
|
2016-07-23 04:56:26 +02:00
|
|
|
|
return;
|
|
|
|
|
|
2016-07-25 15:45:37 +02:00
|
|
|
|
#ifndef HAVE_SOCK_CLOEXEC
|
2016-07-23 04:56:26 +02:00
|
|
|
|
if (fcntl (journal_fd, F_SETFD, FD_CLOEXEC) < 0)
|
|
|
|
|
{
|
|
|
|
|
close (journal_fd);
|
|
|
|
|
journal_fd = -1;
|
|
|
|
|
}
|
2016-07-25 15:45:37 +02:00
|
|
|
|
#endif
|
2016-07-23 04:56:26 +02:00
|
|
|
|
}
|
2016-07-26 06:32:42 +02:00
|
|
|
|
#endif
|
2016-07-23 04:56:26 +02:00
|
|
|
|
|
2016-02-20 13:34:29 +01:00
|
|
|
|
/**
|
|
|
|
|
* g_log_writer_is_journald:
|
|
|
|
|
* @output_fd: output file descriptor to check
|
|
|
|
|
*
|
|
|
|
|
* Check whether the given @output_fd file descriptor is a connection to the
|
|
|
|
|
* systemd journal, or something else (like a log file or `stdout` or
|
|
|
|
|
* `stderr`).
|
|
|
|
|
*
|
glog: fix crash on Linux without stderr stream
0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:58
1 0xb67c43f0 in __GI_abort () at abort.c:89
2 0xb69ee9d8 in _g_log_abort (breakpoint=2, breakpoint@entry=1) at gmessages.c:548
3 0xb69ef692 in g_logv (log_domain=0xb6a1dfc8 "GLib", log_level=-1254563840, log_level@entry=G_LOG_LEVEL_CRITICAL, format=format@entry=0xb6a26a48 "%s: assertion '%s' failed", args=..., args@entry=...) at gmessages.c:1357
4 0xb69ef728 in g_log (log_domain=<optimized out>, log_level=log_level@entry=G_LOG_LEVEL_CRITICAL, format=0xb6a26a48 "%s: assertion '%s' failed") at gmessages.c:1398
5 0xb69efa5a in g_return_if_fail_warning (log_domain=<optimized out>, pretty_function=<optimized out>, expression=<optimized out>) at gmessages.c:2687
6 0xb69efe7c in g_log_writer_is_journald (output_fd=-1) at gmessages.c:2122
7 0xb69f02a2 in g_log_writer_default (log_level=G_LOG_LEVEL_CRITICAL, fields=0xbedc9d00, n_fields=4, user_data=0x0) at gmessages.c:2584
8 0xb69ef21a in g_log_structured_array (log_level=G_LOG_LEVEL_CRITICAL, fields=0xbedc9d00, n_fields=4) at gmessages.c:1933
9 0xb69ef47e in g_log_default_handler (log_domain=0xb6a1dfc8 "GLib", log_level=G_LOG_LEVEL_CRITICAL, message=<optimized out>, unused_data=<optimized out>) at gmessages.c:3036
10 0xb69ef5fc in g_logv (log_domain=0xb6a1dfc8 "GLib", log_level=log_level@entry=G_LOG_LEVEL_CRITICAL, format=format@entry=0xb6a26a48 "%s: assertion '%s' failed", args=..., args@entry=...) at gmessages.c:1336
11 0xb69ef728 in g_log (log_domain=<optimized out>, log_level=log_level@entry=G_LOG_LEVEL_CRITICAL, format=0xb6a26a48 "%s: assertion '%s' failed") at gmessages.c:1398
12 0xb69efa5a in g_return_if_fail_warning (log_domain=<optimized out>, pretty_function=<optimized out>, expression=<optimized out>) at gmessages.c:2687
If stderr is not associated with an output stream, the fileno(stderr) returned is -1.
So, g_return_if_fail_warning is recursively called and the abort occurs on the second call.
Modified by Philip Withnall to include mention this in the
documentation.
https://bugzilla.gnome.org/show_bug.cgi?id=786452
2017-08-18 06:42:44 +02:00
|
|
|
|
* Invalid file descriptors are accepted and return %FALSE, which allows for
|
|
|
|
|
* the following construct without needing any additional error handling:
|
|
|
|
|
* |[<!-- language="C" -->
|
|
|
|
|
* is_journald = g_log_writer_is_journald (fileno (stderr));
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
2016-02-20 13:34:29 +01:00
|
|
|
|
* Returns: %TRUE if @output_fd points to the journal, %FALSE otherwise
|
|
|
|
|
* Since: 2.50
|
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
g_log_writer_is_journald (gint output_fd)
|
|
|
|
|
{
|
2016-12-05 11:10:48 +01:00
|
|
|
|
#if defined(__linux__) && !defined(__BIONIC__)
|
2016-02-20 13:34:29 +01:00
|
|
|
|
/* FIXME: Use the new journal API for detecting whether we’re writing to the
|
|
|
|
|
* journal. See: https://github.com/systemd/systemd/issues/2473
|
|
|
|
|
*/
|
|
|
|
|
static gsize initialized;
|
2016-07-21 01:27:17 +02:00
|
|
|
|
static gboolean fd_is_journal = FALSE;
|
2016-02-20 13:34:29 +01:00
|
|
|
|
|
glog: fix crash on Linux without stderr stream
0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:58
1 0xb67c43f0 in __GI_abort () at abort.c:89
2 0xb69ee9d8 in _g_log_abort (breakpoint=2, breakpoint@entry=1) at gmessages.c:548
3 0xb69ef692 in g_logv (log_domain=0xb6a1dfc8 "GLib", log_level=-1254563840, log_level@entry=G_LOG_LEVEL_CRITICAL, format=format@entry=0xb6a26a48 "%s: assertion '%s' failed", args=..., args@entry=...) at gmessages.c:1357
4 0xb69ef728 in g_log (log_domain=<optimized out>, log_level=log_level@entry=G_LOG_LEVEL_CRITICAL, format=0xb6a26a48 "%s: assertion '%s' failed") at gmessages.c:1398
5 0xb69efa5a in g_return_if_fail_warning (log_domain=<optimized out>, pretty_function=<optimized out>, expression=<optimized out>) at gmessages.c:2687
6 0xb69efe7c in g_log_writer_is_journald (output_fd=-1) at gmessages.c:2122
7 0xb69f02a2 in g_log_writer_default (log_level=G_LOG_LEVEL_CRITICAL, fields=0xbedc9d00, n_fields=4, user_data=0x0) at gmessages.c:2584
8 0xb69ef21a in g_log_structured_array (log_level=G_LOG_LEVEL_CRITICAL, fields=0xbedc9d00, n_fields=4) at gmessages.c:1933
9 0xb69ef47e in g_log_default_handler (log_domain=0xb6a1dfc8 "GLib", log_level=G_LOG_LEVEL_CRITICAL, message=<optimized out>, unused_data=<optimized out>) at gmessages.c:3036
10 0xb69ef5fc in g_logv (log_domain=0xb6a1dfc8 "GLib", log_level=log_level@entry=G_LOG_LEVEL_CRITICAL, format=format@entry=0xb6a26a48 "%s: assertion '%s' failed", args=..., args@entry=...) at gmessages.c:1336
11 0xb69ef728 in g_log (log_domain=<optimized out>, log_level=log_level@entry=G_LOG_LEVEL_CRITICAL, format=0xb6a26a48 "%s: assertion '%s' failed") at gmessages.c:1398
12 0xb69efa5a in g_return_if_fail_warning (log_domain=<optimized out>, pretty_function=<optimized out>, expression=<optimized out>) at gmessages.c:2687
If stderr is not associated with an output stream, the fileno(stderr) returned is -1.
So, g_return_if_fail_warning is recursively called and the abort occurs on the second call.
Modified by Philip Withnall to include mention this in the
documentation.
https://bugzilla.gnome.org/show_bug.cgi?id=786452
2017-08-18 06:42:44 +02:00
|
|
|
|
if (output_fd < 0)
|
|
|
|
|
return FALSE;
|
2016-02-20 13:34:29 +01:00
|
|
|
|
|
|
|
|
|
if (g_once_init_enter (&initialized))
|
|
|
|
|
{
|
2016-07-21 01:27:17 +02:00
|
|
|
|
struct sockaddr_storage addr;
|
|
|
|
|
socklen_t addr_len = sizeof(addr);
|
|
|
|
|
int err = getpeername (output_fd, (struct sockaddr *) &addr, &addr_len);
|
|
|
|
|
if (err == 0 && addr.ss_family == AF_UNIX)
|
|
|
|
|
fd_is_journal = g_str_has_prefix (((struct sockaddr_un *)&addr)->sun_path,
|
|
|
|
|
"/run/systemd/journal/");
|
2016-07-23 04:56:26 +02:00
|
|
|
|
|
2016-02-20 13:34:29 +01:00
|
|
|
|
g_once_init_leave (&initialized, TRUE);
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-21 01:27:17 +02:00
|
|
|
|
return fd_is_journal;
|
2016-07-26 06:32:42 +02:00
|
|
|
|
#else
|
|
|
|
|
return FALSE;
|
|
|
|
|
#endif
|
2016-02-20 13:34:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void escape_string (GString *string);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* g_log_writer_format_fields:
|
|
|
|
|
* @log_level: log level, either from #GLogLevelFlags, or a user-defined
|
|
|
|
|
* level
|
|
|
|
|
* @fields: (array length=n_fields): key–value pairs of structured data forming
|
|
|
|
|
* the log message
|
|
|
|
|
* @n_fields: number of elements in the @fields array
|
2016-03-15 11:47:39 +01:00
|
|
|
|
* @use_color: %TRUE to use ANSI color escape sequences when formatting the
|
|
|
|
|
* message, %FALSE to not
|
2016-02-20 13:34:29 +01:00
|
|
|
|
*
|
|
|
|
|
* Format a structured log message as a string suitable for outputting to the
|
|
|
|
|
* terminal (or elsewhere). This will include the values of all fields it knows
|
|
|
|
|
* how to interpret, which includes `MESSAGE` and `GLIB_DOMAIN` (see the
|
|
|
|
|
* documentation for g_log_structured()). It does not include values from
|
|
|
|
|
* unknown fields.
|
|
|
|
|
*
|
|
|
|
|
* The returned string does **not** have a trailing new-line character. It is
|
|
|
|
|
* encoded in the character set of the current locale, which is not necessarily
|
|
|
|
|
* UTF-8.
|
|
|
|
|
*
|
|
|
|
|
* Returns: (transfer full): string containing the formatted log message, in
|
|
|
|
|
* the character set of the current locale
|
|
|
|
|
* Since: 2.50
|
|
|
|
|
*/
|
|
|
|
|
gchar *
|
|
|
|
|
g_log_writer_format_fields (GLogLevelFlags log_level,
|
|
|
|
|
const GLogField *fields,
|
2016-03-15 11:47:39 +01:00
|
|
|
|
gsize n_fields,
|
|
|
|
|
gboolean use_color)
|
2016-02-20 13:34:29 +01:00
|
|
|
|
{
|
|
|
|
|
gsize i;
|
|
|
|
|
const gchar *message = NULL;
|
|
|
|
|
const gchar *log_domain = NULL;
|
|
|
|
|
gchar level_prefix[STRING_BUFFER_SIZE];
|
|
|
|
|
GString *gstring;
|
2016-08-13 17:34:58 +02:00
|
|
|
|
gint64 now;
|
|
|
|
|
time_t now_secs;
|
|
|
|
|
struct tm *now_tm;
|
|
|
|
|
gchar time_buf[128];
|
2016-02-20 13:34:29 +01:00
|
|
|
|
|
|
|
|
|
/* Extract some common fields. */
|
|
|
|
|
for (i = 0; (message == NULL || log_domain == NULL) && i < n_fields; i++)
|
|
|
|
|
{
|
|
|
|
|
const GLogField *field = &fields[i];
|
|
|
|
|
|
|
|
|
|
if (g_strcmp0 (field->key, "MESSAGE") == 0)
|
|
|
|
|
message = field->value;
|
|
|
|
|
else if (g_strcmp0 (field->key, "GLIB_DOMAIN") == 0)
|
|
|
|
|
log_domain = field->value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Format things. */
|
2016-03-15 11:47:39 +01:00
|
|
|
|
mklevel_prefix (level_prefix, log_level, use_color);
|
2016-02-20 13:34:29 +01:00
|
|
|
|
|
|
|
|
|
gstring = g_string_new (NULL);
|
|
|
|
|
if (log_level & ALERT_LEVELS)
|
|
|
|
|
g_string_append (gstring, "\n");
|
|
|
|
|
if (!log_domain)
|
|
|
|
|
g_string_append (gstring, "** ");
|
|
|
|
|
|
|
|
|
|
if ((g_log_msg_prefix & (log_level & G_LOG_LEVEL_MASK)) ==
|
|
|
|
|
(log_level & G_LOG_LEVEL_MASK))
|
|
|
|
|
{
|
|
|
|
|
const gchar *prg_name = g_get_prgname ();
|
|
|
|
|
gulong pid = getpid ();
|
|
|
|
|
|
|
|
|
|
if (prg_name == NULL)
|
|
|
|
|
g_string_append_printf (gstring, "(process:%lu): ", pid);
|
|
|
|
|
else
|
|
|
|
|
g_string_append_printf (gstring, "(%s:%lu): ", prg_name, pid);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (log_domain != NULL)
|
|
|
|
|
{
|
|
|
|
|
g_string_append (gstring, log_domain);
|
|
|
|
|
g_string_append_c (gstring, '-');
|
|
|
|
|
}
|
|
|
|
|
g_string_append (gstring, level_prefix);
|
|
|
|
|
|
|
|
|
|
g_string_append (gstring, ": ");
|
2016-08-13 17:34:58 +02:00
|
|
|
|
|
|
|
|
|
/* Timestamp */
|
|
|
|
|
now = g_get_real_time ();
|
2017-12-02 12:39:12 +01:00
|
|
|
|
now_secs = (time_t) (now / 1000000);
|
2016-08-13 17:34:58 +02:00
|
|
|
|
now_tm = localtime (&now_secs);
|
|
|
|
|
strftime (time_buf, sizeof (time_buf), "%H:%M:%S", now_tm);
|
|
|
|
|
|
|
|
|
|
g_string_append_printf (gstring, "%s%s.%03d%s: ",
|
|
|
|
|
use_color ? "\033[34m" : "",
|
|
|
|
|
time_buf, (gint) ((now / 1000) % 1000),
|
|
|
|
|
color_reset (use_color));
|
|
|
|
|
|
2016-02-20 13:34:29 +01:00
|
|
|
|
if (message == NULL)
|
|
|
|
|
{
|
|
|
|
|
g_string_append (gstring, "(NULL) message");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
GString *msg;
|
|
|
|
|
const gchar *charset;
|
|
|
|
|
|
|
|
|
|
msg = g_string_new (message);
|
|
|
|
|
escape_string (msg);
|
|
|
|
|
|
|
|
|
|
if (g_get_charset (&charset))
|
|
|
|
|
{
|
|
|
|
|
/* charset is UTF-8 already */
|
|
|
|
|
g_string_append (gstring, msg->str);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
gchar *lstring = strdup_convert (msg->str, charset);
|
|
|
|
|
g_string_append (gstring, lstring);
|
|
|
|
|
g_free (lstring);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_string_free (msg, TRUE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return g_string_free (gstring, FALSE);
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-09 12:47:23 +02:00
|
|
|
|
/* Enable support for the journal if we're on a recent enough Linux */
|
|
|
|
|
#if defined(__linux__) && !defined(__BIONIC__) && defined(HAVE_MKOSTEMP) && defined(O_CLOEXEC)
|
|
|
|
|
#define ENABLE_JOURNAL_SENDV
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef ENABLE_JOURNAL_SENDV
|
2016-07-23 04:56:26 +02:00
|
|
|
|
static int
|
|
|
|
|
journal_sendv (struct iovec *iov,
|
|
|
|
|
gsize iovlen)
|
|
|
|
|
{
|
|
|
|
|
int buf_fd = -1;
|
|
|
|
|
struct msghdr mh;
|
|
|
|
|
struct sockaddr_un sa;
|
|
|
|
|
union {
|
|
|
|
|
struct cmsghdr cmsghdr;
|
|
|
|
|
guint8 buf[CMSG_SPACE(sizeof(int))];
|
|
|
|
|
} control;
|
|
|
|
|
struct cmsghdr *cmsg;
|
|
|
|
|
char path[] = "/dev/shm/journal.XXXXXX";
|
|
|
|
|
|
2016-08-04 11:35:27 +02:00
|
|
|
|
if (journal_fd < 0)
|
|
|
|
|
open_journal ();
|
|
|
|
|
|
2016-07-23 04:56:26 +02:00
|
|
|
|
if (journal_fd < 0)
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
memset (&sa, 0, sizeof (sa));
|
|
|
|
|
sa.sun_family = AF_UNIX;
|
|
|
|
|
if (g_strlcpy (sa.sun_path, "/run/systemd/journal/socket", sizeof (sa.sun_path)) >= sizeof (sa.sun_path))
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
memset (&mh, 0, sizeof (mh));
|
|
|
|
|
mh.msg_name = &sa;
|
|
|
|
|
mh.msg_namelen = offsetof (struct sockaddr_un, sun_path) + strlen (sa.sun_path);
|
|
|
|
|
mh.msg_iov = iov;
|
|
|
|
|
mh.msg_iovlen = iovlen;
|
|
|
|
|
|
2016-07-25 16:25:40 +02:00
|
|
|
|
retry:
|
2016-07-23 04:56:26 +02:00
|
|
|
|
if (sendmsg (journal_fd, &mh, MSG_NOSIGNAL) >= 0)
|
|
|
|
|
return 0;
|
|
|
|
|
|
2016-07-25 16:25:40 +02:00
|
|
|
|
if (errno == EINTR)
|
|
|
|
|
goto retry;
|
|
|
|
|
|
2016-07-23 04:56:26 +02:00
|
|
|
|
if (errno != EMSGSIZE && errno != ENOBUFS)
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
/* Message was too large, so dump to temporary file
|
|
|
|
|
* and pass an FD to the journal
|
|
|
|
|
*/
|
|
|
|
|
if ((buf_fd = mkostemp (path, O_CLOEXEC|O_RDWR)) < 0)
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
|
|
if (unlink (path) < 0)
|
|
|
|
|
{
|
|
|
|
|
close (buf_fd);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (writev (buf_fd, iov, iovlen) < 0)
|
|
|
|
|
{
|
|
|
|
|
close (buf_fd);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mh.msg_iov = NULL;
|
|
|
|
|
mh.msg_iovlen = 0;
|
|
|
|
|
|
|
|
|
|
memset (&control, 0, sizeof (control));
|
|
|
|
|
mh.msg_control = &control;
|
|
|
|
|
mh.msg_controllen = sizeof (control);
|
|
|
|
|
|
|
|
|
|
cmsg = CMSG_FIRSTHDR (&mh);
|
|
|
|
|
cmsg->cmsg_level = SOL_SOCKET;
|
|
|
|
|
cmsg->cmsg_type = SCM_RIGHTS;
|
|
|
|
|
cmsg->cmsg_len = CMSG_LEN (sizeof (int));
|
|
|
|
|
memcpy (CMSG_DATA (cmsg), &buf_fd, sizeof (int));
|
|
|
|
|
|
|
|
|
|
mh.msg_controllen = cmsg->cmsg_len;
|
|
|
|
|
|
2016-07-25 16:25:40 +02:00
|
|
|
|
retry2:
|
|
|
|
|
if (sendmsg (journal_fd, &mh, MSG_NOSIGNAL) >= 0)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
if (errno == EINTR)
|
|
|
|
|
goto retry2;
|
2016-07-23 04:56:26 +02:00
|
|
|
|
|
2016-07-25 16:25:40 +02:00
|
|
|
|
return -1;
|
2016-07-23 04:56:26 +02:00
|
|
|
|
}
|
2017-10-09 12:47:23 +02:00
|
|
|
|
#endif /* ENABLE_JOURNAL_SENDV */
|
2016-07-23 04:56:26 +02:00
|
|
|
|
|
2016-02-20 13:34:29 +01:00
|
|
|
|
/**
|
|
|
|
|
* g_log_writer_journald:
|
|
|
|
|
* @log_level: log level, either from #GLogLevelFlags, or a user-defined
|
|
|
|
|
* level
|
|
|
|
|
* @fields: (array length=n_fields): key–value pairs of structured data forming
|
|
|
|
|
* the log message
|
|
|
|
|
* @n_fields: number of elements in the @fields array
|
|
|
|
|
* @user_data: user data passed to g_log_set_writer_func()
|
|
|
|
|
*
|
|
|
|
|
* Format a structured log message and send it to the systemd journal as a set
|
|
|
|
|
* of key–value pairs. All fields are sent to the journal, but if a field has
|
|
|
|
|
* length zero (indicating program-specific data) then only its key will be
|
|
|
|
|
* sent.
|
|
|
|
|
*
|
|
|
|
|
* This is suitable for use as a #GLogWriterFunc.
|
|
|
|
|
*
|
|
|
|
|
* If GLib has been compiled without systemd support, this function is still
|
|
|
|
|
* defined, but will always return %G_LOG_WRITER_UNHANDLED.
|
|
|
|
|
*
|
|
|
|
|
* Returns: %G_LOG_WRITER_HANDLED on success, %G_LOG_WRITER_UNHANDLED otherwise
|
|
|
|
|
* Since: 2.50
|
|
|
|
|
*/
|
|
|
|
|
GLogWriterOutput
|
|
|
|
|
g_log_writer_journald (GLogLevelFlags log_level,
|
|
|
|
|
const GLogField *fields,
|
|
|
|
|
gsize n_fields,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
2017-10-09 12:47:23 +02:00
|
|
|
|
#ifdef ENABLE_JOURNAL_SENDV
|
2016-07-23 04:56:26 +02:00
|
|
|
|
const char equals = '=';
|
|
|
|
|
const char newline = '\n';
|
|
|
|
|
gsize i, k;
|
|
|
|
|
struct iovec *iov, *v;
|
|
|
|
|
char *buf;
|
2016-02-20 13:34:29 +01:00
|
|
|
|
gint retval;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (fields != NULL, G_LOG_WRITER_UNHANDLED);
|
|
|
|
|
g_return_val_if_fail (n_fields > 0, G_LOG_WRITER_UNHANDLED);
|
|
|
|
|
|
|
|
|
|
/* According to systemd.journal-fields(7), the journal allows fields in any
|
|
|
|
|
* format (including arbitrary binary), but expects text fields to be UTF-8.
|
|
|
|
|
* This is great, because we require input strings to be in UTF-8, so no
|
|
|
|
|
* conversion is necessary and we don’t need to care about the current
|
|
|
|
|
* locale’s character set.
|
|
|
|
|
*/
|
|
|
|
|
|
2016-07-23 04:56:26 +02:00
|
|
|
|
iov = g_alloca (sizeof (struct iovec) * 5 * n_fields);
|
|
|
|
|
buf = g_alloca (32 * n_fields);
|
2016-02-20 13:34:29 +01:00
|
|
|
|
|
2016-07-23 04:56:26 +02:00
|
|
|
|
k = 0;
|
|
|
|
|
v = iov;
|
2016-02-20 13:34:29 +01:00
|
|
|
|
for (i = 0; i < n_fields; i++)
|
|
|
|
|
{
|
2016-07-25 18:31:52 +02:00
|
|
|
|
guint64 length;
|
2016-07-23 04:56:26 +02:00
|
|
|
|
gboolean binary;
|
2016-02-20 13:34:29 +01:00
|
|
|
|
|
2016-07-23 04:56:26 +02:00
|
|
|
|
if (fields[i].length < 0)
|
|
|
|
|
{
|
|
|
|
|
length = strlen (fields[i].value);
|
|
|
|
|
binary = strchr (fields[i].value, '\n') != NULL;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
length = fields[i].length;
|
|
|
|
|
binary = TRUE;
|
|
|
|
|
}
|
2016-02-20 13:34:29 +01:00
|
|
|
|
|
2016-07-23 04:56:26 +02:00
|
|
|
|
if (binary)
|
|
|
|
|
{
|
|
|
|
|
guint64 nstr;
|
2016-02-20 13:34:29 +01:00
|
|
|
|
|
2016-07-23 04:56:26 +02:00
|
|
|
|
v[0].iov_base = (gpointer)fields[i].key;
|
|
|
|
|
v[0].iov_len = strlen (fields[i].key);
|
|
|
|
|
|
|
|
|
|
v[1].iov_base = (gpointer)&newline;
|
|
|
|
|
v[1].iov_len = 1;
|
|
|
|
|
|
2016-07-25 18:31:52 +02:00
|
|
|
|
nstr = GUINT64_TO_LE(length);
|
2016-07-23 04:56:26 +02:00
|
|
|
|
memcpy (&buf[k], &nstr, sizeof (nstr));
|
|
|
|
|
|
|
|
|
|
v[2].iov_base = &buf[k];
|
|
|
|
|
v[2].iov_len = sizeof (nstr);
|
|
|
|
|
v += 3;
|
|
|
|
|
k += sizeof (nstr);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
v[0].iov_base = (gpointer)fields[i].key;
|
|
|
|
|
v[0].iov_len = strlen (fields[i].key);
|
|
|
|
|
|
|
|
|
|
v[1].iov_base = (gpointer)=
|
|
|
|
|
v[1].iov_len = 1;
|
|
|
|
|
v += 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
v[0].iov_base = (gpointer)fields[i].value;
|
|
|
|
|
v[0].iov_len = length;
|
|
|
|
|
|
|
|
|
|
v[1].iov_base = (gpointer)&newline;
|
|
|
|
|
v[1].iov_len = 1;
|
|
|
|
|
v += 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
retval = journal_sendv (iov, v - iov);
|
|
|
|
|
|
|
|
|
|
return retval == 0 ? G_LOG_WRITER_HANDLED : G_LOG_WRITER_UNHANDLED;
|
2016-07-26 06:32:42 +02:00
|
|
|
|
#else
|
|
|
|
|
return G_LOG_WRITER_UNHANDLED;
|
2017-10-09 12:47:23 +02:00
|
|
|
|
#endif /* ENABLE_JOURNAL_SENDV */
|
2016-02-20 13:34:29 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* g_log_writer_standard_streams:
|
|
|
|
|
* @log_level: log level, either from #GLogLevelFlags, or a user-defined
|
|
|
|
|
* level
|
|
|
|
|
* @fields: (array length=n_fields): key–value pairs of structured data forming
|
|
|
|
|
* the log message
|
|
|
|
|
* @n_fields: number of elements in the @fields array
|
|
|
|
|
* @user_data: user data passed to g_log_set_writer_func()
|
|
|
|
|
*
|
|
|
|
|
* Format a structured log message and print it to either `stdout` or `stderr`,
|
|
|
|
|
* depending on its log level. %G_LOG_LEVEL_INFO and %G_LOG_LEVEL_DEBUG messages
|
|
|
|
|
* are sent to `stdout`; all other log levels are sent to `stderr`. Only fields
|
|
|
|
|
* which are understood by this function are included in the formatted string
|
|
|
|
|
* which is printed.
|
|
|
|
|
*
|
2016-03-15 11:47:39 +01:00
|
|
|
|
* If the output stream supports ANSI color escape sequences, they will be used
|
|
|
|
|
* in the output.
|
|
|
|
|
*
|
2016-02-20 13:34:29 +01:00
|
|
|
|
* A trailing new-line character is added to the log message when it is printed.
|
|
|
|
|
*
|
|
|
|
|
* This is suitable for use as a #GLogWriterFunc.
|
|
|
|
|
*
|
|
|
|
|
* Returns: %G_LOG_WRITER_HANDLED on success, %G_LOG_WRITER_UNHANDLED otherwise
|
|
|
|
|
* Since: 2.50
|
|
|
|
|
*/
|
|
|
|
|
GLogWriterOutput
|
|
|
|
|
g_log_writer_standard_streams (GLogLevelFlags log_level,
|
|
|
|
|
const GLogField *fields,
|
|
|
|
|
gsize n_fields,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
FILE *stream;
|
|
|
|
|
gchar *out = NULL; /* in the current locale’s character set */
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (fields != NULL, G_LOG_WRITER_UNHANDLED);
|
|
|
|
|
g_return_val_if_fail (n_fields > 0, G_LOG_WRITER_UNHANDLED);
|
|
|
|
|
|
|
|
|
|
stream = log_level_to_file (log_level);
|
glog: fix crash on windows with --subsystem,windows app
A windows application compiled with -Wl,--subsystem,windows has no
console attached. When started from the start menu for ex, it will crash
when a function attempt to use g_log:
#10 0x00a21b26 in g_logv (log_domain=0xa842e1 <__func__.7668+329> "GLib", log_level=G_LOG_LEVEL_CRITICAL, format=0xa845c6 <__func__.7668+1070> "%s: assertion '%s' failed", args=0x28f2bc "PG"")
#11 0x00a21bb1 in g_log (log_domain=0xa842e1 <__func__.7668+329> "GLib", log_level=G_LOG_LEVEL_CRITICAL, format=0xa845c6 <__func__.7668+1070> "%s: assertion '%s' failed") at gmessages.c:1337
#12 0x00a22bac in g_return_if_fail_warning (log_domain=0xa842e1 <__func__.7668+329> "GLib", pretty_function=0xa84750 <__func__.65002> "g_log_writer_supports_color",
expression=0xa844de <__func__.7668+838> "output_fd >= 0") at gmessages.c:2453
#13 0x00a2239e in g_log_writer_supports_color (output_fd=-2) at gmessages.c:1826
#14 0x00a226ac in g_log_writer_standard_streams (log_level=G_LOG_LEVEL_WARNING, fields=0x28f3c8, n_fields=4, user_data=0x0) at gmessages.c:2254
#15 0x00a2290e in g_log_writer_default (log_level=G_LOG_LEVEL_WARNING, fields=0x28f3c8, n_fields=4, user_data=0x0) at gmessages.c:2357
According to https://msdn.microsoft.com/en-us/library/zs6wbdhx.aspx:
If stdout or stderr is not associated with an output stream (for
example, in a Windows application without a console window), the file
descriptor returned is -2. In previous versions, the file descriptor
returned was -1. This change allows applications to distinguish this
condition from an error.
Check if the stream exists and has an associated descriptor and return
G_LOG_WRITER_UNHANDLED if it's not the case.
Fixes:
https://bugzilla.gnome.org/show_bug.cgi?id=772511
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
2016-10-06 15:16:48 +02:00
|
|
|
|
if (!stream || fileno (stream) < 0)
|
|
|
|
|
return G_LOG_WRITER_UNHANDLED;
|
|
|
|
|
|
2016-03-15 11:47:39 +01:00
|
|
|
|
out = g_log_writer_format_fields (log_level, fields, n_fields,
|
|
|
|
|
g_log_writer_supports_color (fileno (stream)));
|
2016-02-20 13:34:29 +01:00
|
|
|
|
_g_fprintf (stream, "%s\n", out);
|
|
|
|
|
g_free (out);
|
|
|
|
|
|
|
|
|
|
return G_LOG_WRITER_HANDLED;
|
|
|
|
|
}
|
|
|
|
|
|
2016-06-13 19:21:44 +02:00
|
|
|
|
/* The old g_log() API is implemented in terms of the new structured log API.
|
|
|
|
|
* However, some of the checks do not line up between the two APIs: the
|
|
|
|
|
* structured API only handles fatalness of messages for log levels; the old API
|
|
|
|
|
* handles it per-domain as well. Consequently, we need to disable fatalness
|
|
|
|
|
* handling in the structured log API when called from the old g_log() API.
|
|
|
|
|
*
|
|
|
|
|
* We can guarantee that g_log_default_handler() will pass GLIB_OLD_LOG_API as
|
2016-07-20 23:07:40 +02:00
|
|
|
|
* the first field to g_log_structured_array(), if that is the case.
|
2016-06-13 19:21:44 +02:00
|
|
|
|
*/
|
|
|
|
|
static gboolean
|
|
|
|
|
log_is_old_api (const GLogField *fields,
|
|
|
|
|
gsize n_fields)
|
|
|
|
|
{
|
2016-07-20 23:07:40 +02:00
|
|
|
|
return (n_fields >= 1 &&
|
|
|
|
|
g_strcmp0 (fields[0].key, "GLIB_OLD_LOG_API") == 0 &&
|
|
|
|
|
g_strcmp0 (fields[0].value, "1") == 0);
|
2016-06-13 19:21:44 +02:00
|
|
|
|
}
|
|
|
|
|
|
2016-02-20 13:34:29 +01:00
|
|
|
|
/**
|
|
|
|
|
* g_log_writer_default:
|
|
|
|
|
* @log_level: log level, either from #GLogLevelFlags, or a user-defined
|
|
|
|
|
* level
|
|
|
|
|
* @fields: (array length=n_fields): key–value pairs of structured data forming
|
|
|
|
|
* the log message
|
|
|
|
|
* @n_fields: number of elements in the @fields array
|
|
|
|
|
* @user_data: user data passed to g_log_set_writer_func()
|
|
|
|
|
*
|
|
|
|
|
* Format a structured log message and output it to the default log destination
|
|
|
|
|
* for the platform. On Linux, this is typically the systemd journal, falling
|
|
|
|
|
* back to `stdout` or `stderr` if running from the terminal or if output is
|
|
|
|
|
* being redirected to a file.
|
|
|
|
|
*
|
|
|
|
|
* Support for other platform-specific logging mechanisms may be added in
|
|
|
|
|
* future. Distributors of GLib may modify this function to impose their own
|
|
|
|
|
* (documented) platform-specific log writing policies.
|
|
|
|
|
*
|
|
|
|
|
* This is suitable for use as a #GLogWriterFunc, and is the default writer used
|
|
|
|
|
* if no other is set using g_log_set_writer_func().
|
|
|
|
|
*
|
2016-08-03 23:11:57 +02:00
|
|
|
|
* As with g_log_default_handler(), this function drops debug and informational
|
|
|
|
|
* messages unless their log domain (or `all`) is listed in the space-separated
|
|
|
|
|
* `G_MESSAGES_DEBUG` environment variable.
|
|
|
|
|
*
|
2016-02-20 13:34:29 +01:00
|
|
|
|
* Returns: %G_LOG_WRITER_HANDLED on success, %G_LOG_WRITER_UNHANDLED otherwise
|
|
|
|
|
* Since: 2.50
|
|
|
|
|
*/
|
|
|
|
|
GLogWriterOutput
|
|
|
|
|
g_log_writer_default (GLogLevelFlags log_level,
|
|
|
|
|
const GLogField *fields,
|
|
|
|
|
gsize n_fields,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (fields != NULL, G_LOG_WRITER_UNHANDLED);
|
|
|
|
|
g_return_val_if_fail (n_fields > 0, G_LOG_WRITER_UNHANDLED);
|
|
|
|
|
|
|
|
|
|
/* Disable debug message output unless specified in G_MESSAGES_DEBUG. */
|
|
|
|
|
if (!(log_level & DEFAULT_LEVELS) && !(log_level >> G_LOG_LEVEL_USER_SHIFT))
|
|
|
|
|
{
|
|
|
|
|
const gchar *domains, *log_domain = NULL;
|
|
|
|
|
gsize i;
|
|
|
|
|
|
|
|
|
|
domains = g_getenv ("G_MESSAGES_DEBUG");
|
|
|
|
|
|
|
|
|
|
if ((log_level & INFO_LEVELS) == 0 ||
|
|
|
|
|
domains == NULL)
|
|
|
|
|
return G_LOG_WRITER_HANDLED;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < n_fields; i++)
|
|
|
|
|
{
|
|
|
|
|
if (g_strcmp0 (fields[i].key, "GLIB_DOMAIN") == 0)
|
|
|
|
|
{
|
|
|
|
|
log_domain = fields[i].value;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (strcmp (domains, "all") != 0 &&
|
|
|
|
|
(log_domain == NULL || !strstr (domains, log_domain)))
|
|
|
|
|
return G_LOG_WRITER_HANDLED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Mark messages as fatal if they have a level set in
|
|
|
|
|
* g_log_set_always_fatal().
|
|
|
|
|
*/
|
2016-08-03 22:28:28 +02:00
|
|
|
|
if ((log_level & g_log_always_fatal) && !log_is_old_api (fields, n_fields))
|
2016-02-20 13:34:29 +01:00
|
|
|
|
log_level |= G_LOG_FLAG_FATAL;
|
|
|
|
|
|
|
|
|
|
/* Try logging to the systemd journal as first choice. */
|
|
|
|
|
if (g_log_writer_is_journald (fileno (stderr)) &&
|
|
|
|
|
g_log_writer_journald (log_level, fields, n_fields, user_data) ==
|
|
|
|
|
G_LOG_WRITER_HANDLED)
|
|
|
|
|
goto handled;
|
|
|
|
|
|
|
|
|
|
/* FIXME: Add support for the Windows log. */
|
|
|
|
|
|
|
|
|
|
if (g_log_writer_standard_streams (log_level, fields, n_fields, user_data) ==
|
|
|
|
|
G_LOG_WRITER_HANDLED)
|
|
|
|
|
goto handled;
|
|
|
|
|
|
|
|
|
|
return G_LOG_WRITER_UNHANDLED;
|
|
|
|
|
|
|
|
|
|
handled:
|
|
|
|
|
/* Abort if the message was fatal. */
|
|
|
|
|
if (log_level & G_LOG_FLAG_FATAL)
|
|
|
|
|
{
|
|
|
|
|
#ifdef G_OS_WIN32
|
|
|
|
|
if (!g_test_initialized ())
|
|
|
|
|
{
|
|
|
|
|
gchar *locale_msg = NULL;
|
|
|
|
|
|
|
|
|
|
locale_msg = g_locale_from_utf8 (fatal_msg_buf, -1, NULL, NULL, NULL);
|
|
|
|
|
MessageBox (NULL, locale_msg, NULL,
|
|
|
|
|
MB_ICONERROR | MB_SETFOREGROUND);
|
|
|
|
|
g_free (locale_msg);
|
|
|
|
|
}
|
|
|
|
|
#endif /* !G_OS_WIN32 */
|
|
|
|
|
|
|
|
|
|
_g_log_abort (!(log_level & G_LOG_FLAG_RECURSION));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return G_LOG_WRITER_HANDLED;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static GLogWriterOutput
|
|
|
|
|
_g_log_writer_fallback (GLogLevelFlags log_level,
|
|
|
|
|
const GLogField *fields,
|
|
|
|
|
gsize n_fields,
|
|
|
|
|
gpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
FILE *stream;
|
|
|
|
|
gsize i;
|
|
|
|
|
|
|
|
|
|
/* we cannot call _any_ GLib functions in this fallback handler,
|
|
|
|
|
* which is why we skip UTF-8 conversion, etc.
|
|
|
|
|
* since we either recursed or ran out of memory, we're in a pretty
|
|
|
|
|
* pathologic situation anyways, what we can do is giving the
|
|
|
|
|
* the process ID unconditionally however.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
stream = log_level_to_file (log_level);
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < n_fields; i++)
|
|
|
|
|
{
|
|
|
|
|
const GLogField *field = &fields[i];
|
|
|
|
|
|
|
|
|
|
/* Only print fields we definitely recognise, otherwise we could end up
|
|
|
|
|
* printing a random non-string pointer provided by the user to be
|
|
|
|
|
* interpreted by their writer function.
|
|
|
|
|
*/
|
|
|
|
|
if (strcmp (field->key, "MESSAGE") != 0 &&
|
|
|
|
|
strcmp (field->key, "MESSAGE_ID") != 0 &&
|
|
|
|
|
strcmp (field->key, "PRIORITY") != 0 &&
|
|
|
|
|
strcmp (field->key, "CODE_FILE") != 0 &&
|
|
|
|
|
strcmp (field->key, "CODE_LINE") != 0 &&
|
|
|
|
|
strcmp (field->key, "CODE_FUNC") != 0 &&
|
|
|
|
|
strcmp (field->key, "ERRNO") != 0 &&
|
|
|
|
|
strcmp (field->key, "SYSLOG_FACILITY") != 0 &&
|
|
|
|
|
strcmp (field->key, "SYSLOG_IDENTIFIER") != 0 &&
|
|
|
|
|
strcmp (field->key, "SYSLOG_PID") != 0 &&
|
|
|
|
|
strcmp (field->key, "GLIB_DOMAIN") != 0)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
write_string (stream, field->key);
|
|
|
|
|
write_string (stream, "=");
|
|
|
|
|
write_string_sized (stream, field->value, field->length);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifndef G_OS_WIN32
|
|
|
|
|
{
|
|
|
|
|
gchar pid_string[FORMAT_UNSIGNED_BUFSIZE];
|
|
|
|
|
|
|
|
|
|
format_unsigned (pid_string, getpid (), 10);
|
|
|
|
|
write_string (stream, "_PID=");
|
|
|
|
|
write_string (stream, pid_string);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
return G_LOG_WRITER_HANDLED;
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-06 13:23:09 +01:00
|
|
|
|
/**
|
|
|
|
|
* g_return_if_fail_warning: (skip)
|
|
|
|
|
* @log_domain: (nullable):
|
|
|
|
|
* @pretty_function:
|
|
|
|
|
* @expression: (nullable):
|
|
|
|
|
*/
|
2004-09-09 19:55:05 +02:00
|
|
|
|
void
|
|
|
|
|
g_return_if_fail_warning (const char *log_domain,
|
|
|
|
|
const char *pretty_function,
|
|
|
|
|
const char *expression)
|
|
|
|
|
{
|
|
|
|
|
g_log (log_domain,
|
|
|
|
|
G_LOG_LEVEL_CRITICAL,
|
2013-05-20 22:54:48 +02:00
|
|
|
|
"%s: assertion '%s' failed",
|
2004-09-09 19:55:05 +02:00
|
|
|
|
pretty_function,
|
2004-09-30 04:02:00 +02:00
|
|
|
|
expression);
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-06 13:23:09 +01:00
|
|
|
|
/**
|
|
|
|
|
* g_warn_message: (skip)
|
|
|
|
|
* @domain: (nullable):
|
|
|
|
|
* @file:
|
|
|
|
|
* @line:
|
|
|
|
|
* @func:
|
|
|
|
|
* @warnexpr: (nullable):
|
|
|
|
|
*/
|
2007-12-10 15:07:42 +01:00
|
|
|
|
void
|
|
|
|
|
g_warn_message (const char *domain,
|
|
|
|
|
const char *file,
|
|
|
|
|
int line,
|
|
|
|
|
const char *func,
|
|
|
|
|
const char *warnexpr)
|
|
|
|
|
{
|
|
|
|
|
char *s, lstr[32];
|
|
|
|
|
g_snprintf (lstr, 32, "%d", line);
|
|
|
|
|
if (warnexpr)
|
|
|
|
|
s = g_strconcat ("(", file, ":", lstr, "):",
|
|
|
|
|
func, func[0] ? ":" : "",
|
|
|
|
|
" runtime check failed: (", warnexpr, ")", NULL);
|
|
|
|
|
else
|
|
|
|
|
s = g_strconcat ("(", file, ":", lstr, "):",
|
|
|
|
|
func, func[0] ? ":" : "",
|
|
|
|
|
" ", "code should not be reached", NULL);
|
|
|
|
|
g_log (domain, G_LOG_LEVEL_WARNING, "%s", s);
|
|
|
|
|
g_free (s);
|
|
|
|
|
}
|
|
|
|
|
|
2004-09-30 04:02:00 +02:00
|
|
|
|
void
|
|
|
|
|
g_assert_warning (const char *log_domain,
|
|
|
|
|
const char *file,
|
|
|
|
|
const int line,
|
|
|
|
|
const char *pretty_function,
|
|
|
|
|
const char *expression)
|
|
|
|
|
{
|
2014-01-04 18:42:23 +01:00
|
|
|
|
if (expression)
|
|
|
|
|
g_log (log_domain,
|
|
|
|
|
G_LOG_LEVEL_ERROR,
|
|
|
|
|
"file %s: line %d (%s): assertion failed: (%s)",
|
|
|
|
|
file,
|
|
|
|
|
line,
|
|
|
|
|
pretty_function,
|
|
|
|
|
expression);
|
|
|
|
|
else
|
|
|
|
|
g_log (log_domain,
|
|
|
|
|
G_LOG_LEVEL_ERROR,
|
|
|
|
|
"file %s: line %d (%s): should not be reached",
|
|
|
|
|
file,
|
|
|
|
|
line,
|
|
|
|
|
pretty_function);
|
2013-11-27 16:15:44 +01:00
|
|
|
|
_g_log_abort (FALSE);
|
2016-03-30 16:01:30 +02:00
|
|
|
|
g_abort ();
|
2004-09-09 19:55:05 +02:00
|
|
|
|
}
|
|
|
|
|
|
2012-07-30 22:05:08 +02:00
|
|
|
|
/**
|
|
|
|
|
* g_test_expect_message:
|
2016-10-29 03:29:02 +02:00
|
|
|
|
* @log_domain: (nullable): the log domain of the message
|
2012-07-30 22:05:08 +02:00
|
|
|
|
* @log_level: the log level of the message
|
2014-02-08 18:26:56 +01:00
|
|
|
|
* @pattern: a glob-style [pattern][glib-Glob-style-pattern-matching]
|
2012-07-30 22:05:08 +02:00
|
|
|
|
*
|
|
|
|
|
* Indicates that a message with the given @log_domain and @log_level,
|
|
|
|
|
* with text matching @pattern, is expected to be logged. When this
|
|
|
|
|
* message is logged, it will not be printed, and the test case will
|
|
|
|
|
* not abort.
|
|
|
|
|
*
|
2016-08-03 22:55:53 +02:00
|
|
|
|
* This API may only be used with the old logging API (g_log() without
|
|
|
|
|
* %G_LOG_USE_STRUCTURED defined). It will not work with the structured logging
|
|
|
|
|
* API. See [Testing for Messages][testing-for-messages].
|
|
|
|
|
*
|
2012-07-30 22:05:08 +02:00
|
|
|
|
* Use g_test_assert_expected_messages() to assert that all
|
|
|
|
|
* previously-expected messages have been seen and suppressed.
|
|
|
|
|
*
|
|
|
|
|
* You can call this multiple times in a row, if multiple messages are
|
|
|
|
|
* expected as a result of a single call. (The messages must appear in
|
|
|
|
|
* the same order as the calls to g_test_expect_message().)
|
|
|
|
|
*
|
|
|
|
|
* For example:
|
|
|
|
|
*
|
2014-02-01 21:11:49 +01:00
|
|
|
|
* |[<!-- language="C" -->
|
2014-02-15 03:33:36 +01:00
|
|
|
|
* // g_main_context_push_thread_default() should fail if the
|
|
|
|
|
* // context is already owned by another thread.
|
2012-07-30 22:05:08 +02:00
|
|
|
|
* g_test_expect_message (G_LOG_DOMAIN,
|
2012-10-30 13:15:23 +01:00
|
|
|
|
* G_LOG_LEVEL_CRITICAL,
|
2012-11-24 21:47:45 +01:00
|
|
|
|
* "assertion*acquired_context*failed");
|
2012-07-30 22:05:08 +02:00
|
|
|
|
* g_main_context_push_thread_default (bad_context);
|
|
|
|
|
* g_test_assert_expected_messages ();
|
|
|
|
|
* ]|
|
|
|
|
|
*
|
|
|
|
|
* Note that you cannot use this to test g_error() messages, since
|
|
|
|
|
* g_error() intentionally never returns even if the program doesn't
|
2012-11-24 21:58:27 +01:00
|
|
|
|
* abort; use g_test_trap_subprocess() in this case.
|
2012-07-30 22:05:08 +02:00
|
|
|
|
*
|
2013-10-28 10:12:29 +01:00
|
|
|
|
* If messages at %G_LOG_LEVEL_DEBUG are emitted, but not explicitly
|
|
|
|
|
* expected via g_test_expect_message() then they will be ignored.
|
|
|
|
|
*
|
2012-07-30 22:05:08 +02:00
|
|
|
|
* Since: 2.34
|
2002-03-27 18:57:30 +01:00
|
|
|
|
*/
|
2012-07-30 22:05:08 +02:00
|
|
|
|
void
|
|
|
|
|
g_test_expect_message (const gchar *log_domain,
|
|
|
|
|
GLogLevelFlags log_level,
|
|
|
|
|
const gchar *pattern)
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
{
|
2012-07-30 22:05:08 +02:00
|
|
|
|
GTestExpectedMessage *expected;
|
2002-03-27 18:57:30 +01:00
|
|
|
|
|
2012-08-20 22:25:09 +02:00
|
|
|
|
g_return_if_fail (log_level != 0);
|
|
|
|
|
g_return_if_fail (pattern != NULL);
|
2013-10-19 02:40:57 +02:00
|
|
|
|
g_return_if_fail (~log_level & G_LOG_LEVEL_ERROR);
|
2012-08-20 22:25:09 +02:00
|
|
|
|
|
2012-07-30 22:05:08 +02:00
|
|
|
|
expected = g_new (GTestExpectedMessage, 1);
|
|
|
|
|
expected->log_domain = g_strdup (log_domain);
|
|
|
|
|
expected->log_level = log_level;
|
|
|
|
|
expected->pattern = g_strdup (pattern);
|
2002-03-27 18:57:30 +01:00
|
|
|
|
|
2012-07-30 22:05:08 +02:00
|
|
|
|
expected_messages = g_slist_append (expected_messages, expected);
|
2002-03-27 18:57:30 +01:00
|
|
|
|
}
|
|
|
|
|
|
2012-07-30 22:05:08 +02:00
|
|
|
|
void
|
|
|
|
|
g_test_assert_expected_messages_internal (const char *domain,
|
|
|
|
|
const char *file,
|
|
|
|
|
int line,
|
|
|
|
|
const char *func)
|
2002-03-27 18:57:30 +01:00
|
|
|
|
{
|
2012-07-30 22:05:08 +02:00
|
|
|
|
if (expected_messages)
|
|
|
|
|
{
|
|
|
|
|
GTestExpectedMessage *expected;
|
|
|
|
|
gchar level_prefix[STRING_BUFFER_SIZE];
|
|
|
|
|
gchar *message;
|
2002-03-27 18:57:30 +01:00
|
|
|
|
|
2012-07-30 22:05:08 +02:00
|
|
|
|
expected = expected_messages->data;
|
2002-03-27 18:57:30 +01:00
|
|
|
|
|
2016-03-15 11:47:39 +01:00
|
|
|
|
mklevel_prefix (level_prefix, expected->log_level, FALSE);
|
2014-04-10 17:37:23 +02:00
|
|
|
|
message = g_strdup_printf ("Did not see expected message %s-%s: %s",
|
|
|
|
|
expected->log_domain ? expected->log_domain : "**",
|
2012-07-30 22:05:08 +02:00
|
|
|
|
level_prefix, expected->pattern);
|
2014-04-10 17:37:23 +02:00
|
|
|
|
g_assertion_message (G_LOG_DOMAIN, file, line, func, message);
|
2012-07-30 22:05:08 +02:00
|
|
|
|
g_free (message);
|
2002-03-27 18:57:30 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
2001-05-09 18:36:17 +02:00
|
|
|
|
|
2012-07-30 22:05:08 +02:00
|
|
|
|
/**
|
|
|
|
|
* g_test_assert_expected_messages:
|
|
|
|
|
*
|
|
|
|
|
* Asserts that all messages previously indicated via
|
|
|
|
|
* g_test_expect_message() have been seen and suppressed.
|
|
|
|
|
*
|
2016-08-03 22:55:53 +02:00
|
|
|
|
* This API may only be used with the old logging API (g_log() without
|
|
|
|
|
* %G_LOG_USE_STRUCTURED defined). It will not work with the structured logging
|
|
|
|
|
* API. See [Testing for Messages][testing-for-messages].
|
|
|
|
|
*
|
2013-10-28 10:12:29 +01:00
|
|
|
|
* If messages at %G_LOG_LEVEL_DEBUG are emitted, but not explicitly
|
|
|
|
|
* expected via g_test_expect_message() then they will be ignored.
|
|
|
|
|
*
|
2012-07-30 22:05:08 +02:00
|
|
|
|
* Since: 2.34
|
|
|
|
|
*/
|
|
|
|
|
|
2002-03-27 18:57:30 +01:00
|
|
|
|
void
|
|
|
|
|
_g_log_fallback_handler (const gchar *log_domain,
|
|
|
|
|
GLogLevelFlags log_level,
|
|
|
|
|
const gchar *message,
|
|
|
|
|
gpointer unused_data)
|
|
|
|
|
{
|
2004-09-22 23:15:35 +02:00
|
|
|
|
gchar level_prefix[STRING_BUFFER_SIZE];
|
|
|
|
|
#ifndef G_OS_WIN32
|
|
|
|
|
gchar pid_string[FORMAT_UNSIGNED_BUFSIZE];
|
|
|
|
|
#endif
|
2015-04-09 18:05:18 +02:00
|
|
|
|
FILE *stream;
|
2002-03-27 18:57:30 +01:00
|
|
|
|
|
2011-03-24 09:33:55 +01:00
|
|
|
|
/* we cannot call _any_ GLib functions in this fallback handler,
|
2002-03-27 18:57:30 +01:00
|
|
|
|
* which is why we skip UTF-8 conversion, etc.
|
|
|
|
|
* since we either recursed or ran out of memory, we're in a pretty
|
|
|
|
|
* pathologic situation anyways, what we can do is giving the
|
|
|
|
|
* the process ID unconditionally however.
|
|
|
|
|
*/
|
|
|
|
|
|
2016-03-15 11:47:39 +01:00
|
|
|
|
stream = mklevel_prefix (level_prefix, log_level, FALSE);
|
2002-03-27 18:57:30 +01:00
|
|
|
|
if (!message)
|
|
|
|
|
message = "(NULL) message";
|
|
|
|
|
|
2004-09-22 23:15:35 +02:00
|
|
|
|
#ifndef G_OS_WIN32
|
2002-03-27 18:57:30 +01:00
|
|
|
|
format_unsigned (pid_string, getpid (), 10);
|
2004-09-22 23:15:35 +02:00
|
|
|
|
#endif
|
2002-03-27 18:57:30 +01:00
|
|
|
|
|
|
|
|
|
if (log_domain)
|
2015-04-09 18:05:18 +02:00
|
|
|
|
write_string (stream, "\n");
|
2002-03-27 18:57:30 +01:00
|
|
|
|
else
|
2015-04-09 18:05:18 +02:00
|
|
|
|
write_string (stream, "\n** ");
|
2004-09-22 23:15:35 +02:00
|
|
|
|
|
|
|
|
|
#ifndef G_OS_WIN32
|
2015-04-09 18:05:18 +02:00
|
|
|
|
write_string (stream, "(process:");
|
|
|
|
|
write_string (stream, pid_string);
|
|
|
|
|
write_string (stream, "): ");
|
2004-09-22 23:15:35 +02:00
|
|
|
|
#endif
|
|
|
|
|
|
2002-03-27 18:57:30 +01:00
|
|
|
|
if (log_domain)
|
|
|
|
|
{
|
2015-04-09 18:05:18 +02:00
|
|
|
|
write_string (stream, log_domain);
|
|
|
|
|
write_string (stream, "-");
|
2002-03-27 18:57:30 +01:00
|
|
|
|
}
|
2015-04-09 18:05:18 +02:00
|
|
|
|
write_string (stream, level_prefix);
|
|
|
|
|
write_string (stream, ": ");
|
|
|
|
|
write_string (stream, message);
|
2002-03-27 18:57:30 +01:00
|
|
|
|
}
|
|
|
|
|
|
2003-08-25 18:36:03 +02:00
|
|
|
|
static void
|
|
|
|
|
escape_string (GString *string)
|
|
|
|
|
{
|
|
|
|
|
const char *p = string->str;
|
|
|
|
|
gunichar wc;
|
|
|
|
|
|
|
|
|
|
while (p < string->str + string->len)
|
|
|
|
|
{
|
|
|
|
|
gboolean safe;
|
|
|
|
|
|
2004-03-14 19:59:33 +01:00
|
|
|
|
wc = g_utf8_get_char_validated (p, -1);
|
|
|
|
|
if (wc == (gunichar)-1 || wc == (gunichar)-2)
|
|
|
|
|
{
|
|
|
|
|
gchar *tmp;
|
2004-04-22 22:17:54 +02:00
|
|
|
|
guint pos;
|
|
|
|
|
|
|
|
|
|
pos = p - string->str;
|
|
|
|
|
|
2004-03-14 19:59:33 +01:00
|
|
|
|
/* Emit invalid UTF-8 as hex escapes
|
|
|
|
|
*/
|
|
|
|
|
tmp = g_strdup_printf ("\\x%02x", (guint)(guchar)*p);
|
2004-04-22 22:17:54 +02:00
|
|
|
|
g_string_erase (string, pos, 1);
|
|
|
|
|
g_string_insert (string, pos, tmp);
|
2004-03-14 19:59:33 +01:00
|
|
|
|
|
2004-04-22 22:17:54 +02:00
|
|
|
|
p = string->str + (pos + 4); /* Skip over escape sequence */
|
2004-03-14 19:59:33 +01:00
|
|
|
|
|
2004-04-22 22:17:54 +02:00
|
|
|
|
g_free (tmp);
|
2004-03-14 19:59:33 +01:00
|
|
|
|
continue;
|
|
|
|
|
}
|
2003-08-25 18:36:03 +02:00
|
|
|
|
if (wc == '\r')
|
|
|
|
|
{
|
|
|
|
|
safe = *(p + 1) == '\n';
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
safe = CHAR_IS_SAFE (wc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!safe)
|
|
|
|
|
{
|
|
|
|
|
gchar *tmp;
|
2004-04-22 22:17:54 +02:00
|
|
|
|
guint pos;
|
|
|
|
|
|
|
|
|
|
pos = p - string->str;
|
2003-08-25 18:36:03 +02:00
|
|
|
|
|
|
|
|
|
/* Largest char we escape is 0x0a, so we don't have to worry
|
|
|
|
|
* about 8-digit \Uxxxxyyyy
|
|
|
|
|
*/
|
|
|
|
|
tmp = g_strdup_printf ("\\u%04x", wc);
|
2004-04-22 22:17:54 +02:00
|
|
|
|
g_string_erase (string, pos, g_utf8_next_char (p) - p);
|
|
|
|
|
g_string_insert (string, pos, tmp);
|
2003-08-25 18:36:03 +02:00
|
|
|
|
g_free (tmp);
|
|
|
|
|
|
2004-04-22 22:17:54 +02:00
|
|
|
|
p = string->str + (pos + 6); /* Skip over escape sequence */
|
2003-08-25 18:36:03 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
p = g_utf8_next_char (p);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-13 04:29:18 +02:00
|
|
|
|
/**
|
|
|
|
|
* g_log_default_handler:
|
2013-12-06 13:23:09 +01:00
|
|
|
|
* @log_domain: (nullable): the log domain of the message, or %NULL for the
|
|
|
|
|
* default "" application domain
|
2011-10-13 04:29:18 +02:00
|
|
|
|
* @log_level: the level of the message
|
2013-12-06 13:23:09 +01:00
|
|
|
|
* @message: (nullable): the message
|
|
|
|
|
* @unused_data: (nullable): data passed from g_log() which is unused
|
2011-10-13 04:29:18 +02:00
|
|
|
|
*
|
|
|
|
|
* The default log handler set up by GLib; g_log_set_default_handler()
|
|
|
|
|
* allows to install an alternate default log handler.
|
|
|
|
|
* This is used if no log handler has been set for the particular log
|
|
|
|
|
* domain and log level combination. It outputs the message to stderr
|
2013-10-21 16:09:13 +02:00
|
|
|
|
* or stdout and if the log level is fatal it calls abort(). It automatically
|
|
|
|
|
* prints a new-line character after the message, so one does not need to be
|
|
|
|
|
* manually included in @message.
|
2011-10-13 04:29:18 +02:00
|
|
|
|
*
|
2011-11-03 06:48:54 +01:00
|
|
|
|
* The behavior of this log handler can be influenced by a number of
|
|
|
|
|
* environment variables:
|
2014-02-01 16:17:04 +01:00
|
|
|
|
*
|
2014-02-06 01:32:41 +01:00
|
|
|
|
* - `G_MESSAGES_PREFIXED`: A :-separated list of log levels for which
|
|
|
|
|
* messages should be prefixed by the program name and PID of the
|
|
|
|
|
* aplication.
|
2014-02-01 16:17:04 +01:00
|
|
|
|
*
|
2014-02-06 01:32:41 +01:00
|
|
|
|
* - `G_MESSAGES_DEBUG`: A space-separated list of log domains for
|
|
|
|
|
* which debug and informational messages are printed. By default
|
|
|
|
|
* these messages are not printed.
|
2011-11-03 06:48:54 +01:00
|
|
|
|
*
|
2011-10-13 04:29:18 +02:00
|
|
|
|
* stderr is used for levels %G_LOG_LEVEL_ERROR, %G_LOG_LEVEL_CRITICAL,
|
|
|
|
|
* %G_LOG_LEVEL_WARNING and %G_LOG_LEVEL_MESSAGE. stdout is used for
|
|
|
|
|
* the rest.
|
2016-08-12 11:53:19 +02:00
|
|
|
|
*
|
|
|
|
|
* This has no effect if structured logging is enabled; see
|
|
|
|
|
* [Using Structured Logging][using-structured-logging].
|
2011-10-13 04:29:18 +02:00
|
|
|
|
*/
|
2002-03-27 18:57:30 +01:00
|
|
|
|
void
|
|
|
|
|
g_log_default_handler (const gchar *log_domain,
|
|
|
|
|
GLogLevelFlags log_level,
|
|
|
|
|
const gchar *message,
|
|
|
|
|
gpointer unused_data)
|
|
|
|
|
{
|
2016-07-20 23:07:40 +02:00
|
|
|
|
GLogField fields[4];
|
2016-07-22 17:01:39 +02:00
|
|
|
|
int n_fields = 0;
|
2011-11-03 06:48:54 +01:00
|
|
|
|
|
2002-03-27 18:57:30 +01:00
|
|
|
|
/* we can be called externally with recursion for whatever reason */
|
|
|
|
|
if (log_level & G_LOG_FLAG_RECURSION)
|
|
|
|
|
{
|
|
|
|
|
_g_log_fallback_handler (log_domain, log_level, message, unused_data);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-20 23:07:40 +02:00
|
|
|
|
fields[0].key = "GLIB_OLD_LOG_API";
|
|
|
|
|
fields[0].value = "1";
|
|
|
|
|
fields[0].length = -1;
|
2016-07-22 17:01:39 +02:00
|
|
|
|
n_fields++;
|
2016-07-20 23:07:40 +02:00
|
|
|
|
|
|
|
|
|
fields[1].key = "MESSAGE";
|
|
|
|
|
fields[1].value = message;
|
|
|
|
|
fields[1].length = -1;
|
2016-07-22 17:01:39 +02:00
|
|
|
|
n_fields++;
|
2016-07-20 23:07:40 +02:00
|
|
|
|
|
|
|
|
|
fields[2].key = "PRIORITY";
|
|
|
|
|
fields[2].value = log_level_to_priority (log_level);
|
2016-07-23 04:56:26 +02:00
|
|
|
|
fields[2].length = -1;
|
2016-07-22 17:01:39 +02:00
|
|
|
|
n_fields++;
|
2016-07-20 23:07:40 +02:00
|
|
|
|
|
2016-07-22 17:01:39 +02:00
|
|
|
|
if (log_domain)
|
|
|
|
|
{
|
|
|
|
|
fields[3].key = "GLIB_DOMAIN";
|
|
|
|
|
fields[3].value = log_domain;
|
|
|
|
|
fields[3].length = -1;
|
|
|
|
|
n_fields++;
|
|
|
|
|
}
|
2016-07-20 23:07:40 +02:00
|
|
|
|
|
2016-06-13 19:21:44 +02:00
|
|
|
|
/* Print out via the structured log API, but drop any fatal flags since we
|
|
|
|
|
* have already handled them. The fatal handling in the structured logging
|
|
|
|
|
* API is more coarse-grained than in the old g_log() API, so we don't want
|
|
|
|
|
* to use it here.
|
|
|
|
|
*/
|
2016-07-22 17:01:39 +02:00
|
|
|
|
g_log_structured_array (log_level & ~G_LOG_FLAG_FATAL, fields, n_fields);
|
1998-06-11 01:21:14 +02:00
|
|
|
|
}
|
|
|
|
|
|
2011-07-20 02:40:28 +02:00
|
|
|
|
/**
|
|
|
|
|
* g_set_print_handler:
|
|
|
|
|
* @func: the new print handler
|
|
|
|
|
*
|
|
|
|
|
* Sets the print handler.
|
|
|
|
|
*
|
|
|
|
|
* Any messages passed to g_print() will be output via
|
|
|
|
|
* the new handler. The default handler simply outputs
|
|
|
|
|
* the message to stdout. By providing your own handler
|
|
|
|
|
* you can redirect the output, to a GTK+ widget or a
|
|
|
|
|
* log file for example.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the old print handler
|
|
|
|
|
*/
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
GPrintFunc
|
|
|
|
|
g_set_print_handler (GPrintFunc func)
|
|
|
|
|
{
|
|
|
|
|
GPrintFunc old_print_func;
|
2011-07-20 02:40:28 +02:00
|
|
|
|
|
2011-09-17 23:56:33 +02:00
|
|
|
|
g_mutex_lock (&g_messages_lock);
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
old_print_func = glib_print_func;
|
|
|
|
|
glib_print_func = func;
|
2011-09-17 23:56:33 +02:00
|
|
|
|
g_mutex_unlock (&g_messages_lock);
|
2011-07-20 02:40:28 +02:00
|
|
|
|
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
return old_print_func;
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-20 02:40:28 +02:00
|
|
|
|
/**
|
|
|
|
|
* g_print:
|
|
|
|
|
* @format: the message format. See the printf() documentation
|
2011-07-22 13:25:32 +02:00
|
|
|
|
* @...: the parameters to insert into the format string
|
2011-07-20 02:40:28 +02:00
|
|
|
|
*
|
|
|
|
|
* Outputs a formatted message via the print handler.
|
2013-10-21 16:09:13 +02:00
|
|
|
|
* The default print handler simply outputs the message to stdout, without
|
|
|
|
|
* appending a trailing new-line character. Typically, @format should end with
|
|
|
|
|
* its own new-line character.
|
2011-07-20 02:40:28 +02:00
|
|
|
|
*
|
|
|
|
|
* g_print() should not be used from within libraries for debugging
|
|
|
|
|
* messages, since it may be redirected by applications to special
|
|
|
|
|
* purpose message windows or even files. Instead, libraries should
|
2016-08-12 11:53:19 +02:00
|
|
|
|
* use g_log(), g_log_structured(), or the convenience macros g_message(),
|
|
|
|
|
* g_warning() and g_error().
|
2011-07-20 02:40:28 +02:00
|
|
|
|
*/
|
1998-06-11 01:21:14 +02:00
|
|
|
|
void
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
g_print (const gchar *format,
|
2011-07-20 02:40:28 +02:00
|
|
|
|
...)
|
1998-06-11 01:21:14 +02:00
|
|
|
|
{
|
removed this function which was not publically exported in glib.h. to
Mon Aug 24 02:08:56 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gstring.c:
* gstrfuncs.c:
(g_vsprintf): removed this function which was not publically
exported in glib.h. to export it, it should have been named
differently in the first place, since its semantics differ from
vsprintf(). apart from that, it was a possible cause for
problems since it worked on a previously allocated memory area and
was used in a lot places of glib. exporting it would have been a
guararant for problems with threaded programs.
(g_printf_string_upper_bound): exported this function to return
a string size, guarranteed to be big enough to hold the fully
expanded format+args string. added 'q', 'L' and 'll' flag handling.
in fact, the newly allocated area is in most cases much bigger than
required.
(g_strdup_vprintf()): new function returning a newly allocated string
containing the contents of *format and associated args (size is
calculated with g_printf_string_upper_bound()).
(g_strdup_printf): new function which wraps g_strdup_vprintf().
* configure.in: check for va_copy() or __va_copy() alternatively.
check whether va_lists can be copyied by value.
* glib.h: provide a definition for G_VA_COPY.
* glib.h:
* gmessages.c:
(g_logv):
(g_vsnprintf):
pass va_lists by value, not by reference, since this causes problems
on platforms that implement va_list as as arrays. internaly, use
G_VA_COPY (new_arg, org_arg); va_end (new_arg); to produce a second
va_list variable, if multiple passes are required. changed all
callers.
* glib.h:
* gerror.h:
renamed g_debug() to g_on_error_query(), cleaned up a bit.
renamed g_stack_trace() to g_on_error_stack_trace() since both
functions cluttered different namespaces.
there is an appropriate comment in glib.h now that explains the
unix and gdb specific dependencies of both functions.
removed g_attach_process().
g_on_error_stack_trace() should probably be handled with caution,
i've seem several different linux versions (2.0.x) become unstable
after invokation of this function.
1998-08-24 07:26:53 +02:00
|
|
|
|
va_list args;
|
|
|
|
|
gchar *string;
|
1998-12-15 06:28:02 +01:00
|
|
|
|
GPrintFunc local_glib_print_func;
|
2011-07-20 02:40:28 +02:00
|
|
|
|
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
g_return_if_fail (format != NULL);
|
2011-07-20 02:40:28 +02:00
|
|
|
|
|
1998-06-11 01:21:14 +02:00
|
|
|
|
va_start (args, format);
|
removed this function which was not publically exported in glib.h. to
Mon Aug 24 02:08:56 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gstring.c:
* gstrfuncs.c:
(g_vsprintf): removed this function which was not publically
exported in glib.h. to export it, it should have been named
differently in the first place, since its semantics differ from
vsprintf(). apart from that, it was a possible cause for
problems since it worked on a previously allocated memory area and
was used in a lot places of glib. exporting it would have been a
guararant for problems with threaded programs.
(g_printf_string_upper_bound): exported this function to return
a string size, guarranteed to be big enough to hold the fully
expanded format+args string. added 'q', 'L' and 'll' flag handling.
in fact, the newly allocated area is in most cases much bigger than
required.
(g_strdup_vprintf()): new function returning a newly allocated string
containing the contents of *format and associated args (size is
calculated with g_printf_string_upper_bound()).
(g_strdup_printf): new function which wraps g_strdup_vprintf().
* configure.in: check for va_copy() or __va_copy() alternatively.
check whether va_lists can be copyied by value.
* glib.h: provide a definition for G_VA_COPY.
* glib.h:
* gmessages.c:
(g_logv):
(g_vsnprintf):
pass va_lists by value, not by reference, since this causes problems
on platforms that implement va_list as as arrays. internaly, use
G_VA_COPY (new_arg, org_arg); va_end (new_arg); to produce a second
va_list variable, if multiple passes are required. changed all
callers.
* glib.h:
* gerror.h:
renamed g_debug() to g_on_error_query(), cleaned up a bit.
renamed g_stack_trace() to g_on_error_stack_trace() since both
functions cluttered different namespaces.
there is an appropriate comment in glib.h now that explains the
unix and gdb specific dependencies of both functions.
removed g_attach_process().
g_on_error_stack_trace() should probably be handled with caution,
i've seem several different linux versions (2.0.x) become unstable
after invokation of this function.
1998-08-24 07:26:53 +02:00
|
|
|
|
string = g_strdup_vprintf (format, args);
|
1998-06-11 01:21:14 +02:00
|
|
|
|
va_end (args);
|
2011-07-20 02:40:28 +02:00
|
|
|
|
|
2011-09-17 23:56:33 +02:00
|
|
|
|
g_mutex_lock (&g_messages_lock);
|
1998-12-15 06:28:02 +01:00
|
|
|
|
local_glib_print_func = glib_print_func;
|
2011-09-17 23:56:33 +02:00
|
|
|
|
g_mutex_unlock (&g_messages_lock);
|
2011-07-20 02:40:28 +02:00
|
|
|
|
|
1998-12-15 06:28:02 +01:00
|
|
|
|
if (local_glib_print_func)
|
|
|
|
|
local_glib_print_func (string);
|
1998-06-11 01:21:14 +02:00
|
|
|
|
else
|
|
|
|
|
{
|
2002-03-28 21:12:32 +01:00
|
|
|
|
const gchar *charset;
|
|
|
|
|
|
|
|
|
|
if (g_get_charset (&charset))
|
2011-07-20 02:40:28 +02:00
|
|
|
|
fputs (string, stdout); /* charset is UTF-8 already */
|
2002-03-28 21:12:32 +01:00
|
|
|
|
else
|
2011-07-20 02:40:28 +02:00
|
|
|
|
{
|
|
|
|
|
gchar *lstring = strdup_convert (string, charset);
|
2002-03-28 21:12:32 +01:00
|
|
|
|
|
2011-07-20 02:40:28 +02:00
|
|
|
|
fputs (lstring, stdout);
|
|
|
|
|
g_free (lstring);
|
|
|
|
|
}
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
fflush (stdout);
|
1998-06-11 01:21:14 +02:00
|
|
|
|
}
|
removed this function which was not publically exported in glib.h. to
Mon Aug 24 02:08:56 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gstring.c:
* gstrfuncs.c:
(g_vsprintf): removed this function which was not publically
exported in glib.h. to export it, it should have been named
differently in the first place, since its semantics differ from
vsprintf(). apart from that, it was a possible cause for
problems since it worked on a previously allocated memory area and
was used in a lot places of glib. exporting it would have been a
guararant for problems with threaded programs.
(g_printf_string_upper_bound): exported this function to return
a string size, guarranteed to be big enough to hold the fully
expanded format+args string. added 'q', 'L' and 'll' flag handling.
in fact, the newly allocated area is in most cases much bigger than
required.
(g_strdup_vprintf()): new function returning a newly allocated string
containing the contents of *format and associated args (size is
calculated with g_printf_string_upper_bound()).
(g_strdup_printf): new function which wraps g_strdup_vprintf().
* configure.in: check for va_copy() or __va_copy() alternatively.
check whether va_lists can be copyied by value.
* glib.h: provide a definition for G_VA_COPY.
* glib.h:
* gmessages.c:
(g_logv):
(g_vsnprintf):
pass va_lists by value, not by reference, since this causes problems
on platforms that implement va_list as as arrays. internaly, use
G_VA_COPY (new_arg, org_arg); va_end (new_arg); to produce a second
va_list variable, if multiple passes are required. changed all
callers.
* glib.h:
* gerror.h:
renamed g_debug() to g_on_error_query(), cleaned up a bit.
renamed g_stack_trace() to g_on_error_stack_trace() since both
functions cluttered different namespaces.
there is an appropriate comment in glib.h now that explains the
unix and gdb specific dependencies of both functions.
removed g_attach_process().
g_on_error_stack_trace() should probably be handled with caution,
i've seem several different linux versions (2.0.x) become unstable
after invokation of this function.
1998-08-24 07:26:53 +02:00
|
|
|
|
g_free (string);
|
1998-06-11 01:21:14 +02:00
|
|
|
|
}
|
|
|
|
|
|
2011-07-20 02:40:28 +02:00
|
|
|
|
/**
|
|
|
|
|
* g_set_printerr_handler:
|
|
|
|
|
* @func: the new error message handler
|
|
|
|
|
*
|
|
|
|
|
* Sets the handler for printing error messages.
|
|
|
|
|
*
|
|
|
|
|
* Any messages passed to g_printerr() will be output via
|
|
|
|
|
* the new handler. The default handler simply outputs the
|
|
|
|
|
* message to stderr. By providing your own handler you can
|
|
|
|
|
* redirect the output, to a GTK+ widget or a log file for
|
|
|
|
|
* example.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the old error message handler
|
|
|
|
|
*/
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
GPrintFunc
|
|
|
|
|
g_set_printerr_handler (GPrintFunc func)
|
|
|
|
|
{
|
|
|
|
|
GPrintFunc old_printerr_func;
|
2011-07-20 02:40:28 +02:00
|
|
|
|
|
2011-09-17 23:56:33 +02:00
|
|
|
|
g_mutex_lock (&g_messages_lock);
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
old_printerr_func = glib_printerr_func;
|
|
|
|
|
glib_printerr_func = func;
|
2011-09-17 23:56:33 +02:00
|
|
|
|
g_mutex_unlock (&g_messages_lock);
|
2011-07-20 02:40:28 +02:00
|
|
|
|
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
return old_printerr_func;
|
|
|
|
|
}
|
|
|
|
|
|
2011-07-20 02:40:28 +02:00
|
|
|
|
/**
|
|
|
|
|
* g_printerr:
|
|
|
|
|
* @format: the message format. See the printf() documentation
|
2011-07-22 13:25:32 +02:00
|
|
|
|
* @...: the parameters to insert into the format string
|
2011-07-20 02:40:28 +02:00
|
|
|
|
*
|
|
|
|
|
* Outputs a formatted message via the error message handler.
|
2013-10-21 16:09:13 +02:00
|
|
|
|
* The default handler simply outputs the message to stderr, without appending
|
|
|
|
|
* a trailing new-line character. Typically, @format should end with its own
|
|
|
|
|
* new-line character.
|
2011-07-20 02:40:28 +02:00
|
|
|
|
*
|
|
|
|
|
* g_printerr() should not be used from within libraries.
|
2016-08-12 11:53:19 +02:00
|
|
|
|
* Instead g_log() or g_log_structured() should be used, or the convenience
|
|
|
|
|
* macros g_message(), g_warning() and g_error().
|
2011-07-20 02:40:28 +02:00
|
|
|
|
*/
|
1998-06-11 01:21:14 +02:00
|
|
|
|
void
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
g_printerr (const gchar *format,
|
2011-07-20 02:40:28 +02:00
|
|
|
|
...)
|
1998-06-11 01:21:14 +02:00
|
|
|
|
{
|
removed this function which was not publically exported in glib.h. to
Mon Aug 24 02:08:56 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gstring.c:
* gstrfuncs.c:
(g_vsprintf): removed this function which was not publically
exported in glib.h. to export it, it should have been named
differently in the first place, since its semantics differ from
vsprintf(). apart from that, it was a possible cause for
problems since it worked on a previously allocated memory area and
was used in a lot places of glib. exporting it would have been a
guararant for problems with threaded programs.
(g_printf_string_upper_bound): exported this function to return
a string size, guarranteed to be big enough to hold the fully
expanded format+args string. added 'q', 'L' and 'll' flag handling.
in fact, the newly allocated area is in most cases much bigger than
required.
(g_strdup_vprintf()): new function returning a newly allocated string
containing the contents of *format and associated args (size is
calculated with g_printf_string_upper_bound()).
(g_strdup_printf): new function which wraps g_strdup_vprintf().
* configure.in: check for va_copy() or __va_copy() alternatively.
check whether va_lists can be copyied by value.
* glib.h: provide a definition for G_VA_COPY.
* glib.h:
* gmessages.c:
(g_logv):
(g_vsnprintf):
pass va_lists by value, not by reference, since this causes problems
on platforms that implement va_list as as arrays. internaly, use
G_VA_COPY (new_arg, org_arg); va_end (new_arg); to produce a second
va_list variable, if multiple passes are required. changed all
callers.
* glib.h:
* gerror.h:
renamed g_debug() to g_on_error_query(), cleaned up a bit.
renamed g_stack_trace() to g_on_error_stack_trace() since both
functions cluttered different namespaces.
there is an appropriate comment in glib.h now that explains the
unix and gdb specific dependencies of both functions.
removed g_attach_process().
g_on_error_stack_trace() should probably be handled with caution,
i've seem several different linux versions (2.0.x) become unstable
after invokation of this function.
1998-08-24 07:26:53 +02:00
|
|
|
|
va_list args;
|
|
|
|
|
gchar *string;
|
1998-12-15 06:28:02 +01:00
|
|
|
|
GPrintFunc local_glib_printerr_func;
|
2011-07-20 02:40:28 +02:00
|
|
|
|
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
g_return_if_fail (format != NULL);
|
2011-07-20 02:40:28 +02:00
|
|
|
|
|
1998-06-11 01:21:14 +02:00
|
|
|
|
va_start (args, format);
|
removed this function which was not publically exported in glib.h. to
Mon Aug 24 02:08:56 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gstring.c:
* gstrfuncs.c:
(g_vsprintf): removed this function which was not publically
exported in glib.h. to export it, it should have been named
differently in the first place, since its semantics differ from
vsprintf(). apart from that, it was a possible cause for
problems since it worked on a previously allocated memory area and
was used in a lot places of glib. exporting it would have been a
guararant for problems with threaded programs.
(g_printf_string_upper_bound): exported this function to return
a string size, guarranteed to be big enough to hold the fully
expanded format+args string. added 'q', 'L' and 'll' flag handling.
in fact, the newly allocated area is in most cases much bigger than
required.
(g_strdup_vprintf()): new function returning a newly allocated string
containing the contents of *format and associated args (size is
calculated with g_printf_string_upper_bound()).
(g_strdup_printf): new function which wraps g_strdup_vprintf().
* configure.in: check for va_copy() or __va_copy() alternatively.
check whether va_lists can be copyied by value.
* glib.h: provide a definition for G_VA_COPY.
* glib.h:
* gmessages.c:
(g_logv):
(g_vsnprintf):
pass va_lists by value, not by reference, since this causes problems
on platforms that implement va_list as as arrays. internaly, use
G_VA_COPY (new_arg, org_arg); va_end (new_arg); to produce a second
va_list variable, if multiple passes are required. changed all
callers.
* glib.h:
* gerror.h:
renamed g_debug() to g_on_error_query(), cleaned up a bit.
renamed g_stack_trace() to g_on_error_stack_trace() since both
functions cluttered different namespaces.
there is an appropriate comment in glib.h now that explains the
unix and gdb specific dependencies of both functions.
removed g_attach_process().
g_on_error_stack_trace() should probably be handled with caution,
i've seem several different linux versions (2.0.x) become unstable
after invokation of this function.
1998-08-24 07:26:53 +02:00
|
|
|
|
string = g_strdup_vprintf (format, args);
|
1998-06-11 01:21:14 +02:00
|
|
|
|
va_end (args);
|
2011-07-20 02:40:28 +02:00
|
|
|
|
|
2011-09-17 23:56:33 +02:00
|
|
|
|
g_mutex_lock (&g_messages_lock);
|
1998-12-15 06:28:02 +01:00
|
|
|
|
local_glib_printerr_func = glib_printerr_func;
|
2011-09-17 23:56:33 +02:00
|
|
|
|
g_mutex_unlock (&g_messages_lock);
|
2011-07-20 02:40:28 +02:00
|
|
|
|
|
1998-12-15 06:28:02 +01:00
|
|
|
|
if (local_glib_printerr_func)
|
|
|
|
|
local_glib_printerr_func (string);
|
1998-06-11 01:21:14 +02:00
|
|
|
|
else
|
|
|
|
|
{
|
2002-03-28 21:12:32 +01:00
|
|
|
|
const gchar *charset;
|
|
|
|
|
|
|
|
|
|
if (g_get_charset (&charset))
|
2011-07-20 02:40:28 +02:00
|
|
|
|
fputs (string, stderr); /* charset is UTF-8 already */
|
2002-03-28 21:12:32 +01:00
|
|
|
|
else
|
2011-07-20 02:40:28 +02:00
|
|
|
|
{
|
|
|
|
|
gchar *lstring = strdup_convert (string, charset);
|
2002-03-28 21:12:32 +01:00
|
|
|
|
|
2011-07-20 02:40:28 +02:00
|
|
|
|
fputs (lstring, stderr);
|
|
|
|
|
g_free (lstring);
|
|
|
|
|
}
|
version bump to 1.1.3, binary age 0, interface age 0.
Sun Aug 16 20:28:27 1998 Tim Janik <timj@gtk.org>
* version bump to 1.1.3, binary age 0, interface age 0.
* glib.h: be nice to platforms that don't have gint64 and don't
issue #warning on every compilation. since glib doesn't require
gint64 itself, packages that need gint64 should test for this
themselves.
* glib.h:
* gutils.c: added a new function g_vsnprintf().
Fri Aug 14 16:41:53 1998 Tim Janik <timj@gtk.org>
* glib.h: added static inline functions for bit mask tests:
g_bit_nth_lsf, g_bit_nth_msf and g_bit_storage.
Fri Aug 13 14:23:37 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gmessages.c:
revised the message handling system, which is now based on a new
mechanism g_log*. most of the assertment macros got adapted to
feature the new g_log() call with an additional specification of
the log level in a preprocessor macro G_LOG_DOMAIN. if G_LOG_DOMAIN
is undefined upon the includion of glib.h, it'll be defined with a
value of (NULL) and thus preserves the original bahaviour for
warning and error messages. the message handler setting functions
for g_warning, g_error and g_message are only provided for backwards
compatibility and might get removed somewhen.
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GLib" upon compilation. we currently have to add this definition
to the DEFS variable.
* testglib.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
* glib.h: changed some gints to gbooleans, made a few const corrections,
removed some superfluous G_STMT_START{}G_STMT_END wrappers, added some
in other required places.
* gnode.c:
(g_node_prepend):
(g_node_insert_before):
(g_node_insert):
(g_node_append_data):
(g_node_prepend_data):
(g_node_insert_data_before):
(g_node_insert_data):
(g_node_append):
return (node), so these macros/functions can be usefully chained with
g_node_new().
[GModule]
Fri Aug 14 02:24:39 1998 Tim Janik <timj@gtk.org>
* Makefile.am: feature the G_LOG_DOMAIN macro to set the log domain
to "GModule" upon compilation. we currently have to add this definition
to the DEFS variable.
* testgmodule.c: we need an ugly #undef G_LOG_DOMAIN at the start
of this file currently, since automake doesn't support per target
_CFLAGS yet.
1998-08-16 23:14:11 +02:00
|
|
|
|
fflush (stderr);
|
1998-06-11 01:21:14 +02:00
|
|
|
|
}
|
removed this function which was not publically exported in glib.h. to
Mon Aug 24 02:08:56 1998 Tim Janik <timj@gtk.org>
* glib.h:
* gstring.c:
* gstrfuncs.c:
(g_vsprintf): removed this function which was not publically
exported in glib.h. to export it, it should have been named
differently in the first place, since its semantics differ from
vsprintf(). apart from that, it was a possible cause for
problems since it worked on a previously allocated memory area and
was used in a lot places of glib. exporting it would have been a
guararant for problems with threaded programs.
(g_printf_string_upper_bound): exported this function to return
a string size, guarranteed to be big enough to hold the fully
expanded format+args string. added 'q', 'L' and 'll' flag handling.
in fact, the newly allocated area is in most cases much bigger than
required.
(g_strdup_vprintf()): new function returning a newly allocated string
containing the contents of *format and associated args (size is
calculated with g_printf_string_upper_bound()).
(g_strdup_printf): new function which wraps g_strdup_vprintf().
* configure.in: check for va_copy() or __va_copy() alternatively.
check whether va_lists can be copyied by value.
* glib.h: provide a definition for G_VA_COPY.
* glib.h:
* gmessages.c:
(g_logv):
(g_vsnprintf):
pass va_lists by value, not by reference, since this causes problems
on platforms that implement va_list as as arrays. internaly, use
G_VA_COPY (new_arg, org_arg); va_end (new_arg); to produce a second
va_list variable, if multiple passes are required. changed all
callers.
* glib.h:
* gerror.h:
renamed g_debug() to g_on_error_query(), cleaned up a bit.
renamed g_stack_trace() to g_on_error_stack_trace() since both
functions cluttered different namespaces.
there is an appropriate comment in glib.h now that explains the
unix and gdb specific dependencies of both functions.
removed g_attach_process().
g_on_error_stack_trace() should probably be handled with caution,
i've seem several different linux versions (2.0.x) become unstable
after invokation of this function.
1998-08-24 07:26:53 +02:00
|
|
|
|
g_free (string);
|
1998-06-11 01:21:14 +02:00
|
|
|
|
}
|
|
|
|
|
|
2011-10-02 05:38:52 +02:00
|
|
|
|
/**
|
|
|
|
|
* g_printf_string_upper_bound:
|
|
|
|
|
* @format: the format string. See the printf() documentation
|
|
|
|
|
* @args: the parameters to be inserted into the format string
|
|
|
|
|
*
|
|
|
|
|
* Calculates the maximum space needed to store the output
|
|
|
|
|
* of the sprintf() function.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the maximum space needed to store the formatted string
|
|
|
|
|
*/
|
Changes for 64-bit cleanliness, loosely based on patch from Mark Murnane.
Wed Jun 20 12:00:54 2001 Owen Taylor <otaylor@redhat.com>
Changes for 64-bit cleanliness, loosely based on patch
from Mark Murnane.
* gconvert.c (g_convert/g_convert_with_fallback): Remove
workarounds for since-fixed GNU libc bugs. Minor
doc fix.
* gconvert.[ch]: Change gint to gsize/gssize as
appropriate.
* gconvert.c (g_locale/filename_to/from_utf8): Fix incorrect
computation of bytes_read / bytes_written.
* gfileutils.[ch] (g_file_get_contents): Make length
out parameter 'gsize *len'.
* ghook.c (g_hook_compare_ids): Don't compare a
and b as 'a - b'.
* gmacros.h (GSIZE_TO_POINTER): Add GPOINTER_TO_SIZE,
GSIZE_TO_POINTER.
* gmain.c (g_timeout_prepare): Rewrite to avoid
overflows. (Fixes bug when system clock skews
backwards more than 24 days.)
* gmarkup.[ch]: Make lengths passed to callbacks
gsize, length for g_markup_parse-context_parse(),
g_markup_escape_text() gssize.
* gmessages.[ch] (g_printf_string_upper_bound): Change
return value to gsize.
* gmessages.c (printf_string_upper_bound): Remove
a ridiculous use of 'inline' on a 300 line function.
* gstring.[ch]: Represent size of string as a gsize,
not gint. Make parameters to functions take gsize,
or gssize where -1 is allowed.
* gstring.c (g_string_erase): Make
g_string_erase (string, pos, -1) a synonym for
g_string_truncate for consistency with other G*
APIs.
* gstrfuncs.[ch]: Make all functions taking a string
length, take a gsize, or gssize if -1 is allowed.
(g_strstr_len, g_strrstr_len). Also fix some boundary
conditions in g_str[r]str[_len].
* gutf8.c tests/unicode-encoding.c: Make parameters that
are byte lengths gsize, gssize as appropriate. Make
character offsets, other counts, glong.
* gasyncqueue.c gcompletion.c
timeloop.c timeloop-basic.c gutils.c gspawn.c.
Small 64 bit cleanliness fixups.
* glist.c (g_list_sort2, g_list_sort_real): Fix functions
that should have been static.
* gdate.c (g_date_fill_parse_tokens): Fix extra
declaration that was shadowing another.
* tests/module-test.c: Include string.h
Mon Jun 18 15:43:29 2001 Owen Taylor <otaylor@redhat.com>
* gutf8.c (g_get_charset): Make argument
G_CONST_RETURN char **.
2001-06-23 15:55:09 +02:00
|
|
|
|
gsize
|
1999-10-12 14:08:13 +02:00
|
|
|
|
g_printf_string_upper_bound (const gchar *format,
|
2011-10-02 05:38:52 +02:00
|
|
|
|
va_list args)
|
1999-10-12 14:08:13 +02:00
|
|
|
|
{
|
2001-12-06 23:37:05 +01:00
|
|
|
|
gchar c;
|
2002-11-21 01:35:15 +01:00
|
|
|
|
return _g_vsnprintf (&c, 1, format, args) + 1;
|
1999-10-12 14:08:13 +02:00
|
|
|
|
}
|