rlog: rlog::StdioNode Class Reference

- Main Page
- Modules
- Classes
- Files
- Related Pages

- Class List
- Class Hierarchy
- Class Members

# rlog::StdioNode Class Reference

Logs subscribed messages to a file descriptor. More...

`#include <rlog/StdioNode.h>`

Inheritance diagram for rlog::StdioNode:

List of all members.

## Public Types
enum | StdioFlags { DefaultOutput = 0, OutputColor = 1, OutputThreadId = 2, OutputContext = 4, OutputChannel = 8 }
## Public Member Functions
| StdioNode (int fdOut=2, int flags=(int) DefaultOutput)
| StdioNode (int fdOut, bool colorize_if_tty)
void | subscribeTo (RLogNode *node)
## Protected Member Functions
virtual void | publish (const RLogData &data)
| Publish data.
| StdioNode (const StdioNode &)
StdioNode & | operator= (const StdioNode &)
## Protected Attributes
bool | colorize
bool | outputThreadId
bool | outputContext
bool | outputChannel
int | fdOut

## Detailed Description

Logs subscribed messages to a file descriptor.

This displays all subscribed messages to a file descriptor. If the output is a terminal, then the messages are colorized (yellow for warnings, red for errors).

For example, to log to stderr:

      int main(int argc, char **argv)
      {
          // tell RLog the program name..
          RLog_Init( argv[0] );

          // log to standard error
          StdioNode stdlog( STDERR_FILENO );

          // show all warning and error messages, no matter what component they
          // come from.
          stdlog.subscribeTo( GetGlobalChannel( "warning" ));
          stdlog.subscribeTo( GetGlobalChannel( "error" ));
      }

See also:
  RLogChannel

  RLOG_CHANNEL()

Author:
  Valient Gough

## Constructor & Destructor Documentation

StdioNode::StdioNode | ( | int | _fdOut = `2`,
|  | int | flags = `(int)DefaultOutput` |
| ) |  |  |

Parameters:

  | _fdOut | File descriptor to send output
  | flags | bitmask of the following options:
            OutputChannel - Includes the channel name in the output. e.g. [debug]
            OutputContext - Includes the filename and line number in the output. e.g. OpsecAgent.cpp:209
            OutputColor   - Output to a TTY is colored based on log level (not supported by Win32 console)
            OutputThreadId - Includes the thread id in the output e.g. [tid:37333936] (Not supported on Win32)

## Member Function Documentation

void StdioNode::subscribeTo | ( | RLogNode * | node | ) |

Subscribe to log messages.

Example:

       StdioNode log( STDERR_FILENO );
       // subscribe to error and warning messages
       log.subscribeTo( GetGlobalChannel("error" ));
       log.subscribeTo( RLOG_CHANNEL("warning" ));

void StdioNode::publish | ( | const RLogData & | data | ) | `[protected, virtual]`

Publish data.

This iterates over the list of subscribers which have stated interest and sends them the data.

Reimplemented from rlog::RLogNode.

The documentation for this class was generated from the following files:

- StdioNode.h
- StdioNode.cpp