Ultibo API
C/C++ API for Ultibo Core
Loading...
Searching...
No Matches
logging.h File Reference
#include "ultibo/globaltypes.h"
#include "ultibo/globalconst.h"
#include "ultibo/devices.h"
#include "ultibo/console.h"

Go to the source code of this file.

Data Structures

struct  _LOGGING_ENTRY
struct  _LOGGING_ENTRY_EX
struct  _LOGGING_DEVICE

Macros

#define LOGGING_NAME_PREFIX   "Logging"
 Name prefix for Logging Devices.
#define LOGGING_THREAD_NAME   "Logging"
 Thread name for Logging threads.
#define LOGGING_THREAD_PRIORITY   THREAD_PRIORITY_NORMAL
 Thread priority for Logging threads.
#define LOGGING_TYPE_NONE   0
#define LOGGING_TYPE_CONSOLE   1
#define LOGGING_TYPE_FILE   2
#define LOGGING_TYPE_SYSLOG   3
#define LOGGING_TYPE_SERIAL   4
#define LOGGING_STATE_DISABLED   0
#define LOGGING_STATE_ENABLED   1
#define LOGGING_FLAG_NONE   0x00000000
#define CONSOLE_LOGGING_DESCRIPTION   "Console Logging"

Typedefs

typedef struct _LOGGING_ENTRY LOGGING_ENTRY
typedef struct _LOGGING_ENTRY_EX LOGGING_ENTRY_EX
typedef struct _LOGGING_DEVICE LOGGING_DEVICE
typedef uint32_t STDCALL(* logging_enumerate_cb) (LOGGING_DEVICE *logging, void *data)
typedef uint32_t STDCALL(* logging_notification_cb) (DEVICE *device, void *data, uint32_t notification)
typedef uint32_t STDCALL(* logging_device_start_proc) (LOGGING_DEVICE *logging)
typedef uint32_t STDCALL(* logging_device_stop_proc) (LOGGING_DEVICE *logging)
typedef uint32_t STDCALL(* logging_device_output_proc) (LOGGING_DEVICE *logging, const char *data)
typedef uint32_t STDCALL(* logging_device_output_ex_proc) (LOGGING_DEVICE *logging, uint32_t facility, uint32_t severity, const char *tag, const char *content)
 Syslog compatible output.
typedef char *STDCALL(* logging_device_get_target_proc) (LOGGING_DEVICE *logging)
typedef uint32_t STDCALL(* logging_device_set_target_proc) (LOGGING_DEVICE *logging, const char *target)

Functions

uint32_t STDCALL logging_device_start (LOGGING_DEVICE *logging)
uint32_t STDCALL logging_device_stop (LOGGING_DEVICE *logging)
uint32_t STDCALL logging_device_output (LOGGING_DEVICE *logging, const char *data)
uint32_t STDCALL logging_device_output_ex (LOGGING_DEVICE *logging, uint32_t facility, uint32_t severity, const char *tag, const char *content)
uint32_t STDCALL logging_device_get_target (LOGGING_DEVICE *logging, char *target, uint32_t len)
uint32_t STDCALL logging_device_set_target (LOGGING_DEVICE *logging, const char *target)
LOGGING_DEVICE *STDCALL logging_device_create (BOOL _default)
 Create a new Logging device entry.
LOGGING_DEVICE *STDCALL logging_device_create_ex (uint32_t size, BOOL _default)
 Create a new Logging device entry.
uint32_t STDCALL logging_device_destroy (LOGGING_DEVICE *logging)
 Destroy an existing Logging device entry.
uint32_t STDCALL logging_device_register (LOGGING_DEVICE *logging)
 Register a new Logging device in the Logging table.
uint32_t STDCALL logging_device_deregister (LOGGING_DEVICE *logging)
 Deregister a Logging device from the Logging table.
LOGGING_DEVICE *STDCALL logging_device_find (uint32_t loggingid)
LOGGING_DEVICE *STDCALL logging_device_find_by_type (uint32_t loggingtype)
LOGGING_DEVICE *STDCALL logging_device_find_by_device (DEVICE *device)
LOGGING_DEVICE *STDCALL logging_device_find_by_name (const char *name)
LOGGING_DEVICE *STDCALL logging_device_find_by_description (const char *description)
uint32_t STDCALL logging_device_enumerate (logging_enumerate_cb callback, void *data)
uint32_t STDCALL logging_device_notification (LOGGING_DEVICE *logging, logging_notification_cb callback, void *data, uint32_t notification, uint32_t flags)
int STDCALL logging_device_outputf (LOGGING_DEVICE *logging, const char *format,...) _ATTRIBUTE((__format__(__printf__
 Output formatted text to a Logging device.
int STDCALL uint32_t STDCALL logging_device_get_count (void)
 Get the current logging device count.
LOGGING_DEVICE *STDCALL logging_device_get_default (void)
 Get the current default logging device.
uint32_t STDCALL logging_device_set_default (LOGGING_DEVICE *logging)
 Set the current default logging device.
LOGGING_DEVICE *STDCALL logging_device_check (LOGGING_DEVICE *logging)
 Check if the supplied Logging device is in the Logging table.
uint32_t STDCALL logging_type_to_string (uint32_t loggingtype, char *string, uint32_t len)
 Convert a Logging type value to a string.
uint32_t STDCALL logging_state_to_string (uint32_t loggingstate, char *string, uint32_t len)
 Convert a Logging state value to a string.
BOOL STDCALL logging_device_redirect_output (LOGGING_DEVICE *logging)
 Redirect standard output to the logging device specified by Logging.
uint32_t STDCALL logging_get_messageslot_flags (void)
 Get the lock flags for the logging messageslot.
uint32_t STDCALL logging_console_device_add (CONSOLE_DEVICE *console)
uint32_t STDCALL logging_console_device_remove (CONSOLE_DEVICE *console)

Macro Definition Documentation

◆ LOGGING_NAME_PREFIX

#define LOGGING_NAME_PREFIX   "Logging"

Name prefix for Logging Devices.

Logging specific constants

◆ LOGGING_THREAD_NAME

#define LOGGING_THREAD_NAME   "Logging"

Thread name for Logging threads.

◆ LOGGING_THREAD_PRIORITY

#define LOGGING_THREAD_PRIORITY   THREAD_PRIORITY_NORMAL

Thread priority for Logging threads.

◆ LOGGING_TYPE_NONE

#define LOGGING_TYPE_NONE   0

Logging Device Types

◆ LOGGING_TYPE_CONSOLE

#define LOGGING_TYPE_CONSOLE   1

◆ LOGGING_TYPE_FILE

#define LOGGING_TYPE_FILE   2

◆ LOGGING_TYPE_SYSLOG

#define LOGGING_TYPE_SYSLOG   3

◆ LOGGING_TYPE_SERIAL

#define LOGGING_TYPE_SERIAL   4

◆ LOGGING_STATE_DISABLED

#define LOGGING_STATE_DISABLED   0

Logging Device States

◆ LOGGING_STATE_ENABLED

#define LOGGING_STATE_ENABLED   1

◆ LOGGING_FLAG_NONE

#define LOGGING_FLAG_NONE   0x00000000

Logging Device Flags

◆ CONSOLE_LOGGING_DESCRIPTION

#define CONSOLE_LOGGING_DESCRIPTION   "Console Logging"

Console Logging specific constants

Typedef Documentation

◆ LOGGING_ENTRY

typedef struct _LOGGING_ENTRY LOGGING_ENTRY

Logging specific types

◆ LOGGING_ENTRY_EX

◆ LOGGING_DEVICE

◆ logging_enumerate_cb

typedef uint32_t STDCALL(* logging_enumerate_cb) (LOGGING_DEVICE *logging, void *data)

Logging Enumeration Callback

◆ logging_notification_cb

typedef uint32_t STDCALL(* logging_notification_cb) (DEVICE *device, void *data, uint32_t notification)

Logging Notification Callback

◆ logging_device_start_proc

typedef uint32_t STDCALL(* logging_device_start_proc) (LOGGING_DEVICE *logging)

Logging Device Methods

◆ logging_device_stop_proc

typedef uint32_t STDCALL(* logging_device_stop_proc) (LOGGING_DEVICE *logging)

◆ logging_device_output_proc

typedef uint32_t STDCALL(* logging_device_output_proc) (LOGGING_DEVICE *logging, const char *data)

◆ logging_device_output_ex_proc

typedef uint32_t STDCALL(* logging_device_output_ex_proc) (LOGGING_DEVICE *logging, uint32_t facility, uint32_t severity, const char *tag, const char *content)

Syslog compatible output.

◆ logging_device_get_target_proc

typedef char *STDCALL(* logging_device_get_target_proc) (LOGGING_DEVICE *logging)

◆ logging_device_set_target_proc

typedef uint32_t STDCALL(* logging_device_set_target_proc) (LOGGING_DEVICE *logging, const char *target)

Function Documentation

◆ logging_device_start()

uint32_t STDCALL logging_device_start ( LOGGING_DEVICE * logging)

Logging Functions

◆ logging_device_stop()

uint32_t STDCALL logging_device_stop ( LOGGING_DEVICE * logging)

◆ logging_device_output()

uint32_t STDCALL logging_device_output ( LOGGING_DEVICE * logging,
const char * data )

◆ logging_device_output_ex()

uint32_t STDCALL logging_device_output_ex ( LOGGING_DEVICE * logging,
uint32_t facility,
uint32_t severity,
const char * tag,
const char * content )

◆ logging_device_get_target()

uint32_t STDCALL logging_device_get_target ( LOGGING_DEVICE * logging,
char * target,
uint32_t len )

◆ logging_device_set_target()

uint32_t STDCALL logging_device_set_target ( LOGGING_DEVICE * logging,
const char * target )

◆ logging_device_create()

LOGGING_DEVICE *STDCALL logging_device_create ( BOOL _default)

Create a new Logging device entry.

Parameters
DefaultIf true make the new device the default logging device if there is no current default
Returns
Pointer to new Logging device entry or nil if Logging device could not be created

◆ logging_device_create_ex()

LOGGING_DEVICE *STDCALL logging_device_create_ex ( uint32_t size,
BOOL _default )

Create a new Logging device entry.

Parameters
SizeSize in bytes to allocate for new Logging (Including the Logging entry)
DefaultIf true make the new device the default logging device if there is no current default
Returns
Pointer to new Logging device entry or nil if Logging device could not be created

◆ logging_device_destroy()

uint32_t STDCALL logging_device_destroy ( LOGGING_DEVICE * logging)

Destroy an existing Logging device entry.

◆ logging_device_register()

uint32_t STDCALL logging_device_register ( LOGGING_DEVICE * logging)

Register a new Logging device in the Logging table.

◆ logging_device_deregister()

uint32_t STDCALL logging_device_deregister ( LOGGING_DEVICE * logging)

Deregister a Logging device from the Logging table.

◆ logging_device_find()

LOGGING_DEVICE *STDCALL logging_device_find ( uint32_t loggingid)

◆ logging_device_find_by_type()

LOGGING_DEVICE *STDCALL logging_device_find_by_type ( uint32_t loggingtype)

◆ logging_device_find_by_device()

LOGGING_DEVICE *STDCALL logging_device_find_by_device ( DEVICE * device)

◆ logging_device_find_by_name()

LOGGING_DEVICE *STDCALL logging_device_find_by_name ( const char * name)

◆ logging_device_find_by_description()

LOGGING_DEVICE *STDCALL logging_device_find_by_description ( const char * description)

◆ logging_device_enumerate()

uint32_t STDCALL logging_device_enumerate ( logging_enumerate_cb callback,
void * data )

◆ logging_device_notification()

uint32_t STDCALL logging_device_notification ( LOGGING_DEVICE * logging,
logging_notification_cb callback,
void * data,
uint32_t notification,
uint32_t flags )

◆ logging_device_outputf()

int STDCALL logging_device_outputf ( LOGGING_DEVICE * logging,
const char * format,
... )

Output formatted text to a Logging device.

Parameters
LoggingThe logging device to output text to
FormatThe formatted text to output (As per printf in standard C library)
Returns
On success the total number of characters output to the logging device, on error a negative value is returned and errno is set to the error code

◆ logging_device_get_count()

int STDCALL uint32_t STDCALL logging_device_get_count ( void )

Get the current logging device count.

Logging Helper Functions

◆ logging_device_get_default()

LOGGING_DEVICE *STDCALL logging_device_get_default ( void )

Get the current default logging device.

◆ logging_device_set_default()

uint32_t STDCALL logging_device_set_default ( LOGGING_DEVICE * logging)

Set the current default logging device.

◆ logging_device_check()

LOGGING_DEVICE *STDCALL logging_device_check ( LOGGING_DEVICE * logging)

Check if the supplied Logging device is in the Logging table.

◆ logging_type_to_string()

uint32_t STDCALL logging_type_to_string ( uint32_t loggingtype,
char * string,
uint32_t len )

Convert a Logging type value to a string.

◆ logging_state_to_string()

uint32_t STDCALL logging_state_to_string ( uint32_t loggingstate,
char * string,
uint32_t len )

Convert a Logging state value to a string.

◆ logging_device_redirect_output()

BOOL STDCALL logging_device_redirect_output ( LOGGING_DEVICE * logging)

Redirect standard output to the logging device specified by Logging.

Parameters
LoggingThe logging device to redirect output to (or nil to stop redirection)
Returns
True if completed successfully or False if an error occurred
Note
Redirects the output of the text files Output, ErrOutput, StdOut and StdErr which also redirects the output of Write, WriteLn and the standard C library

◆ logging_get_messageslot_flags()

uint32_t STDCALL logging_get_messageslot_flags ( void )

Get the lock flags for the logging messageslot.

◆ logging_console_device_add()

uint32_t STDCALL logging_console_device_add ( CONSOLE_DEVICE * console)

◆ logging_console_device_remove()

uint32_t STDCALL logging_console_device_remove ( CONSOLE_DEVICE * console)