{"@context":"https://w3id.org/codemeta/3.0","@type":"SoftwareSourceCode","identifier":"pkg:golang/github.com/go-spring/log","name":"github.com/go-spring/log","description":"Package log is a high-performance and extensible logging library designed specifically for the Go programming\nlanguage. It provides flexible and structured logging capabilities, including context field extraction, multi-level\nlogging configuration, and multiple output options, making it ideal for server-side applications.\n\n## Core Concepts:\n\nTags:\n\nTags are a core concept in the log package used to categorize logs. By registering a tag via the `RegisterTag`\nfunction, you can use regular expressions to match the user-defined tags. This approach allows for a unified API\nfor logging without explicitly creating logger instances. Even third-party libraries can write logs without\nsetting up a logger object.\n\nLoggers:\n\nA Logger is the object that actually handles the logging process. You can obtain a logger instance using the\n`GetLogger` function, which is mainly provided for compatibility with legacy projects. This allows you to\ndirectly retrieve a logger by its name and log pre-formatted messages using the `Write` function.\n\nContext Field Extraction:\n\nContextual data can be extracted and included in log entries via configurable functions:\n- `log.StringFromContext`: Extracts a string value (e.g., a request ID) from the context.\n- `log.FieldsFromContext`: Returns a list of structured fields from the context, such as trace IDs or user IDs.\n\nConfiguration from File:\n\nThe `log.RefreshFile` function allows loading the logger's configuration from an external file (e.g., XML or JSON).\n\nLogger Initialization and Logging:\n\n- Using `GetLogger`, you can fetch a logger instance (often for compatibility with older systems).\n- You can also register custom tags using `RegisterTag` to classify logs according to your needs.\n\nLogging Messages:\n\nThe package provides various logging functions, such as `Tracef`, `Debugf`, `Infof`, `Warnf`, etc.,\nwhich log messages at different levels (e.g., Trace, Debug, Info, Warn).\nThese functions can either accept structured fields or formatted messages.\n\nStructured Logging:\n\nThe logger also supports structured logging, where fields are captured as key-value pairs and logged with the message.\nThe fields can be provided directly in the log functions or through a map.\n\n## Examples:\n\nUsing a pre-registered tag:\n\nUsing structured fields:","version":"v0.0.12","softwareVersion":"v0.0.12","license":"https://spdx.org/licenses/Apache-2.0","codeRepository":"https://github.com/go-spring/log","issueTracker":"https://github.com/go-spring/log/issues","url":"https://github.com/go-spring/log","programmingLanguage":{"@type":"ComputerLanguage","name":"Go"},"dateCreated":"2025-06-13","dateModified":"2025-10-01","datePublished":"2025-10-01","copyrightYear":2025,"downloadUrl":"https://proxy.golang.org/cached-only/github.com/go-spring/log/@v/v0.0.12.zip","softwareHelp":{"@type":"WebSite","url":"https://pkg.go.dev/github.com/go-spring/log#section-documentation"},"applicationCategory":"go","runtimePlatform":"go","developmentStatus":"active","sameAs":["https://pkg.go.dev/github.com/go-spring/log"],"https://www.w3.org/ns/activitystreams#likes":5}