|
xentara-utils v2.1
The Xentara Utility Library
|
Streams that logs messages for a Windows service. More...
#include <xentara/utils/windows/service/LogStream.hpp>
Inheritance diagram for xentara::utils::windows::service::LogStream:Public Member Functions | |
| LogStream () | |
| Default constructor for a non-functional stream. | |
| LogStream (const EVENT_DESCRIPTOR &event) | |
| Creates a stream that logs to a specific event. | |
| LogStream (LogStream &&other) | |
| Move-constructor that moves the data and state from another stream. | |
| ~LogStream () | |
| Detsructor. | |
| auto | operator= (LogStream &&other) -> LogStream & |
| Move-assignemnt operator that moves the data and state from another stream. | |
| auto | open (const EVENT_DESCRIPTOR &event) -> void |
| Opens a stream that logs to a specific event. | |
| auto | close () -> void |
| Closes an open event. | |
| auto | is_open () const -> bool |
| Checks whether an event is associeated with the stream. | |
Public Member Functions inherited from std::ostream | |
| T | bad (T... args) |
| T | clear (T... args) |
| T | copyfmt (T... args) |
| T | eof (T... args) |
| T | exceptions (T... args) |
| T | fail (T... args) |
| T | fill (T... args) |
| T | flags (T... args) |
| T | flush (T... args) |
| T | getloc (T... args) |
| T | good (T... args) |
| T | imbue (T... args) |
| T | init (T... args) |
| T | iword (T... args) |
| T | move (T... args) |
| T | narrow (T... args) |
| T | operator bool (T... args) |
| T | operator! (T... args) |
| T | operator<< (T... args) |
| T | ostream (T... args) |
| T | precision (T... args) |
| T | put (T... args) |
| T | pword (T... args) |
| T | rdbuf (T... args) |
| T | rdstate (T... args) |
| T | register_callback (T... args) |
| T | seekp (T... args) |
| T | set_rdbuf (T... args) |
| T | setf (T... args) |
| T | setstate (T... args) |
| T | swap (T... args) |
| T | sync_with_stdio (T... args) |
| T | tellp (T... args) |
| T | tie (T... args) |
| T | unsetf (T... args) |
| T | widen (T... args) |
| T | width (T... args) |
| T | write (T... args) |
| T | xalloc (T... args) |
| T | ~ostream (T... args) |
Streams that logs messages for a Windows service.
This stream can be used logs messages to the event log of a Windows service. Messages are only logged the current process is running as a Windows service. You can determine whether the stream will log any messages by checking the stream’s fail bit.
The stream will log a single event every time it is flushed, and when it is destroyed or when another stream is opened.
| xentara::utils::windows::service::LogStream::LogStream | ( | ) |
Default constructor for a non-functional stream.
You can open an event using open(), or you can move-assign a valid stream.
| xentara::utils::windows::service::LogStream::LogStream | ( | const EVENT_DESCRIPTOR & | event | ) |
Creates a stream that logs to a specific event.
If the calling process is not running as a Windows service, the fail bit of the stream will be set. You can check for the fail bit by calling fail() or by using testing for !stream. Usually, you would do loggin like this:
| event | The event that should be used to log the messages. This event must belong to the provider identified by the kEventProvider of the service definition that was used to start the service, and it must have a single user data of type win:UnicodeString, that will be set to the message. |
| xentara::utils::windows::service::LogStream::LogStream | ( | LogStream && | other | ) |
Move-constructor that moves the data and state from another stream.
| xentara::utils::windows::service::LogStream::~LogStream | ( | ) |
Detsructor.
If the stream is open, then any unwritten data is written to the event.
| auto xentara::utils::windows::service::LogStream::close | ( | ) | -> void |
Closes an open event.
If the stream is open, then any unwritten data is written to the event before closing the stream. If the stream is not open, this function does nothing.
In either case, the stream’s fail bit is set to indicate that it is no longer open.
| auto xentara::utils::windows::service::LogStream::is_open | ( | ) | const -> bool |
Checks whether an event is associeated with the stream.
| auto xentara::utils::windows::service::LogStream::open | ( | const EVENT_DESCRIPTOR & | event | ) | -> void |
Opens a stream that logs to a specific event.
This function will attempt to open a stream that will write messages to the given event.
If the calling process is not running as a Windows service, the fail bit of the stream will be set. You can check for the fail bit by calling fail() or by using testing for !stream. Usually, you would do loggin like this:
If the stream is already open, the original stream will remain open, but the fail bit will be set. This is analogous to the behaviour of std::ofstream.
| event | The event that should be used to log the messages. This event must belong to the provider identified by the kEventProvider of the service definition that was used to start the service, and it must have a single user data of type win:UnicodeString, that will be set to the message. |