EtcPal  HEAD (unstable)
ETC Platform Abstraction Layer (EtcPal)
View other versions:
log.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2022 ETC Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *******************************************************************************
16  * This file is a part of EtcPal. For more information, go to:
17  * https://github.com/ETCLabs/EtcPal
18  ******************************************************************************/
19 
22 
23 #ifndef ETCPAL_CPP_LOG_H_
24 #define ETCPAL_CPP_LOG_H_
25 
26 #include <array>
27 #include <cstdarg>
28 #include <cstdio>
29 #include <cstring>
30 #include <memory>
31 #include <queue>
32 #include <string>
33 #include "etcpal/common.h"
34 #include "etcpal/log.h"
35 #include "etcpal/cpp/common.h"
36 #include "etcpal/cpp/mutex.h"
37 #include "etcpal/cpp/signal.h"
38 #include "etcpal/cpp/thread.h"
39 
40 namespace etcpal
41 {
118 
123 {
124 public:
126  LogTimestamp() = default;
127  constexpr LogTimestamp(unsigned int year,
128  unsigned int month,
129  unsigned int day,
130  unsigned int hour,
131  unsigned int minute,
132  unsigned int second,
133  unsigned int msec = 0,
134  int utc_offset = 0);
135 
136  bool IsValid() const noexcept;
137 
138  constexpr const EtcPalLogTimestamp& get() const noexcept;
140 
141  static LogTimestamp Invalid();
142 
143 private:
144  EtcPalLogTimestamp timestamp_{};
145 };
146 
156 constexpr LogTimestamp::LogTimestamp(unsigned int year,
157  unsigned int month,
158  unsigned int day,
159  unsigned int hour,
160  unsigned int minute,
161  unsigned int second,
162  unsigned int msec,
163  int utc_offset)
164  : timestamp_{year, month, day, hour, minute, second, msec, utc_offset}
165 {
166 }
167 
169 inline bool LogTimestamp::IsValid() const noexcept
170 {
171  return etcpal_validate_log_timestamp(&timestamp_);
172 }
173 
175 constexpr const EtcPalLogTimestamp& LogTimestamp::get() const noexcept
176 {
177  return timestamp_;
178 }
179 
182 {
183  return timestamp_;
184 }
185 
188 {
189  return LogTimestamp{};
190 }
191 
199 {
200 public:
201  virtual LogTimestamp GetLogTimestamp();
202 
213  virtual void HandleLogMessage(const EtcPalLogStrings& strings) = 0;
214 };
215 
219 {
220  return LogTimestamp::Invalid();
221 }
222 
226 {
227  kDirect,
228  kQueued
229 };
230 
236 class Logger
237 {
238 public:
239  Logger();
240 
241  bool Startup(LogMessageHandler& message_handler);
242  void Shutdown();
243 
244  bool CanLog(int pri) const noexcept;
245  void Log(int pri, const char* format, ...);
246 
249  void Debug(const char* format, ...);
250  void Info(const char* format, ...);
251  void Notice(const char* format, ...);
252  void Warning(const char* format, ...);
253  void Error(const char* format, ...);
254  void Critical(const char* format, ...);
255  void Alert(const char* format, ...);
256  void Emergency(const char* format, ...);
258 
261  LogDispatchPolicy dispatch_policy() const noexcept;
262  int log_mask() const noexcept;
263  int log_action() const noexcept;
264  int syslog_facility() const noexcept;
265  const char* syslog_hostname() const noexcept;
266  const char* syslog_app_name() const noexcept;
267  const char* syslog_procid() const noexcept;
268  const EtcPalLogParams& log_params() const noexcept;
270 
273  Logger& SetDispatchPolicy(LogDispatchPolicy new_policy) noexcept;
274  Logger& SetLogMask(int log_mask) noexcept;
275  Logger& SetLogAction(int log_action) noexcept;
276  Logger& SetSyslogFacility(int facility) noexcept;
277  Logger& SetSyslogHostname(const char* hostname) noexcept;
278  Logger& SetSyslogHostname(const std::string& hostname) noexcept;
279  Logger& SetSyslogAppName(const char* app_name) noexcept;
280  Logger& SetSyslogAppName(const std::string& app_name) noexcept;
281  Logger& SetSyslogProcId(const char* proc_id) noexcept;
282  Logger& SetSyslogProcId(const std::string& proc_id) noexcept;
283  Logger& SetSyslogProcId(int proc_id) noexcept;
284 
285  Logger& SetThreadPriority(unsigned int priority) noexcept;
286  Logger& SetThreadStackSize(unsigned int stack_size) noexcept;
287  Logger& SetThreadName(const char* name) noexcept;
288  Logger& SetThreadName(const std::string& name) noexcept;
289  Logger& SetThreadPlatformData(void* platform_data) noexcept;
291 
292 private:
293  void LogInternal(int pri, const char* format, std::va_list args);
294  void LogThreadRun();
295  void EmptyLogQueue();
296 
298  EtcPalLogParams log_params_{};
299 
300  struct LogMessage
301  {
302  int pri;
303  std::array<char, ETCPAL_RAW_LOG_MSG_MAX_LEN> buf;
304  };
305 
306  // Used when dispatch_policy_ == Queued
307  // This implementation will become more elegant with the addition of new queue APIs. This is
308  // being tracked with ETCPAL-43 and ETCPAL-46.
309  std::queue<LogMessage> msg_q_;
310  std::unique_ptr<etcpal::Signal> signal_;
311  std::unique_ptr<etcpal::Signal> stop_signal_;
312  std::unique_ptr<etcpal::Mutex> mutex_;
313  etcpal::Thread thread_;
314  bool initialized_{false};
315 };
316 
318 
319 extern "C" inline void LogCallbackFn(void* context, const EtcPalLogStrings* strings)
320 {
321  if (context && strings)
322  {
323  static_cast<LogMessageHandler*>(context)->HandleLogMessage(*strings);
324  }
325 }
326 
327 extern "C" inline void LogTimestampFn(void* context, EtcPalLogTimestamp* timestamp)
328 {
329  if (context && timestamp)
330  {
331  *timestamp = static_cast<LogMessageHandler*>(context)->GetLogTimestamp().get();
332  }
333 }
334 
336 
337 inline Logger::Logger()
338 {
339  // Default logging parameters
341  log_params_.log_fn = LogCallbackFn;
343  log_params_.time_fn = LogTimestampFn;
344  log_params_.context = nullptr;
345 }
346 
353 inline bool Logger::Startup(LogMessageHandler& message_handler)
354 {
356  return false;
357 
358  if (!etcpal_validate_log_params(&log_params_))
359  {
361  return false;
362  }
363 
364  signal_ = std::unique_ptr<etcpal::Signal>(new etcpal::Signal);
365  stop_signal_ = std::unique_ptr<etcpal::Signal>(new etcpal::Signal);
366  mutex_ = std::unique_ptr<etcpal::Mutex>(new etcpal::Mutex);
367 
368  if (!signal_ || !stop_signal_ || !mutex_)
369  {
371  return false;
372  }
373 
374  log_params_.context = &message_handler;
375  initialized_ = true;
376 
377  if (dispatch_policy_ == LogDispatchPolicy::kDirect)
378  return true;
379 
380  // kQueued
381  // Start the log dispatch thread
382  if (!thread_.SetName("EtcPalLoggerThread").Start(&Logger::LogThreadRun, this))
383  {
384  initialized_ = false;
386  return false;
387  }
388  return true;
389 }
390 
395 inline void Logger::Shutdown()
396 {
397  if (initialized_)
398  {
399  initialized_ = false;
400  stop_signal_->Notify();
401  if (dispatch_policy_ == LogDispatchPolicy::kQueued)
402  {
403  signal_->Notify();
404  thread_.Join();
405  }
407  log_params_.context = nullptr;
408  }
409 }
410 
414 inline bool Logger::CanLog(int pri) const noexcept
415 {
416  return etcpal_can_log(&log_params_, pri);
417 }
418 
426 inline void Logger::Log(int pri, const char* format, ...)
427 {
428  std::va_list args;
429  va_start(args, format);
430  LogInternal(pri, format, args);
431  va_end(args);
432 }
433 
435 inline void Logger::Debug(const char* format, ...)
436 {
437  std::va_list args;
438  va_start(args, format);
439  LogInternal(ETCPAL_LOG_DEBUG, format, args);
440  va_end(args);
441 }
442 
444 inline void Logger::Info(const char* format, ...)
445 {
446  std::va_list args;
447  va_start(args, format);
448  LogInternal(ETCPAL_LOG_INFO, format, args);
449  va_end(args);
450 }
451 
453 inline void Logger::Notice(const char* format, ...)
454 {
455  std::va_list args;
456  va_start(args, format);
457  LogInternal(ETCPAL_LOG_NOTICE, format, args);
458  va_end(args);
459 }
460 
462 inline void Logger::Warning(const char* format, ...)
463 {
464  std::va_list args;
465  va_start(args, format);
466  LogInternal(ETCPAL_LOG_WARNING, format, args);
467  va_end(args);
468 }
469 
471 inline void Logger::Error(const char* format, ...)
472 {
473  std::va_list args;
474  va_start(args, format);
475  LogInternal(ETCPAL_LOG_ERR, format, args);
476  va_end(args);
477 }
478 
480 inline void Logger::Critical(const char* format, ...)
481 {
482  std::va_list args;
483  va_start(args, format);
484  LogInternal(ETCPAL_LOG_CRIT, format, args);
485  va_end(args);
486 }
487 
489 inline void Logger::Alert(const char* format, ...)
490 {
491  std::va_list args;
492  va_start(args, format);
493  LogInternal(ETCPAL_LOG_ALERT, format, args);
494  va_end(args);
495 }
496 
498 inline void Logger::Emergency(const char* format, ...)
499 {
500  std::va_list args;
501  va_start(args, format);
502  LogInternal(ETCPAL_LOG_EMERG, format, args);
503  va_end(args);
504 }
505 
508 {
509  return dispatch_policy_;
510 }
511 
513 inline int Logger::log_mask() const noexcept
514 {
515  return log_params_.log_mask;
516 }
517 
519 inline int Logger::log_action() const noexcept
520 {
521  return log_params_.action;
522 }
523 
525 inline int Logger::syslog_facility() const noexcept
526 {
527  return log_params_.syslog_params.facility;
528 }
529 
531 inline const char* Logger::syslog_hostname() const noexcept
532 {
533  return log_params_.syslog_params.hostname;
534 }
535 
537 inline const char* Logger::syslog_app_name() const noexcept
538 {
539  return log_params_.syslog_params.app_name;
540 }
541 
543 inline const char* Logger::syslog_procid() const noexcept
544 {
545  return log_params_.syslog_params.procid;
546 }
547 
553 inline const EtcPalLogParams& Logger::log_params() const noexcept
554 {
555  return log_params_;
556 }
557 
564 {
565  dispatch_policy_ = new_policy;
566  return *this;
567 }
568 
576 inline Logger& Logger::SetLogMask(int log_mask) noexcept
577 {
578  log_params_.log_mask = log_mask;
579  return *this;
580 }
581 
583 inline Logger& Logger::SetLogAction(int log_action) noexcept
584 {
585  log_params_.action = log_action;
586  return *this;
587 }
588 
590 inline Logger& Logger::SetSyslogFacility(int facility) noexcept
591 {
592  log_params_.syslog_params.facility = facility;
593  return *this;
594 }
595 
597 inline Logger& Logger::SetSyslogHostname(const char* hostname) noexcept
598 {
599  ETCPAL_MSVC_NO_DEP_WRN strncpy(log_params_.syslog_params.hostname, hostname, ETCPAL_LOG_HOSTNAME_MAX_LEN - 1);
600  log_params_.syslog_params.hostname[ETCPAL_LOG_HOSTNAME_MAX_LEN - 1] = '\0';
601  return *this;
602 }
603 
605 inline Logger& Logger::SetSyslogHostname(const std::string& hostname) noexcept
606 {
607  SetSyslogHostname(hostname.c_str());
608  return *this;
609 }
610 
612 inline Logger& Logger::SetSyslogAppName(const char* app_name) noexcept
613 {
614  ETCPAL_MSVC_NO_DEP_WRN strncpy(log_params_.syslog_params.app_name, app_name, ETCPAL_LOG_APP_NAME_MAX_LEN - 1);
615  log_params_.syslog_params.app_name[ETCPAL_LOG_APP_NAME_MAX_LEN - 1] = '\0';
616  return *this;
617 }
618 
620 inline Logger& Logger::SetSyslogAppName(const std::string& app_name) noexcept
621 {
622  SetSyslogAppName(app_name.c_str());
623  return *this;
624 }
625 
627 inline Logger& Logger::SetSyslogProcId(const char* proc_id) noexcept
628 {
629  ETCPAL_MSVC_NO_DEP_WRN strncpy(log_params_.syslog_params.procid, proc_id, ETCPAL_LOG_PROCID_MAX_LEN - 1);
630  log_params_.syslog_params.procid[ETCPAL_LOG_PROCID_MAX_LEN - 1] = '\0';
631  return *this;
632 }
633 
635 inline Logger& Logger::SetSyslogProcId(const std::string& proc_id) noexcept
636 {
637  SetSyslogProcId(proc_id.c_str());
638  return *this;
639 }
640 
644 inline Logger& Logger::SetThreadPriority(unsigned int priority) noexcept
645 {
646  thread_.SetPriority(priority);
647  return *this;
648 }
649 
653 inline Logger& Logger::SetThreadStackSize(unsigned int stack_size) noexcept
654 {
655  thread_.SetStackSize(stack_size);
656  return *this;
657 }
658 
662 inline Logger& Logger::SetThreadName(const char* name) noexcept
663 {
664  thread_.SetName(name);
665  return *this;
666 }
667 
671 inline Logger& Logger::SetThreadName(const std::string& name) noexcept
672 {
673  thread_.SetName(name);
674  return *this;
675 }
676 
680 inline Logger& Logger::SetThreadPlatformData(void* platform_data) noexcept
681 {
682  thread_.SetPlatformData(platform_data);
683  return *this;
684 }
685 
687 inline Logger& Logger::SetSyslogProcId(int proc_id) noexcept
688 {
689  ETCPAL_MSVC_NO_DEP_WRN sprintf(log_params_.syslog_params.procid, "%d", proc_id);
690  return *this;
691 }
692 
693 // Private functions
694 
695 inline void Logger::LogInternal(int pri, const char* format, std::va_list args)
696 {
697  if (initialized_)
698  {
699  if (dispatch_policy_ == LogDispatchPolicy::kDirect)
700  {
701  etcpal_vlog(&log_params_, pri, format, args);
702  }
703  else
704  {
705  {
706  etcpal::MutexGuard lock(*mutex_);
707  msg_q_.emplace();
708  msg_q_.back().pri = pri;
709  vsnprintf(msg_q_.back().buf.data(), ETCPAL_RAW_LOG_MSG_MAX_LEN, format, args);
710  }
711  signal_->Notify();
712  }
713  }
714 }
715 
716 inline void Logger::LogThreadRun()
717 {
718  while (!stop_signal_->TryWait())
719  {
720  EmptyLogQueue();
721  signal_->Wait();
722  }
723  // Bail the queue one last time on exit
724  EmptyLogQueue();
725 }
726 
727 inline void Logger::EmptyLogQueue()
728 {
729  std::queue<LogMessage> to_log;
730  {
731  etcpal::MutexGuard lock(*mutex_);
732  to_log.swap(msg_q_);
733  }
734 
735  while (!to_log.empty())
736  {
737  etcpal_log(&log_params_, to_log.front().pri, "%s", to_log.front().buf.data());
738  to_log.pop();
739  }
740 }
741 
742 }; // namespace etcpal
743 
744 #endif // ETCPAL_CPP_LOG_H_
An interface which handles log messages.
Definition: log.h:199
virtual void HandleLogMessage(const EtcPalLogStrings &strings)=0
Define this function to handle log messages and determine what to do with them.
virtual LogTimestamp GetLogTimestamp()
Return a LogTimestamp representing the current local time.
Definition: log.h:218
An object representing the current local time with millisecond resolution for logging purposes.
Definition: log.h:123
constexpr const EtcPalLogTimestamp & get() const noexcept
Get a const reference to the underlying C type.
Definition: log.h:175
bool IsValid() const noexcept
Whether this timestamp represents a valid time.
Definition: log.h:169
LogTimestamp()=default
Construct an invalid timestamp by default.
static LogTimestamp Invalid()
Construct an invalid timestamp.
Definition: log.h:187
A class for dispatching log messages.
Definition: log.h:237
Logger & SetSyslogFacility(int facility) noexcept
Set the Syslog facility value; see RFC 5424 § 6.2.1.
Definition: log.h:590
void Critical(const char *format,...)
Log a message at critical priority.
Definition: log.h:480
void Info(const char *format,...)
Log a message at informational priority.
Definition: log.h:444
Logger & SetThreadPlatformData(void *platform_data) noexcept
Set the platform-specific parameter data of the log dispatch thread.
Definition: log.h:680
bool CanLog(int pri) const noexcept
Determine whether a priority level can be logged using the mask given via SetLogMask().
Definition: log.h:414
LogDispatchPolicy dispatch_policy() const noexcept
Get the current log dispatch policy.
Definition: log.h:507
Logger & SetLogAction(int log_action) noexcept
Set the types of log messages to create and dispatch to the LogMessageHandler.
Definition: log.h:583
void Error(const char *format,...)
Log a message at error priority.
Definition: log.h:471
int log_action() const noexcept
Get the current log action.
Definition: log.h:519
void Emergency(const char *format,...)
Log a message at emergency priority.
Definition: log.h:498
Logger & SetThreadStackSize(unsigned int stack_size) noexcept
Set the stack size of the log dispatch thread.
Definition: log.h:653
void Alert(const char *format,...)
Log a message at alert priority.
Definition: log.h:489
bool Startup(LogMessageHandler &message_handler)
Start logging.
Definition: log.h:353
int syslog_facility() const noexcept
Get the current Syslog facility value.
Definition: log.h:525
Logger & SetSyslogHostname(const char *hostname) noexcept
Set the Syslog HOSTNAME; see RFC 5424 § 6.2.4.
Definition: log.h:597
void Warning(const char *format,...)
Log a message at warning priority.
Definition: log.h:462
Logger & SetSyslogAppName(const char *app_name) noexcept
Set the Syslog APP-NAME; see RFC 5424 § 6.2.5.
Definition: log.h:612
const EtcPalLogParams & log_params() const noexcept
Get the log params used by this logger.
Definition: log.h:553
const char * syslog_hostname() const noexcept
Get the current Syslog HOSTNAME.
Definition: log.h:531
void Log(int pri, const char *format,...)
Log a message.
Definition: log.h:426
const char * syslog_procid() const noexcept
Get the current Syslog PROCID.
Definition: log.h:543
void Shutdown()
Stop logging.
Definition: log.h:395
const char * syslog_app_name() const noexcept
Get the current Syslog APP-NAME.
Definition: log.h:537
int log_mask() const noexcept
Get the current log mask.
Definition: log.h:513
Logger & SetThreadName(const char *name) noexcept
Set the name of the log dispatch thread.
Definition: log.h:662
Logger & SetLogMask(int log_mask) noexcept
Set a new log mask.
Definition: log.h:576
Logger & SetSyslogProcId(const char *proc_id) noexcept
Set the Syslog PROCID; see RFC 5424 § 6.2.6.
Definition: log.h:627
void Debug(const char *format,...)
Log a message at debug priority.
Definition: log.h:435
Logger & SetThreadPriority(unsigned int priority) noexcept
Set the priority of the log dispatch thread.
Definition: log.h:644
Logger & SetDispatchPolicy(LogDispatchPolicy new_policy) noexcept
Change the dispatch policy of this logger.
Definition: log.h:563
void Notice(const char *format,...)
Log a message at notice priority.
Definition: log.h:453
Lock guard around a mutex.
Definition: mutex.h:173
A wrapper class for the EtcPal mutex type.
Definition: mutex.h:88
A wrapper class for the EtcPal signal type.
Definition: signal.h:89
A thread class, modeled after std::thread.
Definition: thread.h:146
Error Start(Function &&func, Args &&... args)
Associate this thread object with a new thread of execution.
Definition: thread.h:428
Thread & SetName(const char *name) noexcept
Set the name of this thread.
Definition: thread.h:358
Error Join(int timeout_ms=ETCPAL_WAIT_FOREVER) noexcept
Wait for the thread to finish execution.
Definition: thread.h:462
Common definitions used by EtcPal C++ wrappers.
C++ wrapper and utilities for etcpal/mutex.h.
C++ wrapper and utilities for etcpal/signal.h.
C++ wrapper and utilities for etcpal/thread.h.
LogDispatchPolicy
Options for the method by which the Logger dispatches log messages.
Definition: log.h:226
@ kQueued
Log messages are queued and dispatched from another thread (recommended)
@ kDirect
Log messages propagate directly from Log() calls to output streams (normally only used for testing)
#define ETCPAL_CONSTEXPR_14
Stand-in for "constexpr" on entities that can only be defined "constexpr" in C++14 or later.
Definition: common.h:53
#define ETCPAL_CONSTEXPR_14_OR_INLINE
Defined to "constexpr" in C++14 or later, "inline" earlier.
Definition: common.h:54
@ kEtcPalErrOk
The call was successful, no error occurred.
Definition: error.h:51
#define ETCPAL_LOG_ERR
Error conditions.
Definition: log.h:189
#define ETCPAL_LOG_PROCID_MAX_LEN
Max length of the procid param.
Definition: log.h:209
#define ETCPAL_LOG_CRIT
Critical conditions.
Definition: log.h:188
#define ETCPAL_RAW_LOG_MSG_MAX_LEN
Max length of a log message string passed to etcpal_log() or etcpal_vlog().
Definition: log.h:212
#define ETCPAL_LOG_APP_NAME_MAX_LEN
Max length of the app_name param.
Definition: log.h:208
#define ETCPAL_LOG_NOTICE
Normal but significant condition.
Definition: log.h:191
void etcpal_vlog(const EtcPalLogParams *params, int pri, const char *format, va_list args)
Log a message with the list of format arguments already generated.
Definition: log.c:478
#define ETCPAL_LOG_CREATE_HUMAN_READABLE
Create a log string with a human-readable prefix including timestamp and severity.
Definition: log.h:351
#define ETCPAL_LOG_DEBUG
Debug-level messages.
Definition: log.h:193
bool etcpal_validate_log_timestamp(const EtcPalLogTimestamp *timestamp)
Determine whether the given EtcPalLogTimestamp is valid.
Definition: log.c:417
bool etcpal_validate_log_params(EtcPalLogParams *params)
Ensure that the given EtcPalLogParams are valid.
Definition: log.c:395
#define ETCPAL_LOG_INFO
Informational.
Definition: log.h:192
#define ETCPAL_LOG_EMERG
System is unusable.
Definition: log.h:186
void etcpal_log(const EtcPalLogParams *params, int pri, const char *format,...)
Log a message.
Definition: log.c:456
bool etcpal_can_log(const EtcPalLogParams *params, int pri)
Determine whether a priority level can be logged given the mask present in the log params.
Definition: log.c:439
#define ETCPAL_LOG_WARNING
Warning conditions.
Definition: log.h:190
#define ETCPAL_LOG_UPTO(pri)
Create a priority mask for all priorities through pri.
Definition: log.h:205
#define ETCPAL_LOG_ALERT
Action must be taken immediately.
Definition: log.h:187
#define ETCPAL_LOG_HOSTNAME_MAX_LEN
Max length of the hostname param.
Definition: log.h:207
void etcpal_deinit(etcpal_features_t features)
Deinitialize the EtcPal library.
Definition: common.c:193
etcpal_error_t etcpal_init(etcpal_features_t features)
Initialize the EtcPal library.
Definition: common.c:112
#define ETCPAL_FEATURE_LOGGING
Use the etcpal/log module.
Definition: common.h:140
A set of parameters used for the etcpal_*log() functions.
Definition: log.h:386
EtcPalSyslogParams syslog_params
The syslog header parameters.
Definition: log.h:392
EtcPalLogCallback log_fn
A callback function for the finished log string(s).
Definition: log.h:390
int action
What should be done when etcpal_log() or etcpal_vlog() is called.
Definition: log.h:388
int log_mask
A mask value that determines which priority messages can be logged.
Definition: log.h:394
EtcPalLogTimeFn time_fn
A callback function for the etcpal_log() and etcpal_vlog() functions to obtain the time from the appl...
Definition: log.h:399
void * context
Application context that will be passed back with the log callback function.
Definition: log.h:401
The set of log strings passed with a call to an etcpal_log_callback function.
Definition: log.h:299
A set of parameters which represent the current local time with millisecond resolution.
Definition: log.h:283
int facility
Syslog Facility; see RFC 5424 § 6.2.1.
Definition: log.h:361
char app_name[ETCPAL_LOG_APP_NAME_MAX_LEN]
Syslog APP-NAME; see RFC 5424 § 6.2.5.
Definition: log.h:365
char procid[ETCPAL_LOG_PROCID_MAX_LEN]
Syslog PROCID; see RFC 5424 § 6.2.6.
Definition: log.h:367
char hostname[ETCPAL_LOG_HOSTNAME_MAX_LEN]
Syslog HOSTNAME; see RFC 5424 § 6.2.4.
Definition: log.h:363