VirtualBox

source: vbox/trunk/src/VBox/Runtime/common/log/logrel.cpp@ 17416

Last change on this file since 17416 was 13832, checked in by vboxsync, 16 years ago

IN_GC -> IN_RC.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 4.4 KB
Line 
1/* $Id: logrel.cpp 13832 2008-11-05 02:01:12Z vboxsync $ */
2/** @file
3 * Runtime VBox - Logger.
4 */
5
6/*
7 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 *
26 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
27 * Clara, CA 95054 USA or visit http://www.sun.com if you need
28 * additional information or have any questions.
29 */
30
31
32/*******************************************************************************
33* Header Files *
34*******************************************************************************/
35#include <iprt/log.h>
36#ifndef IN_RC
37# include <iprt/alloc.h>
38# include <iprt/process.h>
39# include <iprt/semaphore.h>
40# include <iprt/thread.h>
41# include <iprt/mp.h>
42#endif
43#ifdef IN_RING3
44# include <iprt/file.h>
45# include <iprt/path.h>
46#endif
47#include <iprt/time.h>
48#include <iprt/asm.h>
49#include <iprt/assert.h>
50#include <iprt/err.h>
51#include <iprt/param.h>
52
53#include <iprt/stdarg.h>
54#include <iprt/string.h>
55#include <iprt/ctype.h>
56#ifdef IN_RING3
57# include <iprt/alloca.h>
58# include <stdio.h>
59#endif
60
61
62/*******************************************************************************
63* Global Variables *
64*******************************************************************************/
65#ifdef IN_RC
66/** Default relese logger instance. */
67extern "C" DECLIMPORT(RTLOGGERRC) g_RelLogger;
68#else /* !IN_RC */
69/** Default release logger instance. */
70static PRTLOGGER g_pRelLogger;
71#endif /* !IN_RC */
72
73
74/**
75 * Gets the default release logger instance.
76 *
77 * @returns Pointer to default release logger instance.
78 * @returns NULL if no default release logger instance available.
79 */
80RTDECL(PRTLOGGER) RTLogRelDefaultInstance(void)
81{
82#ifdef IN_RC
83 return &g_RelLogger;
84#else /* !IN_RC */
85 return g_pRelLogger;
86#endif /* !IN_RC */
87}
88
89
90#ifndef IN_RC
91/**
92 * Sets the default logger instance.
93 *
94 * @returns iprt status code.
95 * @param pLogger The new default release logger instance.
96 */
97RTDECL(PRTLOGGER) RTLogRelSetDefaultInstance(PRTLOGGER pLogger)
98{
99 return (PRTLOGGER)ASMAtomicXchgPtr((void * volatile *)&g_pRelLogger, pLogger);
100}
101#endif /* !IN_RC */
102
103
104/**
105 * Write to a logger instance, defaulting to the release one.
106 *
107 * This function will check whether the instance, group and flags makes up a
108 * logging kind which is currently enabled before writing anything to the log.
109 *
110 * @param pLogger Pointer to logger instance. If NULL the default release instance is attempted.
111 * @param fFlags The logging flags.
112 * @param iGroup The group.
113 * The value ~0U is reserved for compatability with RTLogLogger[V] and is
114 * only for internal usage!
115 * @param pszFormat Format string.
116 * @param args Format arguments.
117 */
118RTDECL(void) RTLogRelLoggerV(PRTLOGGER pLogger, unsigned fFlags, unsigned iGroup, const char *pszFormat, va_list args)
119{
120 /*
121 * A NULL logger means default instance.
122 */
123 if (!pLogger)
124 {
125 pLogger = RTLogRelDefaultInstance();
126 if (!pLogger)
127 return;
128 }
129 RTLogLoggerExV(pLogger, fFlags, iGroup, pszFormat, args);
130}
131
132
133/**
134 * vprintf like function for writing to the default release log.
135 *
136 * @param pszFormat Printf like format string.
137 * @param args Optional arguments as specified in pszFormat.
138 *
139 * @remark The API doesn't support formatting of floating point numbers at the moment.
140 */
141RTDECL(void) RTLogRelPrintfV(const char *pszFormat, va_list args)
142{
143 RTLogRelLoggerV(NULL, 0, ~0U, pszFormat, args);
144}
145
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette