VirtualBox

source: vbox/trunk/src/VBox/Runtime/common/log/logformat.cpp@ 9380

Last change on this file since 9380 was 8245, checked in by vboxsync, 17 years ago

rebranding: IPRT files again.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 4.1 KB
Line 
1/* $Id: logformat.cpp 8245 2008-04-21 17:24:28Z vboxsync $ */
2/** @file
3 * IPRT - Log Formatter.
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#include <iprt/string.h>
37#include <iprt/assert.h>
38#ifdef IN_RING3
39# include <iprt/thread.h>
40# include <iprt/err.h>
41#endif
42
43#include <iprt/stdarg.h>
44#include <iprt/string.h>
45
46
47/*******************************************************************************
48* Internal Functions *
49*******************************************************************************/
50static DECLCALLBACK(size_t) rtlogFormatStr(void *pvArg, PFNRTSTROUTPUT pfnOutput,
51 void *pvArgOutput, const char **ppszFormat,
52 va_list *pArgs, int cchWidth, int cchPrecision,
53 unsigned fFlags, char chArgSize);
54
55
56/**
57 * Partial vsprintf worker implementation.
58 *
59 * @returns number of bytes formatted.
60 * @param pfnOutput Output worker.
61 * Called in two ways. Normally with a string an it's length.
62 * For termination, it's called with NULL for string, 0 for length.
63 * @param pvArg Argument to output worker.
64 * @param pszFormat Format string.
65 * @param args Argument list.
66 */
67RTDECL(size_t) RTLogFormatV(PFNRTSTROUTPUT pfnOutput, void *pvArg, const char *pszFormat, va_list args)
68{
69 return RTStrFormatV(pfnOutput, pvArg, rtlogFormatStr, NULL, pszFormat, args);
70}
71
72
73/**
74 * Callback to format VBox formatting extentions.
75 * See @ref pg_rt_str_format_rt for a reference on the format types.
76 *
77 * @returns The number of bytes formatted.
78 * @param pvArg Formatter argument.
79 * @param pfnOutput Pointer to output function.
80 * @param pvArgOutput Argument for the output function.
81 * @param ppszFormat Pointer to the format string pointer. Advance this till the char
82 * after the format specifier.
83 * @param pArgs Pointer to the argument list. Use this to fetch the arguments.
84 * @param cchWidth Format Width. -1 if not specified.
85 * @param cchPrecision Format Precision. -1 if not specified.
86 * @param fFlags Flags (RTSTR_NTFS_*).
87 * @param chArgSize The argument size specifier, 'l' or 'L'.
88 */
89static DECLCALLBACK(size_t) rtlogFormatStr(void *pvArg, PFNRTSTROUTPUT pfnOutput, void *pvArgOutput,
90 const char **ppszFormat, va_list *pArgs, int cchWidth,
91 int cchPrecision, unsigned fFlags, char chArgSize)
92{
93 char ch = *(*ppszFormat)++;
94
95 AssertMsgFailed(("Invalid logger format type '%%%c%.10s'!\n", ch, *ppszFormat)); NOREF(ch);
96
97 return 0;
98}
99
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