Loading...
Searching...
No Matches
FormatOps Class Reference

FormatOps. More...

`#include <formats.h>`

## Classes

struct | LogsFormat
| Structure which holds informations about a log format. More...

## Public Member Functions

const LogsFormat | processApacheFormatString (const std::string &format_string)
| Processes the given string to extrapolate the format for Apache2. More...
const LogsFormat | processNginxFormatString (const std::string &format_string)
| Processes the given string to extrapolate the format for Nginx. More...
const LogsFormat | processIisFormatString (const std::string &format_string, const int &log_module)
| Processes the given string to extrapolate the format for the IIS. More...
const QString | getApacheLogSample (const LogsFormat &log_format)
| Returns a log line sample based on the given format. More...
const QString | getNginxLogSample (const LogsFormat &log_format)
| Returns a log line sample based on the given format. More...
const QString | getIisLogSample (const LogsFormat &log_format)
| Returns a log line sample based on the given format. More...

## Private Member Functions

const std::string | parseApacheEscapes (const std::string &string, const bool &strftime=false)
| Parses the escapes (backslashes) and returns the resulting string. More...
const std::string | parseNginxEscapes (const std::string &string)
| Parses the escapes (backslashes) and returns the resulting string. More...
const int | countNewLines (const std::string &initial, const std::string &final, const std::vector< std::string > &separators)
| Conuts how many new lines are there in the format. More...
const size_t | findNginxFieldEnd (const std::string &string, const int &start)
| Finds the end of a Nginx log field. More...
void | checkIisString (const std::string &string)
| Checks whether the format string contains invalid characters or not. More...

## Private Attributes

const std::unordered_map< std::string, std::string > | APACHE_ALF
| < Access logs fields formats More...
const std::unordered_map< std::string, std::string > | NGINX_ALF
| < Access logs fields formats
const std::unordered_map< std::string, std::string > | IIS_ALF
| < Access logs fields formats

## Detailed Description

FormatOps.

Operations for the logs formats

## Member Function Documentation

## checkIisString()

void FormatOps::checkIisString | ( | const std::string & | string | ) |

private

Checks whether the format string contains invalid characters or not.

Parameters

  string | The format string

Exceptions

  LogFormatException |

See also
  processIisFormatString

## countNewLines()

const int FormatOps::countNewLines | ( | const std::string & | initial,
|  | const std::string & | final,
|  | const std::vector< std::string > & | separators
| ) |  |

private

Conuts how many new lines are there in the format.

Used to join log lines which refer to the same log line

Parameters

  initial | The initial separator
  final | The final separator
  separators | The separators in the middle

Returns
  The number of new lines in a single log line

See also
  LogsFormat, processApacheFormatString(), processNginxFormatString()

## findNginxFieldEnd()

const size_t FormatOps::findNginxFieldEnd | ( | const std::string & | string,
|  | const int & | start
| ) |  |

private

Finds the end of a Nginx log field.

Parameters

  string | The format string
  start | The starting point of the field in the string

Returns
  The ending poin of the field in the string

See also
  processNginxFormatString()

## getApacheLogSample()

const QString FormatOps::getApacheLogSample | ( | const LogsFormat & | log_format | ) |

Returns a log line sample based on the given format.

Parameters

  log_format | The logs format to use to build the sample

Returns
  The sample line

See also
  LogsFormat, Craplog::getLogsFormatSample()

## getIisLogSample()

const QString FormatOps::getIisLogSample | ( | const LogsFormat & | log_format | ) |

Returns a log line sample based on the given format.

Parameters

  log_format | The logs format to use to build the sample

Returns
  The sample line

See also
  LogsFormat, Craplog::getLogsFormatSample()

## getNginxLogSample()

const QString FormatOps::getNginxLogSample | ( | const LogsFormat & | log_format | ) |

Returns a log line sample based on the given format.

Parameters

  log_format | The logs format to use to build the sample

Returns
  The sample line

See also
  LogsFormat, Craplog::getLogsFormatSample()

## parseApacheEscapes()

const std::string FormatOps::parseApacheEscapes | ( | const std::string & | string,
|  | const bool & | strftime = `false`
| ) |  |

private

Parses the escapes (backslashes) and returns the resulting string.

Used to obtain the same result as on Apache2

Parameters

  string | The string to parse
  strftime | Whether to apply the strftime special rule when parsing or not

Returns
  The resulting string

Exceptions

  LogFormatException |

See also
  processApacheFormatString()

## parseNginxEscapes()

const std::string FormatOps::parseNginxEscapes | ( | const std::string & | string | ) |

private

Parses the escapes (backslashes) and returns the resulting string.

Used to obtain the same result as on Nginx

Parameters

  string | The string to parse

Returns
  The resulting string

Exceptions

  LogFormatException |

See also
  processNginxFormatString()

## processApacheFormatString()

const FormatOps::LogsFormat FormatOps::processApacheFormatString | ( | const std::string & | format_string | ) |

Processes the given string to extrapolate the format for Apache2.

Parameters

  format_string | The format string to process

Returns
  The logs format

Exceptions

  LogFormatException |

See also
  LogsFormat

## processIisFormatString()

const FormatOps::LogsFormat FormatOps::processIisFormatString | ( | const std::string & | format_string,
|  | const int & | log_module
| ) |  |

Processes the given string to extrapolate the format for the IIS.

Parameters

  format_string | The format string to process
  log_module | The ID of the log module to use

Returns
  The logs format

Exceptions

  LogFormatException |

See also
  LogsFormat

## processNginxFormatString()

const FormatOps::LogsFormat FormatOps::processNginxFormatString | ( | const std::string & | format_string | ) |

Processes the given string to extrapolate the format for Nginx.

Parameters

  format_string | The format string to process

Returns
  The logs format

Exceptions

  LogFormatException |

See also
  LogsFormat

## Member Data Documentation

## APACHE_ALF

const std::unordered_map<std::string, std::string> FormatOps::APACHE_ALF

private

< Access logs fields formats

Composed access logs fields formats

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

- logdoctor/modules/craplog/modules/formats.h
- logdoctor/modules/craplog/modules/formats.cpp