tools/thermal/lib/log.c
Source file repositories/reference/linux-study-clean/tools/thermal/lib/log.c
File Facts
- System
- Linux kernel
- Corpus path
tools/thermal/lib/log.c- Extension
.c- Size
- 1354 bytes
- Lines
- 78
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
Dependency Surface
stdarg.hstdio.hstring.hsyslog.hlog.h
Detected Declarations
function log_str2levelfunction logitfunction log_initfunction log_exit
Annotated Snippet
// SPDX-License-Identifier: LGPL-2.1+
// Copyright (C) 2022, Linaro Ltd - Daniel Lezcano <daniel.lezcano@linaro.org>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <syslog.h>
#include "log.h"
static const char *__ident = "unknown";
static int __options;
static const char * const loglvl[] = {
[LOG_DEBUG] = "DEBUG",
[LOG_INFO] = "INFO",
[LOG_NOTICE] = "NOTICE",
[LOG_WARNING] = "WARN",
[LOG_ERR] = "ERROR",
[LOG_CRIT] = "CRITICAL",
[LOG_ALERT] = "ALERT",
[LOG_EMERG] = "EMERG",
};
int log_str2level(const char *lvl)
{
int i;
for (i = 0; i < sizeof(loglvl) / sizeof(loglvl[LOG_DEBUG]); i++)
if (!strcmp(lvl, loglvl[i]))
return i;
return LOG_DEBUG;
}
extern void logit(int level, const char *format, ...)
{
va_list args;
va_start(args, format);
if (__options & TO_SYSLOG)
vsyslog(level, format, args);
if (__options & TO_STDERR)
vfprintf(stderr, format, args);
if (__options & TO_STDOUT)
vfprintf(stdout, format, args);
va_end(args);
}
int log_init(int level, const char *ident, int options)
{
if (!options)
return -1;
if (level > LOG_DEBUG)
return -1;
if (!ident)
return -1;
__ident = ident;
__options = options;
if (options & TO_SYSLOG) {
openlog(__ident, options | LOG_NDELAY, LOG_USER);
setlogmask(LOG_UPTO(level));
}
return 0;
}
void log_exit(void)
{
closelog();
}
Annotation
- Immediate include surface: `stdarg.h`, `stdio.h`, `string.h`, `syslog.h`, `log.h`.
- Detected declarations: `function log_str2level`, `function logit`, `function log_init`, `function log_exit`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.