14 Commits

Author SHA1 Message Date
Andrew Kelley
209a3da4f7 provide default implementation of std.log on freestanding
closes #6252
2020-09-04 13:00:10 -07:00
Andrew Kelley
4a69b11e74 add license header to all std lib files
add SPDX license identifier
copyright ownership is zig contributors
2020-08-20 16:07:04 -04:00
heidezomp
2439f67061 std.log: update documentation and example for scoped logging 2020-08-13 17:12:16 +02:00
heidezomp
a8e0f667c6 std.log: (breaking) remove scope parameter from logging functions
The logging functions in std.log don't take a scope parameter anymore,
but use the .default scope. To provide your own scope, use the logging
functions in std.log.scoped(.some_other_scope).

As per nmichaels' suggestion: https://github.com/ziglang/zig/pull/6039#issuecomment-673148971
2020-08-13 16:50:38 +02:00
heidezomp
bf2ed0f571 std.log: don't state in docs that messages are logged to stderr
Since the logger implementation can be overridden, the messages might
not be logged to stderr at all.
2020-08-12 15:54:21 +02:00
heidezomp
25607079f0 std.log: add documentation for scoped logging
* Add short documentation to std.log.scoped and std.log.default
 * Update the module documentation and example to explain the difference
   between using explicit scopes, using a scoped logging namespace, and
   using the default namespace
2020-08-12 15:37:56 +02:00
heidezomp
7db2c11537 std.log: add scoped logging struct
* Add a std.log.scoped function that returns a scoped logging struct
 * Add a std.log.default struct that logs using the .default scope

Implementation of daurnimator's proposal:
https://github.com/ziglang/zig/issues/5943#issuecomment-669043489

Note that I named the function "scoped" instead of "scope" so as not to
clash with the scope parameter that is used everywhere; this seemed a
better solution to me than renaming the scope parameter to "s" or
"log_scope" or the like.
2020-08-12 14:03:02 +02:00
heidezomp
32a6759a7a Fix std.log example to make the log handler print the newline
Follow up from #5910
2020-07-22 22:08:08 +00:00
joachimschmidt557
c6bd8e8c53 Make the default log handler print a newline
Closes #5907
2020-07-22 17:02:27 +00:00
purringChaos
094223d634 Fix log.zig example. 2020-07-21 18:53:30 +03:00
Vexu
be1507a7af
update compile error tests and some doc comments 2020-07-12 00:54:07 +03:00
Vexu
e85fe13e44
run zig fmt on std lib and self hosted 2020-07-11 20:41:19 +03:00
Haze Booth
237c5429b0 Don't attempt to use io from thin air 2020-06-19 02:06:27 -04:00
Isaac Freund
0bd067d19a
Introduce std.log
std.log provides 8 log levels and corresponding logging functions. It
allows the user to override the logging "backend" by defining root.log
and to override the default log level by defining root.log_level.

Logging functions accept a scope parameter which allows the implementer
of the logging "backend" to filter logging by library as well as level.

Using the standardized syslog [1] log levels ensures that std.log will
be flexible enough to work for as many use-cases as possible. If we were
to stick with only 3/4 log levels, std.log would be insufficient for
large and/or complex projects such as a kernel or display server.

[1]: https://tools.ietf.org/html/rfc5424#section-6.2.1
2020-06-17 02:14:52 +02:00