summaryrefslogtreecommitdiff
path: root/src/libcamera/include/log.h
blob: 74439848c6ca43097d7e1a0a8bf9cc71a937d6fb (plain)
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
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
 * Copyright (C) 2018, Google Inc.
 *
 * log.h - Logging infrastructure
 */
#ifndef __LIBCAMERA_LOG_H__
#define __LIBCAMERA_LOG_H__

#include <sstream>

namespace libcamera {

enum LogSeverity {
	LogDebug,
	LogInfo,
	LogWarning,
	LogError,
};

class LogMessage
{
public:
	LogMessage(const char *fileName, unsigned int line,
		  LogSeverity severity);
	LogMessage(const LogMessage&) = delete;
	~LogMessage();

	std::ostream& stream() { return msgStream; }

private:
	std::ostringstream msgStream;
};

#define LOG(severity) LogMessage(__FILE__, __LINE__, Log##severity).stream()

} /* namespace libcamera */

#endif /* __LIBCAMERA_LOG_H__ */