summaryrefslogtreecommitdiff
path: root/ACE/ace/Log_Category.inl
blob: a8314bcfaed647b1c7d231925029ac48e60c3984 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
// -*- C++ -*-
ACE_BEGIN_VERSIONED_NAMESPACE_DECL

ACE_INLINE unsigned int
ACE_Log_Category::id() const
{
  return id_;
}

ACE_INLINE const char*
ACE_Log_Category::name () const
{
  return name_;
}

ACE_INLINE unsigned int
ACE_Log_Category_TSS::id() const
{
  return category_->id_;
}

ACE_INLINE const char*
ACE_Log_Category_TSS::name () const
{
  return category_->name_;
}

ACE_INLINE ACE_Log_Msg*
ACE_Log_Category_TSS::logger ()
{
  return logger_;
}

/// Get the current ACE_Log_Priority mask.
ACE_INLINE u_long
ACE_Log_Category_TSS::priority_mask () const
{
  return priority_mask_;
}

/// Set the ACE_Log_Priority mask, returns original mask.
ACE_INLINE u_long
ACE_Log_Category_TSS::priority_mask (u_long n_mask)
{
  u_long o_mask = this->priority_mask_;
  this->priority_mask_ = n_mask;
  return o_mask;
}
/// Return true if the requested priority is enabled.
ACE_INLINE int
ACE_Log_Category_TSS::log_priority_enabled (ACE_Log_Priority log_priority)
{
  return ACE_BIT_ENABLED (this->priority_mask_ |
                          category_->priority_mask(),
                          log_priority);
}

ACE_INLINE void
ACE_Log_Category_TSS::set (const char *file,
                           int line,
                           int op_status,
                           int errnum)
{
  logger_->set(file, line, op_status, errnum, logger_->restart (), logger_->msg_ostream (), logger_->msg_callback ());
}

/// These values are only actually set if the requested priority is
/// enabled.
ACE_INLINE
void ACE_Log_Category_TSS::conditional_set (const char *file,
                                            int line,
                                            int op_status,
                                            int errnum)
{
  logger_->conditional_set(file, line, op_status, errnum);
}

#if !defined (ACE_LACKS_VA_FUNCTIONS)
ACE_INLINE ssize_t
ACE_Log_Category_TSS::log (ACE_Log_Priority priority, const ACE_TCHAR *format_str, ...)
{
  // Start of variable args section.
  va_list argp;

  va_start (argp, format_str);

  ssize_t const result = this->log (format_str,
                                    priority,
                                    argp);
  va_end (argp);

  return result;
}

#if defined (ACE_HAS_WCHAR)
ACE_INLINE ssize_t
ACE_Log_Category_TSS::log (ACE_Log_Priority priority, const ACE_ANTI_TCHAR *format_str, ...)
{
  // Start of variable args section.
  va_list argp;

  va_start (argp, format_str);

  ssize_t const result = this->log (ACE_TEXT_ANTI_TO_TCHAR (format_str),
                                    priority,
                                    argp);
  va_end (argp);

  return result;
}
#endif /* ACE_HAS_WCHAR */
#else /* ACE_LACKS_VA_FUNCTIONS */

ACE_INLINE ssize_t
ACE_Log_Category_TSS::log (const ACE_Log_Formatter &formatter)
{
  if (this->log_priority_enabled (formatter.priority ()))
    return logger_->log (formatter);

  return 0;
}

#endif /* ACE_LACKS_VA_FUNCTIONS */

/**
 * An alternative logging mechanism that makes it possible to
 * integrate variable argument lists from other logging mechanisms
 * into the ACE mechanism.
 */

ACE_INLINE ssize_t
ACE_Log_Category_TSS::log (const ACE_TCHAR *format,
                           ACE_Log_Priority priority,
                           va_list argp)
{
  if (this->log_priority_enabled (priority) == 0)
    return 0;
  return logger_->log(format, priority, argp, this);
}

ACE_INLINE ssize_t
ACE_Log_Category_TSS::log (ACE_Log_Record &log_record,
                           int suppress_stderr)
{
  return logger_->log(log_record, suppress_stderr);
}

ACE_INLINE int
ACE_Log_Category_TSS::log_hexdump (ACE_Log_Priority priority,
                                   const char *buffer,
                                   size_t size,
                                   const ACE_TCHAR *text)
{
  if (this->log_priority_enabled (priority) == 0)
    return 0;
  return logger_->log_hexdump(priority, buffer, size, text, this);
}

/// Get the current ACE_Log_Priority mask.
ACE_INLINE u_long
ACE_Log_Category::priority_mask () const
{
  return priority_mask_;
}

/// Set the ACE_Log_Priority mask, returns original mask.
ACE_INLINE u_long
ACE_Log_Category::priority_mask (u_long n_mask)
{
  u_long o_mask = this->priority_mask_;
  this->priority_mask_ = n_mask;
  return o_mask;
}

ACE_END_VERSIONED_NAMESPACE_DECL