diff options
author | Radek Novacek <rnovacek@redhat.com> | 2012-07-27 09:35:03 +0200 |
---|---|---|
committer | Radek Novacek <rnovacek@redhat.com> | 2012-07-27 09:35:03 +0200 |
commit | 171113535983029ab395341c8f8f3c92f320ea1a (patch) | |
tree | 2e7f2f064d29804666465166c114aa7f7845e134 /src/power | |
parent | 99b6e54a64d962d226679ca290117f114eaf8245 (diff) | |
download | openlmi-providers-171113535983029ab395341c8f8f3c92f320ea1a.tar.gz openlmi-providers-171113535983029ab395341c8f8f3c92f320ea1a.tar.xz openlmi-providers-171113535983029ab395341c8f8f3c92f320ea1a.zip |
Unify logging through all providers
Needs to be ported to sfcb/pegasus standard logging, using stderr for
now.
Diffstat (limited to 'src/power')
-rw-r--r-- | src/power/CMakeLists.txt | 4 | ||||
-rw-r--r-- | src/power/Linux_AssociatedPowerManagementServiceProvider.c | 28 | ||||
-rw-r--r-- | src/power/Linux_ConcreteJobProvider.c | 3 | ||||
-rw-r--r-- | src/power/Linux_HostedServiceProvider.c | 1 | ||||
-rw-r--r-- | src/power/Linux_PowerManagementServiceProvider.c | 12 | ||||
-rw-r--r-- | src/power/globals.c | 24 | ||||
-rw-r--r-- | src/power/globals.h | 7 | ||||
-rw-r--r-- | src/power/trace.c | 29 | ||||
-rw-r--r-- | src/power/trace.h | 4 |
9 files changed, 3 insertions, 109 deletions
diff --git a/src/power/CMakeLists.txt b/src/power/CMakeLists.txt index 4c06beb..606c1f3 100644 --- a/src/power/CMakeLists.txt +++ b/src/power/CMakeLists.txt @@ -5,8 +5,6 @@ set(MOF Linux_PowerManagement.mof) set(provider_SRCS power.c - trace.c - globals.c ) konkretcmpi_generate(${MOF} @@ -22,7 +20,7 @@ add_library(${LIBRARY_NAME} SHARED include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMPI_INCLUDE_DIR} ${GLIB_INCLUDE_DIRS}) -target_link_libraries(${LIBRARY_NAME} ${KONKRETCMPI_LIBRARIES} ${GLIB_LIBRARIES}) +target_link_libraries(${LIBRARY_NAME} curacommon ${KONKRETCMPI_LIBRARIES} ${GLIB_LIBRARIES}) # Check if we have upower and link it pkg_check_modules(UPOWER upower-glib) diff --git a/src/power/Linux_AssociatedPowerManagementServiceProvider.c b/src/power/Linux_AssociatedPowerManagementServiceProvider.c index 7d61d83..75be7d2 100644 --- a/src/power/Linux_AssociatedPowerManagementServiceProvider.c +++ b/src/power/Linux_AssociatedPowerManagementServiceProvider.c @@ -5,7 +5,6 @@ #include "power.h" -#include "trace.h" #include "globals.h" static const CMPIBroker* _cb; @@ -25,11 +24,8 @@ static CMPIStatus Linux_AssociatedPowerManagementServiceCleanup( const CMPIContext* cc, CMPIBoolean term) { - TRACE(1, "Linux_AssociatedPowerManagementServiceCleanup\n"); - power_unref(mi->hdl); mi->hdl = NULL; - CMReturn(CMPI_RC_OK); } @@ -39,8 +35,6 @@ static CMPIStatus Linux_AssociatedPowerManagementServiceEnumInstanceNames( const CMPIResult* cr, const CMPIObjectPath* cop) { - TRACE(1, "Linux_AssociatedPowerManagementServiceEnumInstanceNames\n"); - return KDefaultEnumerateInstanceNames( _cb, mi, cc, cr, cop); } @@ -52,8 +46,6 @@ static CMPIStatus Linux_AssociatedPowerManagementServiceEnumInstances( const CMPIObjectPath* cop, const char** properties) { - TRACE(1, "Linux_AssociatedPowerManagementServiceEnumInstances\n"); - const char *ns = KNameSpace(cop); Linux_AssociatedPowerManagementService w; @@ -95,8 +87,6 @@ static CMPIStatus Linux_AssociatedPowerManagementServiceGetInstance( const CMPIObjectPath* cop, const char** properties) { - TRACE(1, "Linux_AssociatedPowerManagementServiceGetInstance\n"); - return KDefaultGetInstance( _cb, mi, cc, cr, cop, properties); } @@ -164,12 +154,6 @@ static CMPIStatus Linux_AssociatedPowerManagementServiceAssociators( const char* resultRole, const char** properties) { - TRACE(1, "Linux_AssociatedPowerManagementServiceAssociators\n" - "\tassocClass: %s\n" - "\tresultClass: %s\n" - "\trole: %s\n" - "\tresultRole: %s\n", assocClass, resultClass, role, resultRole); - if (!assocClass) { assocClass = "Linux_AssociatedPowerManagementService"; } @@ -198,12 +182,6 @@ static CMPIStatus Linux_AssociatedPowerManagementServiceAssociatorNames( const char* role, const char* resultRole) { - TRACE(1, "Linux_AssociatedPowerManagementServiceAssociatorNames\n" - "\tassocClass: %s\n" - "\tresultClass: %s\n" - "\trole: %s\n" - "\tresultRole: %s\n", assocClass, resultClass, role, resultRole); - if (!assocClass) { assocClass = "Linux_AssociatedPowerManagementService"; } @@ -230,10 +208,6 @@ static CMPIStatus Linux_AssociatedPowerManagementServiceReferences( const char* role, const char** properties) { - TRACE(1, "Linux_AssociatedPowerManagementServiceReferences\n" - "\tassocClass: %s\n" - "\trole: %s\n", assocClass, role); - if (!assocClass) { assocClass = "Linux_AssociatedPowerManagementService"; } @@ -258,8 +232,6 @@ static CMPIStatus Linux_AssociatedPowerManagementServiceReferenceNames( const char* assocClass, const char* role) { - TRACE(1, "Linux_AssociatedPowerManagementServiceReferenceNames(assocClass: %s, role: %s)\n", assocClass, role); - if (!assocClass) { assocClass = "Linux_AssociatedPowerManagementService"; } diff --git a/src/power/Linux_ConcreteJobProvider.c b/src/power/Linux_ConcreteJobProvider.c index 361d045..96176fa 100644 --- a/src/power/Linux_ConcreteJobProvider.c +++ b/src/power/Linux_ConcreteJobProvider.c @@ -1,11 +1,11 @@ #include <konkret/konkret.h> #include <stdint.h> #include "Linux_ConcreteJob.h" +#include "globals.h" static const CMPIBroker* _cb = NULL; #include "power.h" -#include "trace.h" static void Linux_ConcreteJobInitializeInstance(CMPIInstanceMI *mi) { @@ -50,7 +50,6 @@ static CMPIStatus Linux_ConcreteJobEnumInstances( CMPIStatus status; const char *ns = KNameSpace(cop); - TRACE(1, "Linux_ConcreteJobEnumInstances"); PowerStateChangeJob *powerStateChangeJob; GList *plist = power_get_jobs(mi->hdl); diff --git a/src/power/Linux_HostedServiceProvider.c b/src/power/Linux_HostedServiceProvider.c index 4f6c7ac..cbfd55d 100644 --- a/src/power/Linux_HostedServiceProvider.c +++ b/src/power/Linux_HostedServiceProvider.c @@ -5,7 +5,6 @@ #include "Linux_ComputerSystem.h" #include "globals.h" -#include "trace.h" static const CMPIBroker* _cb; diff --git a/src/power/Linux_PowerManagementServiceProvider.c b/src/power/Linux_PowerManagementServiceProvider.c index 8ce3f6c..ca328a9 100644 --- a/src/power/Linux_PowerManagementServiceProvider.c +++ b/src/power/Linux_PowerManagementServiceProvider.c @@ -3,7 +3,6 @@ #include "power.h" #include "globals.h" -#include "trace.h" static const CMPIBroker* _cb = NULL; @@ -23,11 +22,8 @@ static CMPIStatus Linux_PowerManagementServiceCleanup( const CMPIContext* cc, CMPIBoolean term) { - TRACE(1, "Linux_PowerManagementServiceCleanup\n"); - power_unref(mi->hdl); mi->hdl = NULL; - CMReturn(CMPI_RC_OK); } @@ -37,8 +33,6 @@ static CMPIStatus Linux_PowerManagementServiceEnumInstanceNames( const CMPIResult* cr, const CMPIObjectPath* cop) { - TRACE(1, "Linux_PowerManagementServiceEnumInstanceNames\n"); - return KDefaultEnumerateInstanceNames( _cb, mi, cc, cr, cop); } @@ -50,8 +44,6 @@ static CMPIStatus Linux_PowerManagementServiceEnumInstances( const CMPIObjectPath* cop, const char** properties) { - TRACE(1, "Linux_PowerManagementServiceEnumInstances\n"); - Linux_PowerManagementService w; Linux_PowerManagementService_Init(&w, _cb, KNameSpace(cop)); @@ -244,7 +236,6 @@ KUint32 Linux_PowerManagementService_RequestPowerStateChange( const KDateTime* TimeoutPeriod, CMPIStatus* status) { - TRACE(1, "Linux_PowerManagementService_RequestPowerStateChange\n"); KUint32 result = KUINT32_INIT; if (Time->exists && Time->null && TimeoutPeriod->exists && TimeoutPeriod->null) { @@ -260,8 +251,7 @@ KUint32 Linux_PowerManagementService_RequestPowerStateChange( // Time argument is not handled because we don't support powering on systems if (!PowerState->exists || PowerState->null) { - TRACE(1, "wrong PowerState\n"); - KSetStatus(status, ERR_INVALID_PARAMETER); + KSetStatus2(_cb, status, ERR_INVALID_PARAMETER, "PowerState argument is missing"); return result; } power_request_power_state(mi->hdl, PowerState->value); diff --git a/src/power/globals.c b/src/power/globals.c deleted file mode 100644 index 2ba5075..0000000 --- a/src/power/globals.c +++ /dev/null @@ -1,24 +0,0 @@ - -#include "globals.h" - -#define _XOPEN_SOURCE 500 - -#include <stdlib.h> -#include <unistd.h> -#include "trace.h" - -static char *_hostname = NULL; - -const char *get_system_name() -{ - if (_hostname == NULL) { - _hostname = malloc(256 * sizeof(char)); - if (gethostname(_hostname, 255) == -1) { - TRACE(4, "get_hostname(): gethostname returned -1"); - free(_hostname); - _hostname = NULL; - } - } - // TODO: try to get full qualified hostname - return _hostname; -} diff --git a/src/power/globals.h b/src/power/globals.h deleted file mode 100644 index adec07e..0000000 --- a/src/power/globals.h +++ /dev/null @@ -1,7 +0,0 @@ - -#ifndef GLOBALS_H -#define GLOBALS_H - -const char *get_system_name(); - -#endif
\ No newline at end of file diff --git a/src/power/trace.c b/src/power/trace.c deleted file mode 100644 index 1f23a6a..0000000 --- a/src/power/trace.c +++ /dev/null @@ -1,29 +0,0 @@ - -#include <stdlib.h> -#include <stdio.h> -#include <stdarg.h> - -static FILE *_trace_file = NULL; - -void _trace(int level, const char *file, int line, const char *format, ...) -{ - // TODO; level - if (_trace_file == NULL) { - char *filename = getenv("SBLIM_TRACE_FILE"); - if (filename != NULL) { - _trace_file = fopen(filename, "a"); - if (_trace_file == NULL) { - _trace_file = stderr; - } - } else { - _trace_file = stderr; - } - } - - va_list args; - va_start(args, format); - fprintf(_trace_file, "%s:%d\t", file, line); - vfprintf(_trace_file, format, args); - fprintf(_trace_file, "\n"); - va_end(args); -} diff --git a/src/power/trace.h b/src/power/trace.h deleted file mode 100644 index 65118d4..0000000 --- a/src/power/trace.h +++ /dev/null @@ -1,4 +0,0 @@ - -#define TRACE(level, ...) _trace(level, __FILE__, __LINE__, __VA_ARGS__) - -void _trace(int level, const char *file, int line, const char *format, ...); |