| /******************************************************************************* |
| * Copyright (c) 2019 protos software gmbh (http://www.protos.de). |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License 2.0 |
| * which accompanies this distribution, and is available at |
| * https://www.eclipse.org/legal/epl-2.0/ |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| *******************************************************************************/ |
| |
| RoomModel etrice.api.logger { |
| |
| import etrice.api.types.voidType |
| import etrice.api.types.char |
| |
| /** <!-- asciidoc --> |
| * Protocol for logging text messages. |
| * |
| * This protocol is a service and can be accessed via an SAP. It provides PortOperations to log (formatted) messages. |
| * [source, room] |
| * ---- |
| * logger.log("message"); |
| * logger.logF("counter %d", 100); |
| * ---- |
| */ |
| ProtocolClass PLogger { |
| usercode3 ''' |
| #include <stdarg.h> |
| extern void PLogging_internal_logF(); |
| ''' |
| conjugated PortClass |
| { |
| |
| /** |
| * Logs a simple message. Appends line separator. |
| */ |
| Operation log(message: char ref) ''' |
| logF(message, NULL); |
| ''' |
| |
| /** |
| * Logs a formatted message with arguments. Appends line separator. |
| */ |
| Operation logF(format: char ref, args: voidType varargs) ''' |
| va_list argptr; |
| va_start(argptr, format); |
| // TODO call etLogger |
| PLogger_internal_logF(format, argptr); |
| va_end(argptr); |
| ''' |
| } |
| } |
| } |