ilogger.hpp 1.48 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
/*******************************************************************************
 * Copyright 2019 UChicago Argonne, LLC.
 * (c.f. AUTHORS, LICENSE)
 *
 * This file is part of the Argo containers project.
 * For more info, see https://xgitlab.cels.anl.gov/argo/containers
 *
 * SPDX-License-Identifier: BSD-3-Clause
*******************************************************************************/

Swann Perarnau's avatar
Swann Perarnau committed
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
#ifndef __LOGGER_HPP__
#define __LOGGER_HPP__

#include "common.hpp"

class ILogger
{
	private:
		/*Not meant to be used*/
		ILogger(const ILogger& orig){}
		ILogger& operator = (const ILogger& orig){return *this;}

	protected:
		uid_t _ruid;
		Log_type _log_type; //could be or'ed-mask or multiple Log_types

		/*log_type is the or'ed log_types that this logger will actually log.
		 * Any log_type  that is not supported at construction time will just
		 * be silently thrown away when log is called*/
		ILogger(uid_t ruid, Log_type log_type = LOG_TYPE_ALL): _ruid(ruid), _log_type(log_type) {}
		virtual ~ILogger(){}

		void add_errno_in_log(const string& in_msg, int errnum, string &out_msg);

		//This is to be called before logging in log. Return false if
		//the logging must be ignored
		bool prepare_log(Log_type type, const string& msg_in, 
				string& msg_out, int errnum);

	public:

		/*log_type here is the log_type of the specific message being logged*/
		virtual void log(Log_type type, const string& message, int errnum = 0) = 0;
		virtual Log_dest log_destination() const =0;
};

#endif //__LOGGER_HPP__