Changeset 669f5cae in mainline for uspace/srv/logger/main.c


Ignore:
Timestamp:
2012-08-16T08:44:34Z (12 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
6e9e12b
Parents:
cddcc4a3
Message:

Allow setting default log level

Currently, it does not affect existing clients.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/logger/main.c

    rcddcc4a3 r669f5cae  
    4747#include "logger.h"
    4848
     49static void connection_handler_control(void)
     50{
     51        printf(NAME "/control: new client.\n");
     52
     53        while (true) {
     54                ipc_call_t call;
     55                ipc_callid_t callid = async_get_call(&call);
     56
     57                if (!IPC_GET_IMETHOD(call))
     58                        break;
     59
     60                int rc;
     61
     62                switch (IPC_GET_IMETHOD(call)) {
     63                case LOGGER_CTL_GET_DEFAULT_LEVEL:
     64                        async_answer_1(callid, EOK, get_default_logging_level());
     65                        break;
     66                case LOGGER_CTL_SET_DEFAULT_LEVEL:
     67                        rc = set_default_logging_level(IPC_GET_ARG1(call));
     68                        async_answer_0(callid, rc);
     69                        break;
     70                default:
     71                        async_answer_0(callid, EINVAL);
     72                        break;
     73                }
     74        }
     75
     76        printf(NAME "/control: client terminated.\n");
     77}
     78
    4979static logging_namespace_t *find_namespace_and_attach_writer(void)
    5080{
     
    74104static int handle_receive_message(logging_namespace_t *namespace, int level)
    75105{
    76         bool skip_message = (level > DEFAULT_LOGGING_LEVEL) && !namespace_has_reader(namespace, level);
     106        bool skip_message = (level > (int)get_default_logging_level()) && !namespace_has_reader(namespace, level);
    77107        if (skip_message) {
    78108                /* Abort the actual message buffer transfer. */
     
    221251
    222252        switch (iface) {
     253        case LOGGER_INTERFACE_CONTROL:
     254                async_answer_0(iid, EOK);
     255                connection_handler_control();
     256                break;
    223257        case LOGGER_INTERFACE_SINK:
    224258                /* First call has to be the registration. */
Note: See TracChangeset for help on using the changeset viewer.