logs.LogWarning
Overview¶
The "LogWarning" method of the "logs Object" is used to display and output logs with the type Warning in "Server Script".
Syntax¶
Parameters¶
| Parameters | Type | Required | Description |
|---|---|---|---|
| message | string | Yes | Specifies the warning message to display or output. |
| method | string | Optional. Default value is an empty string. | |
| console | bool | Optional. Default value is true. Set to true to display the warning in the browser's developer tools console. | |
| syslogs | bool | Optional. Default value is true. Set to true to output the warning to the system log. |
Return Value¶
Returns true if the log was successfully displayed or output, and false otherwise.
Console Display Format¶
Display Format¶
| Display Column | Display Content | Notes |
|---|---|---|
| Message | The string set in the message | |
| Method | The string set in the method | If method is not specified, brackets([])will not be displayed. |
System Log Output Fields¶
| Output Column | Output Content | Notes |
|---|---|---|
| Comments | The string set in the message | |
| Method | The original Method combined with the method value in the format :method | |
| SysLogType | 50 | Fixed at 50(Warning) |
Usage Examples¶
In the example below, a record with the title "About Pleasanter Version Upgrade" is created in the "temporary table" of Site ID 2. If the creation fails, a warning log is output.
JavaScript¶
const siteId = 2;
const item = items.NewIssue();
item.Title = 'About Pleasanter Version Upgrade';
const ret = items.Create(siteId, item);
if (!ret) {
logs.LogWarning(`Failed to create the record. Site ID:${siteId}`);
}
Code Samples¶
1. A general-purpose logging function
This is a sample code of a general-purpose logger that wraps each method of the logs object so that log output can be switched between debugging and production.
Functional requirements¶
-
Output control by a debug flag
logger.debug()is output only whenDEBUG_MODE(bool) is set totrue. When it isfalse, the output is completely suppressed. -
Centralized management of output destinations
With
LOG_TARGET(bool values for console / syslogs), output to the console and to the system log can each be turned on or off individually. The settings apply to the whole script at once. -
Log levels
The following 6 methods are provided, and each delegates to the corresponding
logsmethod.Method Delegates to Always output logger.debug() LogInfo ✗ (debugging only) logger.info() LogInfo ✓ logger.warn() LogWarning ✓ logger.userError() LogUserError ✓ logger.systemError() LogSystemError ✓ logger.exception() LogException ✓
JavaScript¶
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 | |
Supported Versions¶
| Supported versions | Body |
|---|---|
| 1.4.12.0 or later | Added function |