summaryrefslogtreecommitdiff
path: root/src/libcamera/include/log.h
blob: 76acd15208685d50966880c347640bbfec647fa1 (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
/* 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 {
	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()

};

#endif /* __LIBCAMERA_LOG_H__ */