Coverage Report

Created: 2026-03-31 06:23

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/dcmtk/oflog/libsrc/logmacro.cc
Line
Count
Source
1
// Module:  Log4CPLUS
2
// File:    loggingmacros.cxx
3
// Created: 4/2010
4
// Author:  Vaclav Haisman
5
//
6
//
7
// Copyright 2010 Vaclav Haisman
8
//
9
// Licensed under the Apache License, Version 2.0 (the "License");
10
// you may not use this file except in compliance with the License.
11
// You may obtain a copy of the License at
12
//
13
//     http://www.apache.org/licenses/LICENSE-2.0
14
//
15
// Unless required by applicable law or agreed to in writing, software
16
// distributed under the License is distributed on an "AS IS" BASIS,
17
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
// See the License for the specific language governing permissions and
19
// limitations under the License.
20
21
/** @file
22
 * This file implements support function for logmacro.h file. */
23
24
#include "dcmtk/oflog/internal/internal.h"
25
#include "dcmtk/oflog/logmacro.h"
26
27
28
namespace dcmtk {
29
namespace log4cplus { namespace detail {
30
31
32
//! Helper stream to get the defaults from.
33
static tostringstream const macros_oss_defaults;
34
35
// Individual defaults.
36
37
static STD_NAMESPACE ios_base::fmtflags const default_flags
38
    = macros_oss_defaults.flags ();
39
static log4cplus::tchar const default_fill = macros_oss_defaults.fill ();
40
static STD_NAMESPACE streamsize const default_precision
41
    = macros_oss_defaults.precision ();
42
static STD_NAMESPACE streamsize const default_width = macros_oss_defaults.width ();
43
44
//! Clears string stream using defaults taken from macros_oss_defaults.
45
void
46
clear_tostringstream (tostringstream & os)
47
0
{
48
0
    os.clear ();
49
0
    os.str ("");
50
0
    os.setf (default_flags);
51
0
    os.fill (default_fill);
52
0
    os.precision (default_precision);
53
0
    os.width (default_width);
54
#if defined (DCMTK_LOG4CPLUS_WORKING_LOCALE)
55
    STD_NAMESPACE locale glocale = STD_NAMESPACE locale ();
56
    if (os.getloc () != glocale)
57
        os.imbue (glocale);
58
#endif // defined (DCMTK_LOG4CPLUS_WORKING_LOCALE)
59
0
}
60
61
62
log4cplus::tostringstream &
63
get_macro_body_oss ()
64
0
{
65
0
    tostringstream & oss = internal::get_ptd ()->macros_oss;
66
0
    clear_tostringstream (oss);
67
0
    return oss;
68
0
}
69
70
71
log4cplus::helpers::snprintf_buf &
72
get_macro_body_snprintf_buf ()
73
0
{
74
0
    return internal::get_ptd ()->snprintf_buf;
75
0
}
76
77
78
void
79
macro_forced_log (log4cplus::Logger const & logger,
80
    log4cplus::LogLevel log_level, log4cplus::tstring const & msg,
81
    char const * filename, int line, char const * func)
82
0
{
83
0
    log4cplus::spi::InternalLoggingEvent & ev = internal::get_ptd ()->forced_log_ev;
84
0
    ev.setLoggingEvent (logger.getName (), log_level, msg, filename, line);
85
0
    ev.setFunction (func ? func : "");
86
0
    logger.forcedLog (ev);
87
0
}
88
89
90
} } // namespace log4cplus { namespace detail {
91
} // end namespace dcmtk