VirtualBox

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

Last change on this file since 49329 was 48935, checked in by vboxsync, 11 years ago

Runtime: Whitespace and svn:keyword cleanups by scm.

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