Skip to content

Commit

Permalink
[Go Docs] Update Documentation (#57)
Browse files Browse the repository at this point in the history
* Go Docs [Package] [Configuration] Update Documentation

- [+] refactor(configuration/docs.go): update documentation for LoadTasks function and remove outdated information

* Go Docs [Package] [Navigator] Update Documentation

- [+] docs(navigator): update package documentation in docs.go
	- Update package description to emphasize tailored logging capabilities for K8sBlackPearl project
	- Mention the use of uber-go/zap library for high-performance, leveled logging
	- Highlight the enhancement of log messages with emojis for visual distinction
	- Specify support for structured logging with zap.Field parameters
	- Clarify the availability of a package-level Logger variable that needs to be set using SetLogger
	- Explain the default behavior of printing error messages to standard output if Logger is not set
	- Provide examples of using LogInfoWithEmoji and LogErrorWithEmoji functions for logging
	- Describe the CreateLogFields helper function for generating zap.Field parameters
	- Emphasize the importance of invoking SetLogger before logging to avoid nil pointer dereferences
	- Mention the optional use of emoji strings for visual enhancement in log messages

- [+] Note: The copyright year and author information remain unchanged.
  • Loading branch information
H0llyW00dzZ authored Dec 30, 2023
1 parent 6029bae commit 228218a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 38 deletions.
33 changes: 15 additions & 18 deletions navigator/docs.go
Original file line number Diff line number Diff line change
@@ -1,34 +1,31 @@
// Package navigator provides structured logging capabilities for the K8sBlackPearl project,
// leveraging the uber-go/zap library. It offers leveled logging with the option to prefix
// messages with emojis for enhanced visual distinction.
// Package navigator provides structured logging capabilities tailored for the K8sBlackPearl project,
// utilizing the uber-go/zap library for high-performance, leveled logging. This package enhances
// log messages with emojis for visual distinction and supports structured logging with zap.Field parameters.
//
// A package-level Logger variable is available and protected by a mutex to ensure safe
// concurrent access. This Logger should be initialized and set using SetLogger prior to
// invoking any logging functions. Failing to set the Logger will result in error messages
// being printed to standard output instead of proper log entries.
// A package-level Logger variable is available, which should be set using SetLogger before any logging
// functions are called. If the Logger is not set, logging functions will default to printing error messages
// to standard output to prevent the application from panicking due to a nil Logger.
//
// Logging functions such as LogInfoWithEmoji and LogErrorWithEmoji are available for
// recording informational and error messages, respectively. These functions enhance log
// messages with emojis and a context string for quick identification. They also support
// structured logging by accepting a variable number of zap.Field parameters.
// Functions such as LogInfoWithEmoji and LogErrorWithEmoji are provided for logging informational and error
// messages, respectively. These functions append emojis to the log messages for easier visual scanning in log
// output. They also accept a variable number of zap.Field parameters for structured context logging.
//
// Helper function CreateLogFields is provided to generate a slice of zap.Field from
// specified strings, facilitating the inclusion of consistent structured context within
// logs throughout the application.
// The CreateLogFields helper function is available to generate a slice of zap.Field from specified strings,
// enabling consistent structured context in logs throughout the application.
//
// # Usage
//
// The Logger must be initialized and set using SetLogger before any logging activity.
// Subsequently, LogInfoWithEmoji and LogErrorWithEmoji can be employed for logging
// messages with structured context.
// Before logging, the Logger must be initialized and set using SetLogger. After setting up, the logging
// functions such as LogInfoWithEmoji and LogErrorWithEmoji can be used for logging messages with structured
// context.
//
// Example:
//
// // Initialize the Logger (usually at the start of the application)
// logger, _ := zap.NewProduction()
// navigator.SetLogger(logger)
//
// // Logging with the package functions
// // Logging with package functions
// navigator.LogInfoWithEmoji("🚀", "Application started")
// navigator.LogErrorWithEmoji("❗️", "An error occurred", zap.Error(err))
//
Expand Down
27 changes: 7 additions & 20 deletions worker/configuration/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,23 @@
// It includes methods such as LoadTasksFromJSON and LoadTasksFromYAML to facilitate the
// reading and parsing of configuration files.
//
// A package-level ValidateTask function is exposed to ensure that task configurations
// adhere to expected schemas and constraints. This function should be used to validate
// tasks after loading them to prevent runtime errors due to misconfiguration.
//
// The package also includes helper functions like ConvertToTaskSlice which assists in
// converting generic interface{} types (which may be the result of unstructured parsing)
// into a slice of Task structs.
// The LoadTasks function is exposed to load tasks from a file whose extension determines
// the format of the tasks to be loaded (either JSON or YAML). This function abstracts away
// the specific parsing logic and provides a simple interface for loading tasks.
//
// # Usage
//
// The LoadTasksFromJSON and LoadTasksFromYAML functions should be used to load task
// configurations at the start of the application. The ValidateTask function can be
// used to ensure the validity of the loaded tasks.
// The LoadTasks function should be used to load task configurations at the start of the application.
//
// Example:
//
// // Loading tasks from a JSON configuration file
// tasks, err := configuration.LoadTasksFromJSON("tasks.json")
// // Loading tasks from a configuration file (JSON or YAML)
// tasks, err := configuration.LoadTasks("tasks.json") // .json or .yaml file
// if err != nil {
// // Handle error
// }
//
// // Validate loaded tasks
// for _, task := range tasks {
// if err := configuration.ValidateTask(task); err != nil {
// // Handle validation error
// }
// }
//
// // Application logic using the validated tasks
// // Application logic using the loaded tasks
// for _, task := range tasks {
// fmt.Printf("Task: %+v\n", task)
// }
Expand Down

0 comments on commit 228218a

Please sign in to comment.