Enumerations | Functions

/home/sindre/dev_uclinux/suzaku_shared/hwos_sw/libhwos/hlog.h File Reference

[Hardware OS log interface] Log file functions for HWOS. More...

Go to the source code of this file.

Enumerations

enum  hlog_flag { HLOG_ERROR, HLOG_WARNING, HLOG_NORMAL, HLOG_DEBUG }
 

Definition of possible flags for log entries.


Functions

int hlog_init ()
 Open the log file for the HWOS.
void hlog_write (enum hlog_flag flag, char *text)
 Write a flag and a string to the log file.
void hlog_write_text (char *text)
 Write a string to the log file.
void hlog_write_integer (int number)
 Write an integer to the log file.
void hlog_close ()
 Close the log file for the HWOS.

Detailed Description

[Hardware OS log interface] Log file functions for HWOS.

Functionality for writing to a log file. Writing to the log is mutual exclusive and thread safe.

Author (2011): Sindre Hansen

Definition in file hlog.h.


Function Documentation

void hlog_close (  ) 

Close the log file for the HWOS.

Definition at line 77 of file hlog.c.

{
        if (hlogfile == NULL)
                return;

        fclose(hlogfile);
}

int hlog_init (  ) 

Open the log file for the HWOS.

Returns:
Positive value on success. Negative value on failure.
void hlog_write ( enum hlog_flag  flag,
char *  text 
)

Write a flag and a string to the log file.

Parameters:
flag Flag to write. Could for example indicate an error or a warning.
text Character array (string) to be written.

Definition at line 19 of file hlog.c.

{
        if (hlogfile == NULL)
                return;
        
        
        pthread_mutex_lock(&write_mutex); 

        switch (flag) {
                case HLOG_ERROR:
                        fprintf(hlogfile, "ERROR: ");
                        break;
                case HLOG_WARNING:
                        fprintf(hlogfile, "WARNING: ");
                        break;
                case HLOG_NORMAL:
                        fprintf(hlogfile, "NORMAL: ");
                        break;
                case HLOG_DEBUG:
                        fprintf(hlogfile, "DEBUG: ");
                        break;
                default:
                        fprintf(hlogfile, "UNKNOWN: ");
                        break;
        }

        fprintf(hlogfile,"%s", text);
        fflush(hlogfile);

        pthread_mutex_unlock(&write_mutex);
}

void hlog_write_integer ( int  number  ) 

Write an integer to the log file.

Parameters:
number Integer value to be written.

Definition at line 64 of file hlog.c.

{
        if (hlogfile == NULL)
                return;

        pthread_mutex_lock(&write_mutex); 

        fprintf(hlogfile,"%d", number);
        fflush(hlogfile);

        pthread_mutex_unlock(&write_mutex);
}

void hlog_write_text ( char *  text  ) 

Write a string to the log file.

Parameters:
text Character array (string) to be written.

Definition at line 51 of file hlog.c.

{
        if (hlogfile == NULL)
                return;

        pthread_mutex_lock(&write_mutex); 

        fprintf(hlogfile,"%s", text);
        fflush(hlogfile);

        pthread_mutex_unlock(&write_mutex);
}

 All Data Structures Files Functions Variables Enumerations Enumerator Defines