| 1 | /************************************************************************** |
|---|
| 2 | * Copyright (C) 2004-2007 by Michael Medin <michael@medin.name> * |
|---|
| 3 | * * |
|---|
| 4 | * This code is part of NSClient++ - http://trac.nakednuns.org/nscp * |
|---|
| 5 | * * |
|---|
| 6 | * This program is free software; you can redistribute it and/or modify * |
|---|
| 7 | * it under the terms of the GNU General Public License as published by * |
|---|
| 8 | * the Free Software Foundation; either version 2 of the License, or * |
|---|
| 9 | * (at your option) any later version. * |
|---|
| 10 | * * |
|---|
| 11 | * This program is distributed in the hope that it will be useful, * |
|---|
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
|---|
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
|---|
| 14 | * GNU General Public License for more details. * |
|---|
| 15 | * * |
|---|
| 16 | * You should have received a copy of the GNU General Public License * |
|---|
| 17 | * along with this program; if not, write to the * |
|---|
| 18 | * Free Software Foundation, Inc., * |
|---|
| 19 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
|---|
| 20 | ***************************************************************************/ |
|---|
| 21 | #pragma once |
|---|
| 22 | |
|---|
| 23 | NSC_WRAPPERS_MAIN(); |
|---|
| 24 | |
|---|
| 25 | class FileLogger { |
|---|
| 26 | private: |
|---|
| 27 | std::string file_; |
|---|
| 28 | std::string format_; |
|---|
| 29 | bool init_; |
|---|
| 30 | int log_mask_; |
|---|
| 31 | |
|---|
| 32 | public: |
|---|
| 33 | FileLogger(); |
|---|
| 34 | virtual ~FileLogger(); |
|---|
| 35 | // Module calls |
|---|
| 36 | bool loadModule(NSCAPI::moduleLoadMode mode); |
|---|
| 37 | bool unloadModule(); |
|---|
| 38 | std::wstring getConfigurationMeta(); |
|---|
| 39 | |
|---|
| 40 | |
|---|
| 41 | std::wstring getModuleName() { |
|---|
| 42 | return _T("File logger"); |
|---|
| 43 | } |
|---|
| 44 | NSCModuleWrapper::module_version getModuleVersion() { |
|---|
| 45 | NSCModuleWrapper::module_version version = {0, 0, 1 }; |
|---|
| 46 | return version; |
|---|
| 47 | } |
|---|
| 48 | std::wstring getModuleDescription() { |
|---|
| 49 | return _T("Writes errors and (if configured) debug info to a text file."); |
|---|
| 50 | } |
|---|
| 51 | |
|---|
| 52 | bool hasCommandHandler(); |
|---|
| 53 | bool hasMessageHandler(); |
|---|
| 54 | void handleMessage(int msgType, TCHAR* file, int line, const TCHAR* message); |
|---|
| 55 | int handleCommand(TCHAR* command, TCHAR **argument, TCHAR *returnBuffer, int returnBufferLen); |
|---|
| 56 | //void writeEntry(std::wstring line); |
|---|
| 57 | |
|---|
| 58 | |
|---|
| 59 | std::string getFileName(); |
|---|
| 60 | inline std::wstring FileLogger::get_formated_date(); |
|---|
| 61 | |
|---|
| 62 | }; |
|---|