Repository navigation
Expand file tree
/
Copy pathbasic_formatter.h
More file actions
64 lines (57 loc) · 1.49 KB
/
Copy pathbasic_formatter.h
File metadata and controls
64 lines (57 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
////////////////////////////////////////////////////////////////////////////////
// Distributed under the Boost Software License, Version 1.0. //
// (See accompanying file LICENSE or copy at //
// https://www.boost.org/LICENSE_1_0.txt) //
////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <string>
#include "log/formatter.h"
#include "log/log_level.h"
namespace iris
{
/**
* Implementation of Formatter which formats log message details as:
* L T [t] F:L | M
*
* Where:
* L : First letter of log level
* T : Time stamp
* t : Tag
* F : Filename
* L : Line number
* M : message
*
* Example:
* D 17:38:28 [camera] camera.cpp:58 | x: -4.37114e-08 y: 0 z: -1
*/
class BasicFormatter : public Formatter
{
public:
/** Default */
~BasicFormatter() override = default;
/**
* Format the supplied log details into a string.
*
* @param level
* Log level.
*
* @param tag
* Tag for log message.
*
* @param message
* Log message.
*
* @param filename
* Name of the file logging the message.
*
* @param line
* Line of the log call in the file.
*/
std::string format(
const LogLevel level,
const std::string &tag,
const std::string &message,
const std::string &filename,
const int line) override;
};
}